Merge branch '4.x'

This commit is contained in:
Takeshi KOMIYA
2022-03-28 01:00:37 +09:00
12 changed files with 203 additions and 58 deletions

View File

@@ -49,6 +49,14 @@ code blocks
literal-block
in list
.. highlight:: none
::
test_code_for_noqa()
continued()
doctest blocks
==============

View File

@@ -0,0 +1,16 @@
First section
=============
Some text with a reference, :ref:`next-section`.
Another reference: :ref:`next-section`.
This should allow to test escaping ``#noqa``.
.. _next-section:
Next section
============
Some text, again referring to the section: :ref:`next-section`.

View File

@@ -77,6 +77,12 @@ msgid "literal-block\n"
msgstr "LITERAL-BLOCK\n"
"IN LIST"
msgid "test_code_for_noqa()\n"
"continued()"
msgstr ""
"# TRAILING noqa SHOULD NOT GET STRIPPED\n"
"# FROM THIS BLOCK. #noqa"
msgid "doctest blocks"
msgstr "DOCTEST-BLOCKS"

View File

@@ -0,0 +1,46 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C)
# This file is distributed under the same license as the Sphinx intl <Tests> package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-01-16 15:23+0100\n"
"PO-Revision-Date: 2022-01-16 15:23+0100\n"
"Last-Translator: Jean Abou Samra <jean@abou-samra.fr>\n"
"Language-Team: \n"
"Language: xx\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0\n"
#: ../tests/roots/test-intl/noqa.txt:2
msgid "First section"
msgstr "FIRST SECTION"
#: ../tests/roots/test-intl/noqa.txt:4
msgid "Some text with a reference, :ref:`next-section`."
msgstr "TRANSLATED TEXT WITHOUT REFERENCE. #noqa"
#: ../tests/roots/test-intl/noqa.txt:6
msgid "Another reference: :ref:`next-section`."
msgstr ""
"TEST noqa WHITESPACE INSENSITIVITY.\n"
"# \n"
" noqa"
#: ../tests/roots/test-intl/noqa.txt:8
msgid "This should allow to test escaping ``#noqa``."
msgstr "``#noqa`` IS ESCAPED AT THE END OF THIS STRING. \\#noqa"
#: ../tests/roots/test-intl/noqa.txt:13
msgid "Next section"
msgstr "NEXT SECTION WITH PARAGRAPH TO TEST BARE noqa"
# This edge case should not fail.
#: ../tests/roots/test-intl/noqa.txt:15
msgid "Some text, again referring to the section: :ref:`next-section`."
msgstr "#noqa"

View File

@@ -445,12 +445,3 @@ def test_labeled_rubric(app):
domain = app.env.get_domain("std")
assert 'label' in domain.labels
assert domain.labels['label'] == ('index', 'label', 'blah blah blah')
def test_inline_target(app):
text = "blah _`inline target` blah\n"
restructuredtext.parse(app, text)
domain = app.env.get_domain("std")
assert 'inline target' in domain.labels
assert domain.labels['inline target'] == ('index', 'inline-target', 'inline target')

View File

@@ -186,6 +186,32 @@ def test_text_inconsistency_warnings(app, warning):
assert_re_search(expected_citation_warning_expr, warnings)
@sphinx_intl
@pytest.mark.sphinx('text')
@pytest.mark.test_params(shared_result='test_intl_basic')
def test_noqa(app, warning):
app.build()
result = (app.outdir / 'noqa.txt').read_text()
expect = r"""FIRST SECTION
*************
TRANSLATED TEXT WITHOUT REFERENCE.
TEST noqa WHITESPACE INSENSITIVITY.
"#noqa" IS ESCAPED AT THE END OF THIS STRING. #noqa
NEXT SECTION WITH PARAGRAPH TO TEST BARE noqa
*********************************************
Some text, again referring to the section: NEXT SECTION WITH PARAGRAPH
TO TEST BARE noqa.
"""
assert result == expect
assert "next-section" not in getwarning(warning)
@sphinx_intl
@pytest.mark.sphinx('text')
@pytest.mark.test_params(shared_result='test_intl_basic')
@@ -1180,6 +1206,9 @@ def test_additional_targets_should_be_translated(app):
"""<span class="c1"># SYS IMPORTING</span>""")
assert_count(expected_expr, result, 1)
# '#noqa' should remain in literal blocks.
assert_count("#noqa", result, 1)
# [raw.txt]
result = (app.outdir / 'raw.html').read_text()