From d9d7fb8957db080ef4da9c278c18801cac4bbf29 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 23 Mar 2014 23:01:15 +0900 Subject: 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. --- tests/roots/test-intl/refs_python_domain.po | 25 +++++++++++++++++++++++++ tests/roots/test-intl/refs_python_domain.txt | 15 +++++++++++++++ tests/test_intl.py | 14 ++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 tests/roots/test-intl/refs_python_domain.po create mode 100644 tests/roots/test-intl/refs_python_domain.txt (limited to 'tests') 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 \n" +"Language-Team: LANGUAGE \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) -- cgit v1.2.1