|
From: <mi...@us...> - 2026-06-18 13:27:42
|
Revision: 10364
http://sourceforge.net/p/docutils/code/10364
Author: milde
Date: 2026-06-18 13:27:39 +0000 (Thu, 18 Jun 2026)
Log Message:
-----------
Inform when a directive has content above and below options.
Generate an INFO message if a directive that does not take arguments
has content above and below directive options.
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/RELEASE-NOTES.rst
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/test/test_transforms/test_messages.py
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2026-06-18 07:56:49 UTC (rev 10363)
+++ trunk/docutils/HISTORY.rst 2026-06-18 13:27:39 UTC (rev 10364)
@@ -77,6 +77,8 @@
- Do not add "name" attribute to `<reference>` elements
nor set the internal attribute `indirect_reference_name`.
+ - Report INFO message, if a directive that does not take
+ arguments has content above and below directive options.
* docutils/readers/standalone.py
Modified: trunk/docutils/RELEASE-NOTES.rst
===================================================================
--- trunk/docutils/RELEASE-NOTES.rst 2026-06-18 07:56:49 UTC (rev 10363)
+++ trunk/docutils/RELEASE-NOTES.rst 2026-06-18 13:27:39 UTC (rev 10364)
@@ -79,10 +79,6 @@
Parsers
-------
-* The "rst" parser will issue an INFO, if a directive that does not take
- arguments has content above and below directive options in
- Docutils 0.24 or later.
-
* The "rst" parser will warn if a `"figure"`_ directive is missing both
caption and legend in Docutils 1.0.
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2026-06-18 07:56:49 UTC (rev 10363)
+++ trunk/docutils/docutils/parsers/rst/states.py 2026-06-18 13:27:39 UTC (rev 10364)
@@ -2326,6 +2326,11 @@
options = {}
if arg_block and not (directive.required_arguments
or directive.optional_arguments):
+ if options and content:
+ self.reporter.info(
+ 'Directive content before and after options.',
+ nodes.literal_block('', '\n'.join(indented)),
+ line=content_offset)
content = arg_block + indented[i:]
content_offset = line_offset
arg_block = []
Modified: trunk/docutils/test/test_transforms/test_messages.py
===================================================================
--- trunk/docutils/test/test_transforms/test_messages.py 2026-06-18 07:56:49 UTC (rev 10363)
+++ trunk/docutils/test/test_transforms/test_messages.py 2026-06-18 13:27:39 UTC (rev 10364)
@@ -25,10 +25,13 @@
class TransformTestCase(unittest.TestCase):
+ maxDiff = None
+
def test_transforms(self):
parser = Parser()
settings = get_default_settings(Parser)
settings.warning_stream = ''
+ settings.report_level = 1
for name, (transforms, cases) in totest.items():
for casenum, (case_input, case_expected) in enumerate(cases):
with self.subTest(id=f'totest[{name!r}][{casenum}]'):
@@ -79,6 +82,31 @@
<paragraph>
Undefined substitution referenced: "unknown substitution".
"""],
+["""\
+.. note:: Directive content above
+ :class: custom
+
+ and below directive options can be confusing.
+""",
+"""\
+<document source="test data">
+ <note classes="custom">
+ <paragraph>
+ Directive content above
+ <paragraph>
+ and below directive options can be confusing.
+ <section classes="system-messages">
+ <title>
+ Docutils System Messages
+ <system_message level="1" line="3" source="test data" type="INFO">
+ <paragraph>
+ Directive content before and after options.
+ <literal_block xml:space="preserve">
+ Directive content above
+ :class: custom
+ \n\
+ and below directive options can be confusing.
+"""],
])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|