Skip to content

Feature Request: Support Combined Assignment and Multi-Variable Documentation in @doc #59633

@ilyagarazha

Description

@ilyagarazha

Currently, Julia’s @doc macro supports two useful patterns:

  1. Assigning a value while adding a docstring:

    @doc "Square root of pi" sqr_pi = π
  2. Documenting multiple unassigned variables:

    @doc "Parameter of PID controller" K_p, K_i, K_d

However, combining these two features — assigning values and documenting multiple variables with a single docstring — is not supported. For example:

@doc "Parameter of PID controller" K_p, K_i, K_d = 1, 2, 3

…currently only attaches the docstring to K_p, while K_i and K_d remain undocumented, even though they are logically part of the same conceptual group.

Desired Behavior

The macro should allow a docstring to be applied to all variables in a multi-assignment expression:

@doc "Parameter of PID controller" K_p, K_i, K_d = 1, 2, 3

→ This should attach the same docstring to K_p, K_i, and K_d (just like @doc "..." x, y does for unassigned variables).

Why This Matters

This would improve code clarity and maintainability, especially in scientific or control systems code, where related constants are often defined and documented together. It avoids repetition and keeps documentation logically grouped with the variables it describes.

Example Use Case

@doc """
    PID controller gains.
    K_p: Proportional gain
    K_i: Integral gain
    K_d: Derivative gain
""" K_p, K_i, K_d = 1.0, 0.1, 0.01

Currently, only K_p gets the docstring. With this enhancement, all three would be properly documented in ?K_p, ?K_i, and ?K_d.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsystemThe documentation building systemfeatureIndicates new feature / enhancement requests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions