You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: restructuredtext/style.rst
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -356,6 +356,38 @@ Objects can be referenced with these roles:
356
356
- ``:py:data:`pkg.mod.VARIABLE``` to reference a module-level variable ``VARIABLE`` in ``pkg.mod``.
357
357
- ``:py:const:`pkg.mod.CONSTANT``` to reference a module-level *constant* ``CONSTANT`` in ``pkg.mod``.
358
358
359
+
.. note::
360
+
Types in docstrings do *not* respect imports in the file, and instead are resolved using `Sphinx's own target-resolution rules <https://www.sphinx-doc.org/en/master/usage/domains/python.html#target-resolution>`__.
361
+
In other words,
362
+
363
+
.. code-block::
364
+
365
+
from collections.abc import Sequence
366
+
367
+
def run_stuff(stuff):
368
+
"""Run some stuff.
369
+
370
+
Parameters
371
+
----------
372
+
stuff : `Sequence` [`str`]
373
+
Stuff to run.
374
+
375
+
does not work, but
376
+
377
+
.. code-block::
378
+
379
+
from collections.abc import Sequence
380
+
381
+
def run_stuff(stuff):
382
+
"""Run some stuff.
383
+
384
+
Parameters
385
+
----------
386
+
stuff : `~collections.abc.Sequence` [`str`]
387
+
Stuff to run.
388
+
389
+
does. See the link above for how to make relative links to types; the syntax is not the same as Python's, and it operates on the documentation hierarchy, not the module hierarchy.
0 commit comments