From 7aa1c5eed298cfbfa6638ac2cd6f53fe1d75bdc0 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 4 Nov 2008 21:35:05 +0100 Subject: [PATCH] #21: allow short form for seealso arguments. --- CHANGES | 3 +++ doc/markup/para.rst | 7 +++++++ sphinx/directives/other.py | 11 ++++++++--- sphinx/util/compat.py | 2 +- tests/root/markup.txt | 2 +- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 590ea7067..e1fd96a2b 100644 --- a/CHANGES +++ b/CHANGES @@ -28,6 +28,9 @@ New features added - Lists enumerated by letters or roman numerals are now handled like in standard reST. + - The ``seealso`` directive can now also be given arguments, as a short + form. + * HTML output and templates: - Incompatible change: The "root" relation link (top left in the diff --git a/doc/markup/para.rst b/doc/markup/para.rst index ebc70426e..c60eb2587 100644 --- a/doc/markup/para.rst +++ b/doc/markup/para.rst @@ -74,6 +74,13 @@ units as well as normal text: `GNU tar manual, Basic Tar Format `_ 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 This directive creates a paragraph heading that is not used to create a diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index 442313a93..2e64eb0cf 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -229,13 +229,18 @@ directives.register_directive('versionchanged', version_directive) def seealso_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): - rv = make_admonition( + seealsonode = make_admonition( addnodes.seealso, name, [_('See also')], options, content, 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.arguments = (0, 0, 0) +seealso_directive.arguments = (0, 1, 1) directives.register_directive('seealso', seealso_directive) diff --git a/sphinx/util/compat.py b/sphinx/util/compat.py index f7d646b6c..f9b88a449 100644 --- a/sphinx/util/compat.py +++ b/sphinx/util/compat.py @@ -33,5 +33,5 @@ def make_admonition(node_class, name, arguments, options, content, lineno, classes = ['admonition-' + nodes.make_id(title_text)] admonition_node['classes'] += classes state.nested_parse(content, content_offset, admonition_node) - return [admonition_node] + return admonition_node diff --git a/tests/root/markup.txt b/tests/root/markup.txt index 43e4e5902..c2c6b7440 100644 --- a/tests/root/markup.txt +++ b/tests/root/markup.txt @@ -99,7 +99,7 @@ Stuff [#]_ Reference lookup: [Ref1]_ (defined in another file). -.. seealso:: +.. seealso:: something, something else, something more `Google `_ For everything.