Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/doc8/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ def any_types(nodes, types):
title_types = (
docutils_nodes.title,
docutils_nodes.subtitle,
docutils_nodes.section,
)
for i, line in enumerate(lines):
if len(line) > self._max_line_length:
Expand Down
30 changes: 30 additions & 0 deletions src/doc8/tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,36 @@ def test_unsplittable_length(self):
errors = list(check.report_iter(parsed_file))
self.assertEqual(expected_errors, len(errors))

def test_allow_long_titles_only_skips_title_lines(self):
content = b"""\
.. title:: clang-tidy - misc-anonymous-namespace-in-header

misc-anonymous-namespace-in-header
==================================

Finds anonymous namespaces in headers.

Anonymous namespaces in headers can lead to One Definition Rule (ODR) violations
because each translation unit including the header will get its own unique version
of the symbols. This increases binary size and can cause confusing link-time errors.
"""
conf = {"max_line_length": 40, "allow_long_titles": True}
with tempfile.NamedTemporaryFile(suffix=".rst") as fh:
fh.write(content)
fh.flush()

parsed_file = parser.ParsedFile(fh.name)
check = checks.CheckMaxLineLength(conf)

self.assertEqual(
[
(8, "D001", "Line too long"),
(9, "D001", "Line too long"),
(10, "D001", "Line too long"),
],
list(check.report_iter(parsed_file)),
)

def test_definition_term_length(self):
conf = {"max_line_length": 79, "allow_long_titles": True}
with tempfile.NamedTemporaryFile(suffix=".rst") as fh:
Expand Down
Loading