Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanas committed Feb 15, 2022
1 parent 4b3bb23 commit b595ca1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions sphinx/transforms/i18n.py
Expand Up @@ -9,7 +9,7 @@
"""

from os import path
from re import match, MULTILINE
from re import match, DOTALL
from textwrap import indent
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, TypeVar

Expand Down Expand Up @@ -84,7 +84,7 @@ def publish_msgstr(app: "Sphinx", source: str, source_path: str, source_line: in


def parse_noqa(source: str) -> Tuple[str, bool]:
m = match(r"(.*)(?<!\\)#\s*noqa\s*$", source, MULTILINE)
m = match(r"(.*)(?<!\\)#\s*noqa\s*$", source, DOTALL)
if m:
return m.group(1), True
else:
Expand Down
4 changes: 2 additions & 2 deletions tests/roots/test-intl/xx/LC_MESSAGES/literalblock.po
Expand Up @@ -80,8 +80,8 @@ msgstr "LITERAL-BLOCK\n"
msgid "test_code_for_noqa()\n"
"continued()"
msgstr ""
"# Trailing noqa should not get stripped\n"
"# from this block. #noqa"
"# TRAILING noqa SHOULD NOT GET STRIPPED\n"
"# FROM THIS BLOCK. #noqa"

msgid "doctest blocks"
msgstr "DOCTEST-BLOCKS"
Expand Down
15 changes: 6 additions & 9 deletions tests/roots/test-intl/xx/LC_MESSAGES/noqa.po
Expand Up @@ -19,7 +19,7 @@ msgstr ""

#: ../tests/roots/test-intl/noqa.txt:2
msgid "First section"
msgstr ""
msgstr "FIRST SECTION"

#: ../tests/roots/test-intl/noqa.txt:4
msgid "Some text with a reference, :ref:`next-section`."
Expand All @@ -28,20 +28,17 @@ msgstr "TRANSLATED TEXT WITHOUT REFERENCE. #noqa"
#: ../tests/roots/test-intl/noqa.txt:6
msgid "Another reference: :ref:`next-section`."
msgstr ""
"TEST WHITESPACE INSENSITIVITY.\n"
"\n"
"\n"
" # \n"
"\n"
"noqa"
"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"
msgstr "``#noqa`` IS ESCAPED AT THE END OF THIS STRING. \\#noqa"

#: ../tests/roots/test-intl/noqa.txt:13
msgid "Next section"
msgstr ""
msgstr "NEXT SECTION WITH PARAGRAPH TO TEST BARE noqa"

# This edge case should not fail.
#: ../tests/roots/test-intl/noqa.txt:15
Expand Down
13 changes: 7 additions & 6 deletions tests/test_intl.py
Expand Up @@ -198,20 +198,21 @@ def test_text_inconsistency_warnings(app, warning):
def test_noqa(app, warning):
app.build()
result = (app.outdir / 'noqa.txt').read_text()
expect = r"""First section
expect = r"""FIRST SECTION
*************
TRANSLATED TEXT WITHOUT REFERENCE.
TEST WHITESPACE INSENSITIVITY.
TEST noqa WHITESPACE INSENSITIVITY.
"#noqa" is escaped at the end of this string. #noqa
"#noqa" IS ESCAPED AT THE END OF THIS STRING. #noqa
Next section
************
NEXT SECTION WITH PARAGRAPH TO TEST BARE noqa
*********************************************
Some text, again referring to the section: Next section.
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)
Expand Down

0 comments on commit b595ca1

Please sign in to comment.