This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add new reST directive for links to source code
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.2
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: alex, eric.araujo, ezio.melotti, georg.brandl, rhettinger
Priority: low Keywords:

Created on 2010-11-06 06:28 by rhettinger, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg120587 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-11-06 06:28
In a few cases where the pure python source code is a helpful adjunct to the documentation, I've added some links using the "seealso" directive:

  .. seealso::
  
     Latest version of the `ast module Python source code
     <http://svn.python.org/view/python/branches/release27-maint/Lib/ast.py?view=markup>`_


It would be great if a new directive could be introduced for this purpose.  Something like:

.. sourcecode Lib/ast.py


With a directive, we could easily point the root directory to different releases or to a local source directory for local doc build.
msg120590 - (view) Author: Alex Gaynor (alex) * (Python committer) Date: 2010-11-06 06:54
Seems to me it should be an inline directive (or whatever they're called).  i.e. it'd be written::

.. seealso::

    Latest version of the :sourcecode:`ast module Python source code <Lib/ast.py>`.
msg120591 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-06 06:58
A directive can take options, for example to control highlighting, display of line numbers, etc.  Similar existing constructs like literalinclude are directives.

Inline reST things are called roles :)
msg120594 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-11-06 07:20
OK, I added a "source" role in r86256.  It can be used as Alex showed:

either like :source:`ast module Python source code <Lib/ast.py>`
(with an explicit link title)

or like :source:`Lib/ast.py`
(where the link title is the file name).
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54543
2010-11-06 15:13:05ezio.melottisetnosy: + ezio.melotti

stage: resolved
2010-11-06 07:20:34georg.brandlsetstatus: open -> closed
resolution: accepted
messages: + msg120594
2010-11-06 06:58:01eric.araujosetnosy: + eric.araujo
messages: + msg120591
2010-11-06 06:54:39alexsetnosy: + alex
messages: + msg120590
2010-11-06 06:28:01rhettingercreate