summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES5
-rw-r--r--sphinx/directives/other.py23
-rw-r--r--sphinx/locale/__init__.py2
-rw-r--r--sphinx/writers/html.py2
-rw-r--r--sphinx/writers/text.py2
-rw-r--r--tests/roots/test-intl/contents.txt1
-rw-r--r--tests/roots/test-intl/seealso.po33
-rw-r--r--tests/roots/test-intl/seealso.txt15
-rw-r--r--tests/test_build_gettext.py8
-rw-r--r--tests/test_intl.py13
10 files changed, 82 insertions, 22 deletions
diff --git a/CHANGES b/CHANGES
index 4386b5f1..d7ec12a3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,11 @@
Release 1.2 (in development)
============================
+* PR#99: Strip down seealso directives to normal admonitions. This removes
+ their unusual CSS classes (admonition-see-also), inconsistent LaTeX
+ admonition title ("See Also" instead of "See also"), and spurious indentation
+ in the text builder.
+
* sphinx-build now has a verbose option :option:`-v` which can be
repeated for greater effect. A single occurrance provides a
slightly more verbose output than normal. Two or more occurrences
diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py
index c6baf775..3167d606 100644
--- a/sphinx/directives/other.py
+++ b/sphinx/directives/other.py
@@ -11,6 +11,7 @@ import os
from docutils import nodes
from docutils.parsers.rst import Directive, directives
+from docutils.parsers.rst.directives.admonitions import BaseAdmonition
from docutils.parsers.rst.directives.misc import Class
from docutils.parsers.rst.directives.misc import Include as BaseInclude
@@ -205,29 +206,11 @@ class VersionChange(Directive):
return ret
-class SeeAlso(Directive):
+class SeeAlso(BaseAdmonition):
"""
An admonition mentioning things to look at as reference.
"""
- has_content = True
- required_arguments = 0
- optional_arguments = 1
- final_argument_whitespace = True
- option_spec = {}
-
- def run(self):
- ret = make_admonition(
- addnodes.seealso, self.name, [_('See also')], self.options,
- self.content, self.lineno, self.content_offset, self.block_text,
- self.state, self.state_machine)
- if self.arguments:
- argnodes, msgs = self.state.inline_text(self.arguments[0],
- self.lineno)
- para = nodes.paragraph()
- para += argnodes
- para += msgs
- ret[0].insert(1, para)
- return ret
+ node_class = addnodes.seealso
class TabularColumns(Directive):
diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py
index c1e88c1e..96da67d6 100644
--- a/sphinx/locale/__init__.py
+++ b/sphinx/locale/__init__.py
@@ -159,7 +159,7 @@ admonitionlabels = {
'hint': l_('Hint'),
'important': l_('Important'),
'note': l_('Note'),
- 'seealso': l_('See Also'),
+ 'seealso': l_('See also'),
'tip': l_('Tip'),
'warning': l_('Warning'),
}
diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py
index 33fe2781..252cedc4 100644
--- a/sphinx/writers/html.py
+++ b/sphinx/writers/html.py
@@ -203,7 +203,7 @@ class HTMLTranslator(BaseTranslator):
def visit_admonition(self, node, name=''):
self.body.append(self.starttag(
node, 'div', CLASS=('admonition ' + name)))
- if name and name != 'seealso':
+ if name:
node.insert(0, nodes.title(name, admonitionlabels[name]))
self.set_first_last(node)
diff --git a/sphinx/writers/text.py b/sphinx/writers/text.py
index 2c38aeb4..63b6b9e7 100644
--- a/sphinx/writers/text.py
+++ b/sphinx/writers/text.py
@@ -578,6 +578,8 @@ class TextTranslator(nodes.NodeVisitor):
depart_tip = _make_depart_admonition('tip')
visit_warning = _visit_admonition
depart_warning = _make_depart_admonition('warning')
+ visit_seealso = _visit_admonition
+ depart_seealso = _make_depart_admonition('seealso')
def visit_versionmodified(self, node):
self.new_state(0)
diff --git a/tests/roots/test-intl/contents.txt b/tests/roots/test-intl/contents.txt
index 45db24cc..4ece2621 100644
--- a/tests/roots/test-intl/contents.txt
+++ b/tests/roots/test-intl/contents.txt
@@ -8,6 +8,7 @@
external_links
refs_inconsistency
literalblock
+ seealso
definition_terms
figure_caption
index_entries
diff --git a/tests/roots/test-intl/seealso.po b/tests/roots/test-intl/seealso.po
new file mode 100644
index 00000000..d3b27e51
--- /dev/null
+++ b/tests/roots/test-intl/seealso.po
@@ -0,0 +1,33 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) 2010, Georg Brandl & Team
+# This file is distributed under the same license as the Sphinx <Tests> package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: Sphinx <Tests> 0.6\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-12-16 06:06\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "i18n with seealso"
+msgstr "I18N WITH SEEALSO"
+
+msgid "short text 1"
+msgstr "SHORT TEXT 1"
+
+msgid "long text 1"
+msgstr "LONG TEXT 1"
+
+msgid "short text 2"
+msgstr "SHORT TEXT 2"
+
+msgid "long text 2"
+msgstr "LONG TEXT 2"
+
diff --git a/tests/roots/test-intl/seealso.txt b/tests/roots/test-intl/seealso.txt
new file mode 100644
index 00000000..ed885997
--- /dev/null
+++ b/tests/roots/test-intl/seealso.txt
@@ -0,0 +1,15 @@
+:tocdepth: 2
+
+i18n with seealso
+============================
+.. #960 directive-seelaso-ignored-in-the-gettext
+
+.. seealso:: short text 1
+
+.. seealso::
+
+ long text 1
+
+.. seealso:: short text 2
+
+ long text 2
diff --git a/tests/test_build_gettext.py b/tests/test_build_gettext.py
index d98cde86..2c465c6f 100644
--- a/tests/test_build_gettext.py
+++ b/tests/test_build_gettext.py
@@ -40,6 +40,14 @@ def test_build(app):
@with_app(buildername='gettext')
+def test_seealso(app):
+ # regression test for issue #960
+ app.builder.build(['markup'])
+ catalog = (app.outdir / 'markup.pot').text()
+ assert 'msgid "something, something else, something more"' in catalog
+
+
+@with_app(buildername='gettext')
def test_gettext(app):
app.builder.build(['markup'])
diff --git a/tests/test_intl.py b/tests/test_intl.py
index d828a851..1f8db84f 100644
--- a/tests/test_intl.py
+++ b/tests/test_intl.py
@@ -243,6 +243,19 @@ def test_i18n_definition_terms(app):
@with_intl_app(buildername='text')
+def test_seealso(app):
+ app.builder.build(['seealso'])
+ result = (app.outdir / 'seealso.txt').text(encoding='utf-8')
+ expect = (u"\nI18N WITH SEEALSO"
+ u"\n*****************\n"
+ u"\nSee also: SHORT TEXT 1\n"
+ u"\nSee also: LONG TEXT 1\n"
+ u"\nSee also: SHORT TEXT 2\n"
+ u"\n LONG TEXT 2\n")
+ assert result == expect
+
+
+@with_intl_app(buildername='text')
def test_i18n_figure_caption(app):
# regression test for #940
app.builder.build(['figure_caption'])