doc8-inline-markup 2026.11.18.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- doc8_inline_markup/__init__.py +1 -0
- doc8_inline_markup/_doc8.py +36 -0
- doc8_inline_markup/_rst.py +99 -0
- doc8_inline_markup/py.typed +0 -0
- doc8_inline_markup-2026.11.18.3.dist-info/METADATA +59 -0
- doc8_inline_markup-2026.11.18.3.dist-info/RECORD +10 -0
- doc8_inline_markup-2026.11.18.3.dist-info/WHEEL +5 -0
- doc8_inline_markup-2026.11.18.3.dist-info/entry_points.txt +2 -0
- doc8_inline_markup-2026.11.18.3.dist-info/licenses/LICENSE +21 -0
- doc8_inline_markup-2026.11.18.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""A doc8 plugin for nested reStructuredText inline markup."""
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Expose the inline-markup check to doc8."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, override
|
|
6
|
+
|
|
7
|
+
from doc8.checks import ContentCheck
|
|
8
|
+
|
|
9
|
+
from doc8_inline_markup._rst import lint
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from collections.abc import Iterator
|
|
13
|
+
|
|
14
|
+
from doc8.parser import ParsedFile
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
_DIAGNOSTIC_CODE = "RST001"
|
|
18
|
+
_DIAGNOSTIC_MESSAGE = "Move inline code outside emphasis."
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class CheckInlineMarkup(ContentCheck):
|
|
22
|
+
"""Report inline literals inside reStructuredText emphasis."""
|
|
23
|
+
|
|
24
|
+
REPORTS = frozenset({_DIAGNOSTIC_CODE})
|
|
25
|
+
|
|
26
|
+
@override
|
|
27
|
+
def report_iter(
|
|
28
|
+
self,
|
|
29
|
+
parsed_file: ParsedFile,
|
|
30
|
+
) -> Iterator[tuple[int, str, str]]:
|
|
31
|
+
if parsed_file.extension.lower() == ".rst":
|
|
32
|
+
for line in lint(
|
|
33
|
+
text=parsed_file.contents,
|
|
34
|
+
source=parsed_file.filename,
|
|
35
|
+
):
|
|
36
|
+
yield line, _DIAGNOSTIC_CODE, _DIAGNOSTIC_MESSAGE
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""Lint inline code nested inside reStructuredText emphasis."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, override
|
|
6
|
+
|
|
7
|
+
from docutils import nodes
|
|
8
|
+
from docutils.frontend import get_default_settings
|
|
9
|
+
from docutils.parsers.rst import Parser
|
|
10
|
+
from docutils.parsers.rst.states import Inliner
|
|
11
|
+
from docutils.utils import escape2null, new_document
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from re import Match
|
|
15
|
+
from types import SimpleNamespace
|
|
16
|
+
|
|
17
|
+
type _InlineResult = tuple[
|
|
18
|
+
str, list[nodes.Node], str, list[nodes.system_message]
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class _LintInliner(Inliner):
|
|
23
|
+
"""Look for inline literals left as text by the emphasis handlers."""
|
|
24
|
+
|
|
25
|
+
# Docutils interpolates these patterns from the concrete class namespace.
|
|
26
|
+
simplename = Inliner.simplename
|
|
27
|
+
emailc = Inliner.emailc
|
|
28
|
+
non_whitespace_after = Inliner.non_whitespace_after
|
|
29
|
+
non_whitespace_escape_before = Inliner.non_whitespace_escape_before
|
|
30
|
+
uric = Inliner.uric
|
|
31
|
+
uri_end = Inliner.uri_end
|
|
32
|
+
non_unescaped_whitespace_escape_before = (
|
|
33
|
+
Inliner.non_unescaped_whitespace_escape_before
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def __init__(self) -> None:
|
|
37
|
+
super().__init__()
|
|
38
|
+
self.dispatch = {
|
|
39
|
+
**self.dispatch,
|
|
40
|
+
# Docutils dispatches to unbound methods with the inliner as
|
|
41
|
+
# the first argument. types-docutils models these as bound.
|
|
42
|
+
"*": _LintInliner._emphasis, # type: ignore[dict-item]
|
|
43
|
+
"**": _LintInliner._emphasis, # type: ignore[dict-item]
|
|
44
|
+
}
|
|
45
|
+
self.lines: list[int] = []
|
|
46
|
+
self._paragraph_lines = 0
|
|
47
|
+
|
|
48
|
+
@override
|
|
49
|
+
def parse(
|
|
50
|
+
self,
|
|
51
|
+
text: str,
|
|
52
|
+
lineno: int,
|
|
53
|
+
memo: SimpleNamespace,
|
|
54
|
+
parent: nodes.Element,
|
|
55
|
+
) -> tuple[list[nodes.Node], list[nodes.system_message]]:
|
|
56
|
+
self._paragraph_lines = text.count("\n")
|
|
57
|
+
return super().parse(text, lineno, memo, parent)
|
|
58
|
+
|
|
59
|
+
def _emphasis(self, match: Match[str], lineno: int) -> _InlineResult:
|
|
60
|
+
delimiter = match["start"]
|
|
61
|
+
handler = Inliner.strong if delimiter == "**" else Inliner.emphasis
|
|
62
|
+
before, inlines, remaining, messages = handler(self, match, lineno)
|
|
63
|
+
if inlines and isinstance(inlines[0], (nodes.strong, nodes.emphasis)):
|
|
64
|
+
raw = inlines[0].rawsource
|
|
65
|
+
body = raw[len(delimiter) : -len(delimiter)]
|
|
66
|
+
offset = self._literal_offset(text=body)
|
|
67
|
+
if offset is not None:
|
|
68
|
+
# Docutils passes the unconsumed suffix of the paragraph to
|
|
69
|
+
# each inline handler and keeps its original line number.
|
|
70
|
+
span_offset = self._paragraph_lines - match.string.count("\n")
|
|
71
|
+
self.lines.append(
|
|
72
|
+
lineno + span_offset + before.count("\n") + offset
|
|
73
|
+
)
|
|
74
|
+
return before, list(inlines), remaining, messages
|
|
75
|
+
|
|
76
|
+
def _literal_offset(self, *, text: str) -> int | None:
|
|
77
|
+
escaped = escape2null(text)
|
|
78
|
+
for match in self.patterns.initial.finditer(escaped):
|
|
79
|
+
if match["start"] != "\x60\x60" or self.quoted_start(match):
|
|
80
|
+
continue
|
|
81
|
+
end = self.patterns.literal.search(escaped[match.end("start") :])
|
|
82
|
+
if end and end.start(1):
|
|
83
|
+
return escaped.count("\n", 0, match.start("start"))
|
|
84
|
+
return None
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def lint(*, text: str, source: str) -> list[int]:
|
|
88
|
+
"""Return the line of the first nested inline literal per emphasis span."""
|
|
89
|
+
inliner = _LintInliner()
|
|
90
|
+
parser = Parser(inliner=inliner)
|
|
91
|
+
settings = get_default_settings(Parser)
|
|
92
|
+
settings.file_insertion_enabled = False
|
|
93
|
+
settings.raw_enabled = False
|
|
94
|
+
settings.report_level = 5
|
|
95
|
+
settings.halt_level = 6
|
|
96
|
+
settings.syntax_highlight = "none"
|
|
97
|
+
document = new_document(source, settings=settings)
|
|
98
|
+
parser.parse(text, document)
|
|
99
|
+
return sorted(inliner.lines)
|
|
File without changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: doc8-inline-markup
|
|
3
|
+
Version: 2026.11.18.3
|
|
4
|
+
Summary: A doc8 plugin for inline literals inside reStructuredText emphasis.
|
|
5
|
+
Author-email: Adam Dangoor <adamdangoor@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Source, https://github.com/adamtheturtle/doc8-inline-markup
|
|
8
|
+
Keywords: doc8,restructuredtext
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
12
|
+
Classifier: Operating System :: POSIX
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
18
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Description-Content-Type: text/x-rst
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: doc8<3,>=2
|
|
23
|
+
Requires-Dist: docutils<0.24,>=0.21
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
doc8 Inline Markup
|
|
27
|
+
==================
|
|
28
|
+
|
|
29
|
+
A doc8 plugin that detects inline literals inside bold or italic
|
|
30
|
+
reStructuredText. Docutils treats the inner backticks as text, which
|
|
31
|
+
makes the code render with visible backticks. The check reports RST001.
|
|
32
|
+
|
|
33
|
+
For example, change this note::
|
|
34
|
+
|
|
35
|
+
.. note:: **``event_id`` deduplication**
|
|
36
|
+
|
|
37
|
+
to::
|
|
38
|
+
|
|
39
|
+
.. note:: ``event_id`` deduplication
|
|
40
|
+
|
|
41
|
+
Installation
|
|
42
|
+
------------
|
|
43
|
+
|
|
44
|
+
Install the plugin in the same environment as doc8. For a uv project,
|
|
45
|
+
add it as a development dependency::
|
|
46
|
+
|
|
47
|
+
uv add --dev doc8-inline-markup
|
|
48
|
+
|
|
49
|
+
Run doc8 as usual::
|
|
50
|
+
|
|
51
|
+
uv run doc8 docs/guide.rst
|
|
52
|
+
|
|
53
|
+
doc8 discovers the plugin automatically. It checks .rst files, skips code
|
|
54
|
+
blocks and comments, and supports doc8's standard ignore settings. Run doc8
|
|
55
|
+
on included files directly. Content in extension directives that Docutils
|
|
56
|
+
cannot parse is outside the check's scope.
|
|
57
|
+
|
|
58
|
+
If you used rst-inline-markup-lint, replace that dependency with
|
|
59
|
+
doc8-inline-markup and remove any standalone hook entry for the old package.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
doc8_inline_markup/__init__.py,sha256=qxQ98TEvoTUDHPQznwbaZJXK0WZ5loHzTN21kP3v0_g,63
|
|
2
|
+
doc8_inline_markup/_doc8.py,sha256=xsHaj_oa8zs9X14SALRWlB2NT4jaTWBeT-ToqPHdhds,923
|
|
3
|
+
doc8_inline_markup/_rst.py,sha256=ynpv0H9WDmNItt4Tjoo2eUqZ5o2K_D0HEzoFQ0uuceM,3796
|
|
4
|
+
doc8_inline_markup/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
doc8_inline_markup-2026.11.18.3.dist-info/licenses/LICENSE,sha256=cnfgEzv8YMudbgPysNfgAdqeOo4zf0y2C3Ctw4RgEE4,1069
|
|
6
|
+
doc8_inline_markup-2026.11.18.3.dist-info/METADATA,sha256=8F05a-qAqPHL5oUm0UFXtkFTendbZeMnIFZ-lSwLniM,1995
|
|
7
|
+
doc8_inline_markup-2026.11.18.3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
8
|
+
doc8_inline_markup-2026.11.18.3.dist-info/entry_points.txt,sha256=5GuqkSa-Pa7Ku0b6n_veQk26rl7gWc1hZFsatiDuvFk,87
|
|
9
|
+
doc8_inline_markup-2026.11.18.3.dist-info/top_level.txt,sha256=KEp5VpxD2_7jMFHiThUW_qox7SlfEIYrYMIJo_DfrUU,19
|
|
10
|
+
doc8_inline_markup-2026.11.18.3.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Adam Dangoor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
doc8_inline_markup
|