summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorshimizukawa <shimizukawa@gmail.com>2014-03-23 23:01:15 +0900
committershimizukawa <shimizukawa@gmail.com>2014-03-23 23:01:15 +0900
commitd9d7fb8957db080ef4da9c278c18801cac4bbf29 (patch)
tree34b49fa5094eddf694584e7c9c0ab5a32d11bf1d /tests
parent27f359a1a3e20f00229644a7a76553d1887ae1bd (diff)
downloadsphinx-d9d7fb8957db080ef4da9c278c18801cac4bbf29.tar.gz
Fix i18n: missing python domain's cross-references with currentmodule directive or currentclass directive. refs #1363
* node attributes 'py:module', 'py:class' is provided from environment (e.x. currentmodule directive is provided on previous line, not on node) * Because translation nodes are parsed in independently, 'provided attributes by environment' are not exist. * For a pending_xref nodes, all attributes of a translated xref node should be same as original xref node in current test cases. * For the above reasons, I overwrite all attributes from origonal node to new translated xref node.
Diffstat (limited to 'tests')
-rw-r--r--tests/roots/test-intl/refs_python_domain.po25
-rw-r--r--tests/roots/test-intl/refs_python_domain.txt15
-rw-r--r--tests/test_intl.py14
3 files changed, 54 insertions, 0 deletions
diff --git a/tests/roots/test-intl/refs_python_domain.po b/tests/roots/test-intl/refs_python_domain.po
new file mode 100644
index 00000000..bed87c4c
--- /dev/null
+++ b/tests/roots/test-intl/refs_python_domain.po
@@ -0,0 +1,25 @@
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: issue1363 1363\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-03-16 19:34+0900\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"
+
+#: ..\..\index.rst:4
+msgid "i18n with python domain refs"
+msgstr "I18N WITH PYTHON DOMAIN REFS"
+
+#: ..\..\index.rst:8
+msgid "See this decorator: :func:`sensitive_variables`."
+msgstr "SEE THIS DECORATOR: :func:`sensitive_variables`."
+
+#: ..\..\index.rst:12
+msgid "Some description"
+msgstr "SOME DESCRIPTION"
+
diff --git a/tests/roots/test-intl/refs_python_domain.txt b/tests/roots/test-intl/refs_python_domain.txt
new file mode 100644
index 00000000..20a8bc50
--- /dev/null
+++ b/tests/roots/test-intl/refs_python_domain.txt
@@ -0,0 +1,15 @@
+:tocdepth: 2
+
+i18n with python domain refs
+=============================
+
+.. currentmodule:: sensitive
+
+See this decorator: :func:`sensitive_variables`.
+
+.. function:: sensitive_variables(*variables)
+
+ Some description
+
+.. currentmodule:: reporting
+
diff --git a/tests/test_intl.py b/tests/test_intl.py
index cdbb5f4c..ca0273c8 100644
--- a/tests/test_intl.py
+++ b/tests/test_intl.py
@@ -206,6 +206,20 @@ def test_i18n_footnote_backlink(app):
assert refid2id[ids] == backrefs
+@with_intl_app(buildername='xml', warning=warnfile)
+def test_i18n_refs_python_domain(app):
+ app.builder.build(['refs_python_domain'])
+ et = ElementTree.parse(app.outdir / 'refs_python_domain.xml')
+ secs = et.findall('section')
+
+ # regression test for fix #1363
+ para0 = secs[0].findall('paragraph')
+ assert_elem(
+ para0[0],
+ texts=['SEE THIS DECORATOR:', 'sensitive_variables()', '.'],
+ refs=['sensitive.sensitive_variables'])
+
+
@with_intl_app(buildername='text', warning=warnfile, cleanenv=True)
def test_i18n_warn_for_number_of_references_inconsistency(app):
app.builddir.rmtree(True)