Skip to content

Commit

Permalink
Add note about docstrings for aliases (#18157)
Browse files Browse the repository at this point in the history
As mentioned in #18041 (comment)
docstrings attached to aliases of functions should be avoided where possible.
  • Loading branch information
MichaelHatherly authored and tkelman committed Aug 21, 2016
1 parent e08c8b4 commit 3ed55a4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions doc/manual/documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,32 @@ Global Variables
Adds docstring ``"..."`` to the ``Binding``\ s ``a``, ``b``, and ``c``.

.. note::

When a ``const`` definition is only used to define an alias of another definition, such
as is the case with the function ``div`` and its alias ``÷`` in ``Base``, do not
document the alias and instead document the actual function.

If the alias is documented and not the real definition then the docsystem (``?`` mode)
will not return the docstring attached to the alias when the real definition is
searched for.

For example you should write

.. code-block:: julia
"..."
f(x) = x + 1
const alias = f
rather than

.. code-block:: julia
f(x) = x + 1
"..."
const alias = f
.. code-block:: julia
"..."
Expand Down

0 comments on commit 3ed55a4

Please sign in to comment.