#21: allow short form for seealso arguments.

This commit is contained in:
Georg Brandl 2008-11-04 21:35:05 +01:00
parent a29cd9518a
commit 7aa1c5eed2
5 changed files with 20 additions and 5 deletions

View File

@ -28,6 +28,9 @@ New features added
- Lists enumerated by letters or roman numerals are now handled like in - Lists enumerated by letters or roman numerals are now handled like in
standard reST. standard reST.
- The ``seealso`` directive can now also be given arguments, as a short
form.
* HTML output and templates: * HTML output and templates:
- Incompatible change: The "root" relation link (top left in the - Incompatible change: The "root" relation link (top left in the

View File

@ -74,6 +74,13 @@ units as well as normal text:
`GNU tar manual, Basic Tar Format <http://link>`_ `GNU tar manual, Basic Tar Format <http://link>`_
Documentation for tar archive files, including GNU tar extensions. Documentation for tar archive files, including GNU tar extensions.
There's also a "short form" allowed that looks like this::
.. seealso:: modules :mod:`zipfile`, :mod:`tarfile`
.. versionadded:: 0.5
The short form.
.. directive:: .. rubric:: title .. directive:: .. rubric:: title
This directive creates a paragraph heading that is not used to create a This directive creates a paragraph heading that is not used to create a

View File

@ -229,13 +229,18 @@ directives.register_directive('versionchanged', version_directive)
def seealso_directive(name, arguments, options, content, lineno, def seealso_directive(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine): content_offset, block_text, state, state_machine):
rv = make_admonition( seealsonode = make_admonition(
addnodes.seealso, name, [_('See also')], options, content, addnodes.seealso, name, [_('See also')], options, content,
lineno, content_offset, block_text, state, state_machine) lineno, content_offset, block_text, state, state_machine)
return rv if arguments:
argnodes, msgs = state.inline_text(arguments[0], lineno)
para = nodes.paragraph()
para += argnodes
seealsonode[1:1] = [para] + msgs
return [seealsonode]
seealso_directive.content = 1 seealso_directive.content = 1
seealso_directive.arguments = (0, 0, 0) seealso_directive.arguments = (0, 1, 1)
directives.register_directive('seealso', seealso_directive) directives.register_directive('seealso', seealso_directive)

View File

@ -33,5 +33,5 @@ def make_admonition(node_class, name, arguments, options, content, lineno,
classes = ['admonition-' + nodes.make_id(title_text)] classes = ['admonition-' + nodes.make_id(title_text)]
admonition_node['classes'] += classes admonition_node['classes'] += classes
state.nested_parse(content, content_offset, admonition_node) state.nested_parse(content, content_offset, admonition_node)
return [admonition_node] return admonition_node

View File

@ -99,7 +99,7 @@ Stuff [#]_
Reference lookup: [Ref1]_ (defined in another file). Reference lookup: [Ref1]_ (defined in another file).
.. seealso:: .. seealso:: something, something else, something more
`Google <http://www.google.com>`_ `Google <http://www.google.com>`_
For everything. For everything.