-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Description
Currently, Julia’s @doc
macro supports two useful patterns:
-
Assigning a value while adding a docstring:
@doc "Square root of pi" sqr_pi = √π
-
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
.