|
From: <mi...@us...> - 2022-03-05 23:27:53
|
Revision: 9029
http://sourceforge.net/p/docutils/code/9029
Author: milde
Date: 2022-03-05 23:27:50 +0000 (Sat, 05 Mar 2022)
Log Message:
-----------
Simplify code as dicts have fixed order since 3.6
We no longer need to sort a dictionary from `**kwargs`
in order to have a fixed order for stable tests.
Modified Paths:
--------------
trunk/docutils/docutils/utils/math/latex2mathml.py
trunk/docutils/test/functional/expected/math_output_mathml.html
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2022-03-05 23:27:39 UTC (rev 9028)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2022-03-05 23:27:50 UTC (rev 9029)
@@ -104,8 +104,8 @@
'Uparrow': '\u21d1', # ⇑ UPWARDS DOUBLE ARROW
'Downarrow': '\u21d3', # ⇓ DOWNWARDS DOUBLE ARROW
'Updownarrow': '\u21d5', # ⇕ UP DOWN DOUBLE ARROW
- 'lmoustache': '\u23b0', # ⎰ UPPER LEFT OR LOWER RIGHT CURLY BRACKET SECTION
- 'rmoustache': '\u23b1', # ⎱ UPPER RIGHT OR LOWER LEFT CURLY BRACKET SECTION
+ 'lmoustache': '\u23b0', # ⎰ … CURLY BRACKET SECTION
+ 'rmoustache': '\u23b1', # ⎱ … LEFT CURLY BRACKET SECTION
'arrowvert': '\u23d0', # ⏐ VERTICAL LINE EXTENSION
'bracevert': '\u23aa', # ⎪ CURLY BRACKET EXTENSION
'lvert': '|', # left |
@@ -223,15 +223,15 @@
# limits etc. -> <mover> or <munder>
over = {# TeX: (char, offset-correction/em)
- 'overbrace': ('\u23DE', -0.2), # DejaVu Math -0.6
+ 'overbrace': ('\u23DE', -0.2), # DejaVu Math -0.6
'overleftarrow': ('\u2190', -0.2),
'overleftrightarrow': ('\u2194', -0.2),
- 'overline': ('_', -0.2), # \u2012' FIGURE DASH does not stretch
+ 'overline': ('_', -0.2), # \u2012 does not stretch
'overrightarrow': ('\u2192', -0.2),
'widehat': ('^', -0.5),
'widetilde': ('~', -0.3),
}
-under = {'underbrace': ('\u23DF', 0.1), # DejaVu Math -0.7
+under = {'underbrace': ('\u23DF', 0.1), # DejaVu Math -0.7
'underleftarrow': ('\u2190', -0.2),
'underleftrightarrow': ('\u2194', -0.2),
'underline': ('_', -0.8),
@@ -338,9 +338,7 @@
self.extend(children)
self.attributes = {}
- # sort attributes for predictable functional tests
- # as self.attributes.update(attributes) does not keep order in Python < 3.6
- for key in sorted(attributes.keys()):
+ for key in attributes.keys():
# Use .lower() to allow argument `CLASS` for attribute `class`
# (Python keyword). MathML uses only lowercase attributes.
self.attributes[key.lower()] = attributes[key]
Modified: trunk/docutils/test/functional/expected/math_output_mathml.html
===================================================================
--- trunk/docutils/test/functional/expected/math_output_mathml.html 2022-03-05 23:27:39 UTC (rev 9028)
+++ trunk/docutils/test/functional/expected/math_output_mathml.html 2022-03-05 23:27:50 UTC (rev 9029)
@@ -392,7 +392,7 @@
<span class="docutils literal">align</span> environment:</p>
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
- <mtable class="align" columnalign="right left" columnspacing="0" displaystyle="true">
+ <mtable class="align" displaystyle="true" columnalign="right left" columnspacing="0">
<mtr>
<mtd>
<msub>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-03-05 23:28:35
|
Revision: 9030
http://sourceforge.net/p/docutils/code/9030
Author: milde
Date: 2022-03-05 23:28:32 +0000 (Sat, 05 Mar 2022)
Log Message:
-----------
Avoid too long lines.
flake8 rule E501: line too long (N > 79 characters)
Modified Paths:
--------------
trunk/docutils/docutils/core.py
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/languages/__init__.py
trunk/docutils/docutils/languages/af.py
trunk/docutils/docutils/languages/ar.py
trunk/docutils/docutils/languages/ca.py
trunk/docutils/docutils/languages/cs.py
trunk/docutils/docutils/languages/da.py
trunk/docutils/docutils/languages/de.py
trunk/docutils/docutils/languages/en.py
trunk/docutils/docutils/languages/eo.py
trunk/docutils/docutils/languages/es.py
trunk/docutils/docutils/languages/fa.py
trunk/docutils/docutils/languages/fi.py
trunk/docutils/docutils/languages/fr.py
trunk/docutils/docutils/languages/gl.py
trunk/docutils/docutils/languages/he.py
trunk/docutils/docutils/languages/it.py
trunk/docutils/docutils/languages/ja.py
trunk/docutils/docutils/languages/ko.py
trunk/docutils/docutils/languages/lt.py
trunk/docutils/docutils/languages/lv.py
trunk/docutils/docutils/languages/nl.py
trunk/docutils/docutils/languages/pl.py
trunk/docutils/docutils/languages/pt_br.py
trunk/docutils/docutils/languages/ru.py
trunk/docutils/docutils/languages/sk.py
trunk/docutils/docutils/languages/sv.py
trunk/docutils/docutils/languages/zh_cn.py
trunk/docutils/docutils/languages/zh_tw.py
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/rst/__init__.py
trunk/docutils/docutils/parsers/rst/directives/body.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/docutils/parsers/rst/languages/af.py
trunk/docutils/docutils/parsers/rst/languages/ar.py
trunk/docutils/docutils/parsers/rst/languages/ca.py
trunk/docutils/docutils/parsers/rst/languages/cs.py
trunk/docutils/docutils/parsers/rst/languages/da.py
trunk/docutils/docutils/parsers/rst/languages/de.py
trunk/docutils/docutils/parsers/rst/languages/en.py
trunk/docutils/docutils/parsers/rst/languages/eo.py
trunk/docutils/docutils/parsers/rst/languages/es.py
trunk/docutils/docutils/parsers/rst/languages/fa.py
trunk/docutils/docutils/parsers/rst/languages/fi.py
trunk/docutils/docutils/parsers/rst/languages/fr.py
trunk/docutils/docutils/parsers/rst/languages/gl.py
trunk/docutils/docutils/parsers/rst/languages/he.py
trunk/docutils/docutils/parsers/rst/languages/ja.py
trunk/docutils/docutils/parsers/rst/languages/ko.py
trunk/docutils/docutils/parsers/rst/languages/lt.py
trunk/docutils/docutils/parsers/rst/languages/lv.py
trunk/docutils/docutils/parsers/rst/languages/nl.py
trunk/docutils/docutils/parsers/rst/languages/pl.py
trunk/docutils/docutils/parsers/rst/languages/pt_br.py
trunk/docutils/docutils/parsers/rst/languages/ru.py
trunk/docutils/docutils/parsers/rst/languages/sk.py
trunk/docutils/docutils/parsers/rst/languages/sv.py
trunk/docutils/docutils/parsers/rst/languages/zh_cn.py
trunk/docutils/docutils/parsers/rst/languages/zh_tw.py
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/transforms/__init__.py
trunk/docutils/docutils/transforms/frontmatter.py
trunk/docutils/docutils/transforms/references.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/error_reporting.py
trunk/docutils/docutils/utils/smartquotes.py
trunk/docutils/docutils/utils/urischemes.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/docutils_xml.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/docutils/writers/s5_html/__init__.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/alltests.py
trunk/docutils/test/local_dummy_lang.py
trunk/docutils/test/package_unittest.py
trunk/docutils/test/test_dependencies.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_nodes.py
trunk/docutils/test/test_settings.py
trunk/docutils/test/test_utils.py
trunk/docutils/tools/buildhtml.py
trunk/docutils/tools/dev/create_unimap.py
trunk/docutils/tools/dev/generate_punctuation_chars.py
trunk/docutils/tools/rst2man.py
trunk/docutils/tox.ini
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/core.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -9,7 +9,8 @@
custom component objects first, and pass *them* to
``publish_*``/`Publisher`. See `The Docutils Publisher`_.
-.. _The Docutils Publisher: https://docutils.sourceforge.io/docs/api/publisher.html
+.. _The Docutils Publisher:
+ https://docutils.sourceforge.io/docs/api/publisher.html
"""
__docformat__ = 'reStructuredText'
@@ -313,10 +314,11 @@
default_usage = '%prog [options] [<source> [<destination>]]'
-default_description = ('Reads from <source> (default is stdin) and writes to '
- '<destination> (default is stdout). See '
- '<https://docutils.sourceforge.io/docs/user/config.html> for '
- 'the full reference.')
+default_description = (
+ 'Reads from <source> (default is stdin) and writes to <destination> '
+ '(default is stdout). '
+ 'See https://docutils.sourceforge.io/docs/user/config.html '
+ ' for the full reference.')
def publish_cmdline(reader=None, reader_name='standalone',
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/frontend.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -511,7 +511,8 @@
'default': 5, 'metavar': '<level>',
'validator': validate_threshold}),
('Enable debug-level system messages and diagnostics.',
- ['--debug'], {'action': 'store_true', 'validator': validate_boolean}),
+ ['--debug'], {'action': 'store_true',
+ 'validator': validate_boolean}),
('Disable debug output. (default)',
['--no-debug'], {'action': 'store_false', 'dest': 'debug'}),
('Send the output of system messages to <file>.',
@@ -587,7 +588,7 @@
'_source': None,
'_destination': None,
'_config_files': None}
- """Defaults for settings that don't have command-line option equivalents."""
+ """Defaults for settings without command-line option equivalents."""
relative_path_settings = ('warning_stream',)
@@ -633,8 +634,9 @@
self.defaults.update(config_settings.__dict__)
def populate_from_components(self, components):
- """
- For each component, first populate from the `SettingsSpec.settings_spec`
+ """Collect settings specification from components.
+
+ For each component, populate from the `SettingsSpec.settings_spec`
structure, then from the `SettingsSpec.settings_defaults` dictionary.
After all components have been processed, check for and populate from
each component's `SettingsSpec.settings_default_overrides` dictionary.
@@ -771,12 +773,12 @@
`handle_old_config`, to convert settings from the old [options] section.
"""
- old_warning = """
-The "[option]" section is deprecated. Support for old-format configuration
-files will be removed in Docutils 0.21 or later. Please revise your
-configuration files. See <https://docutils.sourceforge.io/docs/user/config.html>,
-section "Old-Format Configuration Files".
-"""
+ old_warning = (
+ 'The "[option]" section is deprecated.\n'
+ 'Support for old-format configuration files will be removed in '
+ 'Docutils 0.21 or later. Please revise your configuration files. '
+ 'See <https://docutils.sourceforge.io/docs/user/config.html>, '
+ 'section "Old-Format Configuration Files".')
not_utf8_error = """\
Unable to read configuration file "%s": content not encoded as UTF-8.
Modified: trunk/docutils/docutils/languages/__init__.py
===================================================================
--- trunk/docutils/docutils/languages/__init__.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/__init__.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -74,7 +74,8 @@
if self.fallback:
module = self.import_from_packages(self.fallback)
if reporter and (language_code != 'en'):
- reporter.info('Using %s for language "%s".'%(module, language_code))
+ reporter.info('Using %s for language "%s".'
+ % (module, language_code))
self.cache[language_code] = module
return module
Modified: trunk/docutils/docutils/languages/af.py
===================================================================
--- trunk/docutils/docutils/languages/af.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/af.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Afrikaans-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/ar.py
===================================================================
--- trunk/docutils/docutils/languages/ar.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/ar.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Arabic-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/ca.py
===================================================================
--- trunk/docutils/docutils/languages/ca.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/ca.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Catalan-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/cs.py
===================================================================
--- trunk/docutils/docutils/languages/cs.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/cs.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Czech-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/da.py
===================================================================
--- trunk/docutils/docutils/languages/da.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/da.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Danish-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/de.py
===================================================================
--- trunk/docutils/docutils/languages/de.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/de.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
German language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/en.py
===================================================================
--- trunk/docutils/docutils/languages/en.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/en.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
English-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/eo.py
===================================================================
--- trunk/docutils/docutils/languages/eo.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/eo.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Esperanto-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/es.py
===================================================================
--- trunk/docutils/docutils/languages/es.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/es.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Spanish-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/fa.py
===================================================================
--- trunk/docutils/docutils/languages/fa.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/fa.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Persian-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/fi.py
===================================================================
--- trunk/docutils/docutils/languages/fi.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/fi.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Finnish-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/fr.py
===================================================================
--- trunk/docutils/docutils/languages/fr.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/fr.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
French-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/gl.py
===================================================================
--- trunk/docutils/docutils/languages/gl.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/gl.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -5,9 +5,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Galician-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/he.py
===================================================================
--- trunk/docutils/docutils/languages/he.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/he.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Hebrew-language mappings for language-dependent features of Docutils.
@@ -24,7 +24,8 @@
'revision': '\u05de\u05d4\u05d3\u05d5\u05e8\u05d4',
'status': '\u05e1\u05d8\u05d8\u05d5\u05e1',
'date': '\u05ea\u05d0\u05e8\u05d9\u05da',
- 'copyright': '\u05d6\u05db\u05d5\u05d9\u05d5\u05ea \u05e9\u05de\u05d5\u05e8\u05d5\u05ea',
+ 'copyright': ('\u05d6\u05db\u05d5\u05d9\u05d5\u05ea '
+ '\u05e9\u05de\u05d5\u05e8\u05d5\u05ea'),
'dedication': '\u05d4\u05e7\u05d3\u05e9\u05d4',
'abstract': '\u05ea\u05e7\u05e6\u05d9\u05e8',
'attention': '\u05ea\u05e9\u05d5\u05de\u05ea \u05dc\u05d1',
@@ -50,7 +51,7 @@
'\u05de\u05d4\u05d3\u05d5\u05e8\u05d4': 'revision',
'\u05e1\u05d8\u05d8\u05d5\u05e1': 'status',
'\u05ea\u05d0\u05e8\u05d9\u05da': 'date',
- '\u05d6\u05db\u05d5\u05d9\u05d5\u05ea \u05e9\u05de\u05d5\u05e8\u05d5\u05ea': 'copyright',
+ '\u05d6\u05db\u05d5\u05d9\u05d5\u05ea \u05e9\u05de\u05d5\u05e8\u05d5\u05ea': 'copyright', # noqa:E501
'\u05d4\u05e7\u05d3\u05e9\u05d4': 'dedication',
'\u05ea\u05e7\u05e6\u05d9\u05e8': 'abstract'}
"""Hebrew to canonical name mapping for bibliographic fields."""
Modified: trunk/docutils/docutils/languages/it.py
===================================================================
--- trunk/docutils/docutils/languages/it.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/it.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Italian-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/ja.py
===================================================================
--- trunk/docutils/docutils/languages/ja.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/ja.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Japanese-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/ko.py
===================================================================
--- trunk/docutils/docutils/languages/ko.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/ko.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Korean-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/lt.py
===================================================================
--- trunk/docutils/docutils/languages/lt.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/lt.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Lithuanian language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/lv.py
===================================================================
--- trunk/docutils/docutils/languages/lv.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/lv.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -2,9 +2,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Latvian-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/nl.py
===================================================================
--- trunk/docutils/docutils/languages/nl.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/nl.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Dutch-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/pl.py
===================================================================
--- trunk/docutils/docutils/languages/pl.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/pl.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,9 +3,9 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
Polish-language mappings for language-dependent features of Docutils.
Modified: trunk/docutils/docutils/languages/pt_br.py
===================================================================
--- trunk/docutils/docutils/languages/pt_br.py 2022-03-05 23:27:50 UTC (rev 9029)
+++ trunk/docutils/docutils/languages/pt_br.py 2022-03-05 23:28:32 UTC (rev 9030)
@@ -3,12 +3,12 @@
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
-# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be
-# translated for each language: one in docutils/languages, the other in
-# docutils/parsers/rst/languages.
+# read <https://docutils.sourceforge.io/docs/howto/i18n.html>.
+# Two files must be translated for each language: one in docutils/languages,
+# the other in docutils/parsers/rst/languages.
"""
-Brazilian Portuguese-language mappings for language-dependent features of Docutils.
+Brazilian Portuguese-language mappings for lan...
[truncated message content] |
|
From: <mi...@us...> - 2022-03-05 23:29:09
|
Revision: 9032
http://sourceforge.net/p/docutils/code/9032
Author: milde
Date: 2022-03-05 23:29:06 +0000 (Sat, 05 Mar 2022)
Log Message:
-----------
Avoid multiple statements on one line. Fix redundant backslash
Exceptions for sets of empty class definitions
and other cases where it improves comprehension.
flake8 rules
E502: the backslash is redundant between brackets
E701: multiple statements on one line (colon)
E704: multiple statements on one line (def)
Modified Paths:
--------------
trunk/docutils/docutils/parsers/rst/directives/images.py
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/transforms/__init__.py
trunk/docutils/docutils/transforms/references.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/smartquotes.py
trunk/docutils/docutils/writers/docutils_xml.py
trunk/docutils/test/test_settings.py
trunk/docutils/test/test_statemachine.py
trunk/docutils/tox.ini
Modified: trunk/docutils/docutils/parsers/rst/directives/images.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/images.py 2022-03-05 23:28:42 UTC (rev 9031)
+++ trunk/docutils/docutils/parsers/rst/directives/images.py 2022-03-05 23:29:06 UTC (rev 9032)
@@ -15,7 +15,7 @@
except ImportError:
try: # sometimes PIL modules are put in PYTHONPATH's root
import Image
- class PIL: pass # dummy wrapper
+ class PIL: pass # noqa:E701 dummy wrapper
PIL.Image = Image
except ImportError:
PIL = None
Modified: trunk/docutils/docutils/parsers/rst/directives/tables.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/tables.py 2022-03-05 23:28:42 UTC (rev 9031)
+++ trunk/docutils/docutils/parsers/rst/directives/tables.py 2022-03-05 23:29:06 UTC (rev 9032)
@@ -349,7 +349,7 @@
raise SystemMessagePropagation(severe)
csv_file = io.StringInput(
source=csv_text, source_path=source, encoding=encoding,
- error_handler=(self.state.document.settings.\
+ error_handler=(self.state.document.settings.
input_encoding_error_handler))
csv_data = csv_file.read().splitlines()
else:
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2022-03-05 23:28:42 UTC (rev 9031)
+++ trunk/docutils/docutils/statemachine.py 2022-03-05 23:29:06 UTC (rev 9032)
@@ -1101,15 +1101,14 @@
return str(self.data)
def __repr__(self):
- return '%s(%s, items=%s)' % (self.__class__.__name__,
- self.data, self.items)
+ return f'{self.__class__.__name__}({self.data}, items={self.items})'
- def __lt__(self, other): return self.data < self.__cast(other)
- def __le__(self, other): return self.data <= self.__cast(other)
- def __eq__(self, other): return self.data == self.__cast(other)
- def __ne__(self, other): return self.data != self.__cast(other)
- def __gt__(self, other): return self.data > self.__cast(other)
- def __ge__(self, other): return self.data >= self.__cast(other)
+ def __lt__(self, other): return self.data < self.__cast(other) # noqa
+ def __le__(self, other): return self.data <= self.__cast(other) # noqa
+ def __eq__(self, other): return self.data == self.__cast(other) # noqa
+ def __ne__(self, other): return self.data != self.__cast(other) # noqa
+ def __gt__(self, other): return self.data > self.__cast(other) # noqa
+ def __ge__(self, other): return self.data >= self.__cast(other) # noqa
def __cast(self, other):
if isinstance(other, ViewList):
@@ -1117,9 +1116,12 @@
else:
return other
- def __contains__(self, item): return item in self.data
- def __len__(self): return len(self.data)
+ def __contains__(self, item):
+ return item in self.data
+ def __len__(self):
+ return len(self.data)
+
# The __getitem__()/__setitem__() methods check whether the index
# is a slice first, since indexing a native list with a slice object
# just works.
@@ -1268,9 +1270,12 @@
index = self.index(item)
del self[index]
- def count(self, item): return self.data.count(item)
- def index(self, item): return self.data.index(item)
+ def count(self, item):
+ return self.data.count(item)
+ def index(self, item):
+ return self.data.index(item)
+
def reverse(self):
self.data.reverse()
self.items.reverse()
Modified: trunk/docutils/docutils/transforms/__init__.py
===================================================================
--- trunk/docutils/docutils/transforms/__init__.py 2022-03-05 23:28:42 UTC (rev 9031)
+++ trunk/docutils/docutils/transforms/__init__.py 2022-03-05 23:29:06 UTC (rev 9032)
@@ -27,7 +27,8 @@
from docutils import languages, ApplicationError, TransformSpec
-class TransformError(ApplicationError): pass
+class TransformError(ApplicationError):
+ pass
class Transform:
Modified: trunk/docutils/docutils/transforms/references.py
===================================================================
--- trunk/docutils/docutils/transforms/references.py 2022-03-05 23:28:42 UTC (rev 9031)
+++ trunk/docutils/docutils/transforms/references.py 2022-03-05 23:29:06 UTC (rev 9032)
@@ -624,7 +624,8 @@
note.resolved = 1
-class CircularSubstitutionDefinitionError(Exception): pass
+class CircularSubstitutionDefinitionError(Exception):
+ pass
class Substitutions(Transform):
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2022-03-05 23:28:42 UTC (rev 9031)
+++ trunk/docutils/docutils/utils/__init__.py 2022-03-05 23:29:06 UTC (rev 9032)
@@ -27,7 +27,8 @@
self.level = level
-class SystemMessagePropagation(ApplicationError): pass
+class SystemMessagePropagation(ApplicationError):
+ pass
class Reporter:
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2022-03-05 23:28:42 UTC (rev 9031)
+++ trunk/docutils/docutils/utils/smartquotes.py 2022-03-05 23:29:06 UTC (rev 9032)
@@ -556,14 +556,14 @@
elif attr == '-1': # Special "stupefy" mode.
do_stupefy = True
else:
- if 'q' in attr: do_quotes = True
- if 'b' in attr: do_backticks = True
- if 'B' in attr: do_backticks = 2
- if 'd' in attr: do_dashes = 1
- if 'D' in attr: do_dashes = 2
- if 'i' in attr: do_dashes = 3
- if 'e' in attr: do_ellipses = True
- if 'w' in attr: convert_quot = True
+ if 'q' in attr: do_quotes = True # noqa: E701
+ if 'b' in attr: do_backticks = True # noqa: E701
+ if 'B' in attr: do_backticks = 2 # noqa: E701
+ if 'd' in attr: do_dashes = 1 # noqa: E701
+ if 'D' in attr: do_dashes = 2 # noqa: E701
+ if 'i' in attr: do_dashes = 3 # noqa: E701
+ if 'e' in attr: do_ellipses = True # noqa: E701
+ if 'w' in attr: convert_quot = True # noqa: E701
prev_token_last_char = ' '
# Last character of the previous text token. Used as
Modified: trunk/docutils/docutils/writers/docutils_xml.py
===================================================================
--- trunk/docutils/docutils/writers/docutils_xml.py 2022-03-05 23:28:42 UTC (rev 9031)
+++ trunk/docutils/docutils/writers/docutils_xml.py 2022-03-05 23:29:06 UTC (rev 9032)
@@ -17,7 +17,8 @@
from docutils import frontend, writers, nodes
-class RawXmlError(docutils.ApplicationError): pass
+class RawXmlError(docutils.ApplicationError):
+ pass
class Writer(writers.Writer):
Modified: trunk/docutils/test/test_settings.py
===================================================================
--- trunk/docutils/test/test_settings.py 2022-03-05 23:28:42 UTC (rev 9031)
+++ trunk/docutils/test/test_settings.py 2022-03-05 23:29:06 UTC (rev 9032)
@@ -225,7 +225,8 @@
def tearDown(self):
os.environ = self.orig_environ
- def test_old(self): pass # don't repreat this test
+ def test_old(self):
+ pass # don't repreat this test
@unittest.skipUnless(
os.name == 'posix',
Modified: trunk/docutils/test/test_statemachine.py
===================================================================
--- trunk/docutils/test/test_statemachine.py 2022-03-05 23:28:42 UTC (rev 9031)
+++ trunk/docutils/test/test_statemachine.py 2022-03-05 23:29:06 UTC (rev 9032)
@@ -56,47 +56,54 @@
def bof(self, context):
self.levelholder[0] += 1
self.level = self.levelholder[0]
- if self.debug: print('StateMachine%s' % self.level, file=sys.stderr)
+ if self.debug:
+ print('StateMachine%s' % self.level, file=sys.stderr)
return [], ['StateMachine%s' % self.level]
def blank(self, match, context, next_state):
result = ['blank%s' % self.level]
- if self.debug: print('blank%s' % self.level, file=sys.stderr)
+ if self.debug:
+ print('blank%s' % self.level, file=sys.stderr)
if context and context[-1] and context[-1][-2:] == '::':
result.extend(self.literalblock())
return [], None, result
def indent(self, match, context, next_state):
- if self.debug: print('indent%s' % self.level, file=sys.stderr)
+ if self.debug:
+ print('indent%s' % self.level, file=sys.stderr)
context, next_state, result = statemachine.StateWS.indent(
self, match, context, next_state)
return context, next_state, ['indent%s' % self.level] + result
def known_indent(self, match, context, next_state):
- if self.debug: print('known_indent%s' % self.level, file=sys.stderr)
+ if self.debug:
+ print('known_indent%s' % self.level, file=sys.stderr)
context, next_state, result = statemachine.StateWS.known_indent(
self, match, context, next_state)
return context, next_state, ['known_indent%s' % self.level] + result
def bullet(self, match, context, next_state):
- if self.debug: print('bullet%s' % self.level, file=sys.stderr)
+ if self.debug:
+ print('bullet%s' % self.level, file=sys.stderr)
context, next_state, result \
= self.known_indent(match, context, next_state)
return [], next_state, ['bullet%s' % self.level] + result
def text(self, match, context, next_state):
- if self.debug: print('text%s' % self.level, file=sys.stderr)
+ if self.debug:
+ print('text%s' % self.level, file=sys.stderr)
return [match.string], next_state, ['text%s' % self.level]
def literalblock(self):
indented, indent, offset, good = self.state_machine.get_indented()
- if self.debug: print('literalblock%s(%s)' % (self.level, indent),
- file=sys.stderr)
+ if self.debug:
+ print('literalblock%s(%s)' % (self.level, indent), file=sys.stderr)
return ['literalblock%s(%s)' % (self.level, indent)]
def eof(self, context):
self.levelholder[0] -= 1
- if self.debug: print('finished%s' % self.level, file=sys.stderr)
+ if self.debug:
+ print('finished%s' % self.level, file=sys.stderr)
return ['finished%s' % self.level]
Modified: trunk/docutils/tox.ini
===================================================================
--- trunk/docutils/tox.ini 2022-03-05 23:28:42 UTC (rev 9031)
+++ trunk/docutils/tox.ini 2022-03-05 23:29:06 UTC (rev 9032)
@@ -38,9 +38,6 @@
# whitespace around the operators with the lowest priority(ies).
# Use your own judgment; …"
- E502, # the backslash is redundant between brackets
- E701, # multiple statements on one line (colon)
- E704, # multiple statements on one line (def)
E711, # comparison to None should be 'if cond is not None:'
E713, # test for membership should be 'not in'
E721, # do not compare types, use 'isinstance()'
@@ -59,10 +56,16 @@
# Allow exceptions for specific files (requires flake8 >= 3.7.0)
per-file-ignores =
+ # class definitions with "…: pass" on one line
+ docutils/__init__.py:E701
+ docutils/nodes.py:E701
+ docutils/io.py:E701
+ docutils/statemachine.py:E701
+ docutils/utils/__init__.py:E701
# start of error message should be visible in traceback
docutils/parsers/rst/directives/tables.py:E128
# complex regexp definitions
- docutils/parsers/rst/states.py:E121,E128
+ docutils/parsers/rst/states.py:E121,E128,E701
# deprecated module, will be removed
docutils/utils/error_reporting.py:E261
# module with 3rd-party origin
@@ -72,8 +75,8 @@
docutils/utils/math/tex2unichar.py:E123,E261,E501
# allow aligning values in data-collections
docutils/utils/smartquotes.py:E241
- docutils/utils/roman.py:E241
- docutils/utils/math/latex2mathml.py:E241,E261,E501
+ docutils/utils/roman.py:E241,E701
+ docutils/utils/math/latex2mathml.py:E241,E261,E501,E701
docutils/writers/xetex/__init__.py:E241
# also allow '##' to mark deactivated code:
docutils/writers/latex2e/__init__.py:E241,E266
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-03-05 23:29:22
|
Revision: 9033
http://sourceforge.net/p/docutils/code/9033
Author: milde
Date: 2022-03-05 23:29:18 +0000 (Sat, 05 Mar 2022)
Log Message:
-----------
Do not use bare 'except'.
flake8 rule E722
Exception: as catchall, if
* the right thing to do does not depend on the error
* any error is reported or risen again.
Modified Paths:
--------------
trunk/docutils/docutils/io.py
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/utils/error_reporting.py
trunk/docutils/docutils/utils/smartquotes.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
trunk/docutils/tox.ini
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/docutils/io.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -31,7 +31,7 @@
locale_encoding = "UTF-8"
else:
locale_encoding = None
-except: # any other problems determining the locale -> use None
+except: # noqa any other problems determining the locale -> use None
locale_encoding = None
try:
codecs.lookup(locale_encoding or '')
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/docutils/nodes.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -1792,7 +1792,7 @@
children = (p,) + children
try:
Element.__init__(self, rawsource, *children, **attributes)
- except:
+ except: # noqa catchall
print('system_message: children=%r' % (children,))
raise
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/docutils/statemachine.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -263,7 +263,7 @@
else:
transitions = None
state = self.get_state(next_state)
- except:
+ except: # noqa catchall
if self.debug:
self.error()
raise
@@ -674,7 +674,7 @@
try:
del self.transitions[name]
self.transition_order.remove(name)
- except:
+ except: # noqa catchall
raise UnknownTransitionError(name)
def make_transition(self, name, next_state=None):
Modified: trunk/docutils/docutils/utils/error_reporting.py
===================================================================
--- trunk/docutils/docutils/utils/error_reporting.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/docutils/utils/error_reporting.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -72,7 +72,7 @@
locale_encoding = "UTF-8"
else:
locale_encoding = None
- except: # any other problems determining the locale -> use None
+ except: # noqa any other problems determining the locale -> use None
locale_encoding = None
try:
codecs.lookup(locale_encoding or '') # None -> ''
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/docutils/utils/smartquotes.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -898,7 +898,7 @@
try:
locale.setlocale(locale.LC_ALL, '') # set to user defaults
defaultlanguage = locale.getdefaultlocale()[0]
- except:
+ except: # noqa catchall
defaultlanguage = 'en'
# Normalize and drop unsupported subtags:
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -1080,7 +1080,7 @@
while True:
try:
c_start = rowspans.pop()
- except:
+ except IndexError:
break
cline += '\\cline{%d-%d}\n' % (c_start, c_start)
res.append(cline)
@@ -1089,13 +1089,13 @@
def set_rowspan(self, cell, value):
try:
self._rowspan[cell] = value
- except:
+ except IndexError:
pass
def get_rowspan(self, cell):
try:
return self._rowspan[cell]
- except:
+ except IndexError:
return 0
def get_entry_number(self):
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/test/DocutilsTestSupport.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -78,7 +78,7 @@
try:
import mypdb as pdb
-except:
+except ImportError:
import pdb
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2022-03-05 23:29:18 UTC (rev 9033)
@@ -71,7 +71,7 @@
errstr_8bit_path = """\
Cannot encode input file path "\u043c\u0438\u0440.txt" (wrong locale?).\
"""
-except:
+except FileNotFoundError:
errstr_8bit_path = """\
InputError: [Errno 2] No such file or directory: '\u043c\u0438\u0440.txt'.\
"""
Modified: trunk/docutils/tox.ini
===================================================================
--- trunk/docutils/tox.ini 2022-03-05 23:29:06 UTC (rev 9032)
+++ trunk/docutils/tox.ini 2022-03-05 23:29:18 UTC (rev 9033)
@@ -38,10 +38,6 @@
# whitespace around the operators with the lowest priority(ies).
# Use your own judgment; …"
- E711, # comparison to None should be 'if cond is not None:'
- E713, # test for membership should be 'not in'
- E721, # do not compare types, use 'isinstance()'
- E722, # do not use bare 'except'
E731, # do not assign a lambda expression, use a def
E741, # ambiguous variable name 'a'
W503, # line break before binary operator
@@ -95,3 +91,6 @@
# raw string test samples with trailing whitespace
test/test_writers/test_manpage.py:E121,E128,E501,W291
test/test_writers/test_latex2e.py:E122,E128,E501,W291,W293
+
+ # ignore all errors when setting locale
+ tools/*.py:E722
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-03-05 23:29:34
|
Revision: 9034
http://sourceforge.net/p/docutils/code/9034
Author: milde
Date: 2022-03-05 23:29:31 +0000 (Sat, 05 Mar 2022)
Log Message:
-----------
Avoid ambiguous variable name l (may be mixed up with 1).
flake8 rule E741
Modified Paths:
--------------
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/utils/math/math2html.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/tools/dev/generate_punctuation_chars.py
trunk/docutils/tox.ini
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2022-03-05 23:29:18 UTC (rev 9033)
+++ trunk/docutils/docutils/statemachine.py 2022-03-05 23:29:31 UTC (rev 9034)
@@ -1145,8 +1145,8 @@
assert len(self.data) == len(self.items), 'data mismatch'
if self.parent:
k = (i.start or 0) + self.parent_offset
- l = (i.stop or len(self)) + self.parent_offset
- self.parent[k:l] = item
+ n = (i.stop or len(self)) + self.parent_offset
+ self.parent[k:n] = item
else:
self.data[i] = item
if self.parent:
@@ -1164,8 +1164,8 @@
del self.items[i.start:i.stop]
if self.parent:
k = (i.start or 0) + self.parent_offset
- l = (i.stop or len(self)) + self.parent_offset
- del self.parent[k:l]
+ n = (i.stop or len(self)) + self.parent_offset
+ del self.parent[k:n]
def __add__(self, other):
if isinstance(other, ViewList):
Modified: trunk/docutils/docutils/utils/math/math2html.py
===================================================================
--- trunk/docutils/docutils/utils/math/math2html.py 2022-03-05 23:29:18 UTC (rev 9033)
+++ trunk/docutils/docutils/utils/math/math2html.py 2022-03-05 23:29:31 UTC (rev 9034)
@@ -2562,8 +2562,8 @@
# horizontal
literal = self.parseliteral(pos)
self.alignments = []
- for l in literal:
- self.alignments.append(l)
+ for s in literal:
+ self.alignments.append(s)
class FormulaMatrix(MultiRowFormula):
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2022-03-05 23:29:18 UTC (rev 9033)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2022-03-05 23:29:31 UTC (rev 9034)
@@ -428,7 +428,7 @@
self.setup = [r'\usepackage[%s]{babel}' % ','.join(languages)]
# Deactivate "active characters"
shorthands = []
- for c in ''.join(self.active_chars.get(l, '') for l in languages):
+ for c in ''.join(self.active_chars.get(lng, '') for lng in languages):
if c not in shorthands:
shorthands.append(c)
if shorthands:
Modified: trunk/docutils/tools/dev/generate_punctuation_chars.py
===================================================================
--- trunk/docutils/tools/dev/generate_punctuation_chars.py 2022-03-05 23:29:18 UTC (rev 9033)
+++ trunk/docutils/tools/dev/generate_punctuation_chars.py 2022-03-05 23:29:31 UTC (rev 9034)
@@ -260,25 +260,25 @@
Sort string and replace 'cdef' by 'c-f' and similar.
"""
- l = []
+ lst = []
s = sorted(ord(ch) for ch in s)
for n in s:
try:
- if l[-1][-1] + 1 == n:
- l[-1].append(n)
+ if lst[-1][-1] + 1 == n:
+ lst[-1].append(n)
else:
- l.append([n])
+ lst.append([n])
except IndexError:
- l.append([n])
+ lst.append([n])
- l2 = []
- for i in l:
+ lst2 = []
+ for i in lst:
i = [chr(n) for n in i]
if len(i) > 2:
i = i[0], '-', i[-1]
- l2.extend(i)
+ lst2.extend(i)
- return ''.join(l2)
+ return ''.join(lst2)
def wrap_string(s, startstring="('", endstring="')", wrap=67):
@@ -285,15 +285,15 @@
"""Line-wrap a unicode string literal definition."""
c = len(startstring)
contstring = "'\n" + ' '*(len(startstring)-2) + "'"
- l = [startstring]
+ lst = [startstring]
for ch in s.replace("'", r"\'"):
c += 1
if ch == '\\' and c > wrap:
c = len(startstring)
ch = contstring + ch
- l.append(ch)
- l.append(endstring)
- return ''.join(l)
+ lst.append(ch)
+ lst.append(endstring)
+ return ''.join(lst)
def print_differences(old, new, name):
Modified: trunk/docutils/tox.ini
===================================================================
--- trunk/docutils/tox.ini 2022-03-05 23:29:18 UTC (rev 9033)
+++ trunk/docutils/tox.ini 2022-03-05 23:29:31 UTC (rev 9034)
@@ -38,8 +38,6 @@
# whitespace around the operators with the lowest priority(ies).
# Use your own judgment; …"
- E731, # do not assign a lambda expression, use a def
- E741, # ambiguous variable name 'a'
W503, # line break before binary operator
W504, # line break after binary operator
W605, # invalid escape sequence
@@ -65,7 +63,7 @@
# deprecated module, will be removed
docutils/utils/error_reporting.py:E261
# module with 3rd-party origin
- docutils/utils/math/math2html.py:E111,E114,E123,E241,E261,E501
+ docutils/utils/math/math2html.py:E111,E114,E123,E241,E261,E501,E731
# generated auxiliary files
docutils/utils/math/unichar2tex.py:E122
docutils/utils/math/tex2unichar.py:E123,E261,E501
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-03-05 23:29:51
|
Revision: 9035
http://sourceforge.net/p/docutils/code/9035
Author: milde
Date: 2022-03-05 23:29:48 +0000 (Sat, 05 Mar 2022)
Log Message:
-----------
Avoid line break after binary operator.
Breaking before binary operators is the recommended style
in PEP 8 (changed in April 2016).
flake8 rule W504
Modified Paths:
--------------
trunk/docutils/docutils/core.py
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/io.py
trunk/docutils/docutils/parsers/rst/directives/admonitions.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/transforms/misc.py
trunk/docutils/docutils/transforms/references.py
trunk/docutils/docutils/utils/error_reporting.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/package_unittest.py
trunk/docutils/test/test_writers/test_latex2e.py
trunk/docutils/test/test_writers/test_manpage.py
trunk/docutils/tools/quicktest.py
trunk/docutils/tox.ini
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/docutils/core.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -273,8 +273,8 @@
Include "--traceback" output, Docutils version (%s%s),
Python version (%s), your OS type & version, and the
command line used.""" % (__version__,
- docutils.__version_details__ and
- ' [%s]'%docutils.__version_details__ or '',
+ docutils.__version_details__
+ and ' [%s]'%docutils.__version_details__ or '',
sys.version.split()[0])), file=self._stderr)
def report_SystemMessage(self, error):
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/docutils/frontend.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -596,8 +596,8 @@
version_template = ('%%prog (Docutils %s%s, Python %s, on %s)'
% (docutils.__version__,
- docutils.__version_details__ and
- ' [%s]'%docutils.__version_details__ or '',
+ docutils.__version_details__
+ and ' [%s]'%docutils.__version_details__ or '',
sys.version.split()[0], sys.platform))
"""Default version message."""
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/docutils/io.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -254,8 +254,8 @@
self.destination = destination
"""Where warning output is sent."""
- self.encoding = (encoding or getattr(destination, 'encoding', None) or
- locale_encoding or 'ascii')
+ self.encoding = (encoding or getattr(destination, 'encoding', None)
+ or locale_encoding or 'ascii')
"""The output character encoding."""
self.encoding_errors = encoding_errors
Modified: trunk/docutils/docutils/parsers/rst/directives/admonitions.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/admonitions.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/docutils/parsers/rst/directives/admonitions.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -41,8 +41,8 @@
admonition_node += title
admonition_node += messages
if 'classes' not in self.options:
- admonition_node['classes'] += ['admonition-' +
- nodes.make_id(title_text)]
+ admonition_node['classes'] += ['admonition-'
+ + nodes.make_id(title_text)]
self.state.nested_parse(self.content, self.content_offset,
admonition_node)
return [admonition_node]
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/docutils/parsers/rst/states.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -1043,8 +1043,8 @@
# Must recurse on strings before *and* after the match;
# there may be multiple patterns.
return (self.implicit_inline(text[:match.start()], lineno)
- + method(match, lineno) +
- self.implicit_inline(text[match.end():], lineno))
+ + method(match, lineno)
+ + self.implicit_inline(text[match.end():], lineno))
except MarkupMismatch:
pass
return [nodes.Text(text)]
@@ -2062,8 +2062,8 @@
initial_state='SubstitutionDef', blank_finish=blank_finish)
i = 0
for node in substitution_node[:]:
- if not (isinstance(node, nodes.Inline) or
- isinstance(node, nodes.Text)):
+ if not (isinstance(node, nodes.Inline)
+ or isinstance(node, nodes.Text)):
self.parent += substitution_node[i]
del substitution_node[i]
else:
@@ -2088,9 +2088,9 @@
return [substitution_node], blank_finish
def disallowed_inside_substitution_definitions(self, node):
- if (node['ids'] or
- isinstance(node, nodes.reference) and node.get('anonymous') or
- isinstance(node, nodes.footnote_reference) and node.get('auto')):
+ if (node['ids']
+ or isinstance(node, nodes.reference) and node.get('anonymous')
+ or isinstance(node, nodes.footnote_reference) and node.get('auto')): # noqa: E501
return True
else:
return False
Modified: trunk/docutils/docutils/transforms/misc.py
===================================================================
--- trunk/docutils/docutils/transforms/misc.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/docutils/transforms/misc.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -49,8 +49,8 @@
# Check for appropriate following siblings:
for index in range(parent.index(child) + 1, len(parent)):
element = parent[index]
- if (isinstance(element, nodes.Invisible) or
- isinstance(element, nodes.system_message)):
+ if (isinstance(element, nodes.Invisible)
+ or isinstance(element, nodes.system_message)):
continue
element['classes'] += pending.details['class']
pending.parent.remove(pending)
@@ -100,13 +100,13 @@
def visit_transition(self, node):
index = node.parent.index(node)
error = None
- if (index == 0 or
- isinstance(node.parent[0], nodes.title) and
- (index == 1 or
- isinstance(node.parent[1], nodes.subtitle) and
- index == 2)):
- assert (isinstance(node.parent, nodes.document) or
- isinstance(node.parent, nodes.section))
+ if (index == 0
+ or isinstance(node.parent[0], nodes.title)
+ and (index == 1
+ or isinstance(node.parent[1], nodes.subtitle)
+ and index == 2)):
+ assert (isinstance(node.parent, nodes.document)
+ or isinstance(node.parent, nodes.section))
error = self.document.reporter.error(
'Document or section may not begin with a transition.',
source=node.source, line=node.line)
Modified: trunk/docutils/docutils/transforms/references.py
===================================================================
--- trunk/docutils/docutils/transforms/references.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/docutils/transforms/references.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -40,9 +40,9 @@
def apply(self):
for target in self.document.findall(nodes.target):
# Only block-level targets without reference (like ".. _target:"):
- if (isinstance(target.parent, nodes.TextElement) or
- (target.hasattr('refid') or target.hasattr('refuri') or
- target.hasattr('refname'))):
+ if (isinstance(target.parent, nodes.TextElement)
+ or (target.hasattr('refid') or target.hasattr('refuri')
+ or target.hasattr('refname'))):
continue
assert len(target) == 0, 'error: block-level target has children'
next_node = target.next_node(ascend=True)
Modified: trunk/docutils/docutils/utils/error_reporting.py
===================================================================
--- trunk/docutils/docutils/utils/error_reporting.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/docutils/utils/error_reporting.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -92,8 +92,8 @@
def __init__(self, data, encoding=None, encoding_errors='backslashreplace',
decoding_errors='replace'):
self.data = data
- self.encoding = (encoding or getattr(data, 'encoding', None) or
- locale_encoding or 'ascii')
+ self.encoding = (encoding or getattr(data, 'encoding', None)
+ or locale_encoding or 'ascii')
self.encoding_errors = encoding_errors
self.decoding_errors = decoding_errors
@@ -195,8 +195,8 @@
self.stream = stream
"""Where warning output is sent."""
- self.encoding = (encoding or getattr(stream, 'encoding', None) or
- locale_encoding or 'ascii')
+ self.encoding = (encoding or getattr(stream, 'encoding', None)
+ or locale_encoding or 'ascii')
"""The output character encoding."""
self.encoding_errors = encoding_errors
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/docutils/writers/_html_base.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -1032,9 +1032,9 @@
del atts[att_name]
if style:
atts['style'] = ' '.join(style)
- if (isinstance(node.parent, nodes.TextElement) or
- (isinstance(node.parent, nodes.reference) and
- not isinstance(node.parent.parent, nodes.TextElement))):
+ if (isinstance(node.parent, nodes.TextElement)
+ or (isinstance(node.parent, nodes.reference)
+ and not isinstance(node.parent.parent, nodes.TextElement))):
# Inline context or surrounded by <a>...</a>.
suffix = ''
else:
@@ -1383,8 +1383,8 @@
def depart_paragraph(self, node):
self.body.append('</p>')
- if not (isinstance(node.parent, (nodes.list_item, nodes.entry)) and
- (len(node.parent) == 1)):
+ if not (isinstance(node.parent, (nodes.list_item, nodes.entry))
+ and (len(node.parent) == 1)):
self.body.append('\n')
def visit_problematic(self, node):
@@ -1722,9 +1722,9 @@
children = [child for child in node.children
if not isinstance(child, nodes.Invisible)]
if (children and isinstance(children[0], nodes.paragraph)
- and (isinstance(children[-1], nodes.bullet_list) or
- isinstance(children[-1], nodes.enumerated_list) or
- isinstance(children[-1], nodes.field_list))):
+ and (isinstance(children[-1], nodes.bullet_list)
+ or isinstance(children[-1], nodes.enumerated_list)
+ or isinstance(children[-1], nodes.field_list))):
children.pop()
if len(children) <= 1:
return
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -222,9 +222,9 @@
if isinstance(node.next_node(descend=False, siblings=True),
nodes.colspec):
return
- if 'colwidths-auto' in node.parent.parent['classes'] or (
- 'colwidths-auto' in self.settings.table_style and
- ('colwidths-given' not in node.parent.parent['classes'])):
+ if ('colwidths-auto' in node.parent.parent['classes']
+ or ('colwidths-auto' in self.settings.table_style
+ and 'colwidths-given' not in node.parent.parent['classes'])):
return
total_width = sum(node['colwidth'] for node in self.colspecs)
self.body.append(self.starttag(node, 'colgroup'))
@@ -411,9 +411,9 @@
self.body.append(self.starttag(node, 'td', '', CLASS='field-body'))
self.set_class_on_child(node, 'first', 0)
field = node.parent
- if (self.compact_field_list or
- isinstance(field.parent, nodes.docinfo) or
- field.parent.index(field) == len(field.parent) - 1):
+ if (self.compact_field_list
+ or isinstance(field.parent, nodes.docinfo)
+ or field.parent.index(field) == len(field.parent) - 1):
# If we are in a compact list, the docinfo, or if this is
# the last field of the field list, do not add vertical
# space after last element.
@@ -436,10 +436,10 @@
assert isinstance(field_body, nodes.field_body)
children = [n for n in field_body
if not isinstance(n, nodes.Invisible)]
- if not (len(children) == 0 or
- len(children) == 1 and
- isinstance(children[0],
- (nodes.paragraph, nodes.line_block))):
+ if not (len(children) == 0
+ or len(children) == 1
+ and isinstance(children[0],
+ (nodes.paragraph, nodes.line_block))):
self.compact_field_list = False
break
self.body.append(self.starttag(node, 'table', frame='void',
@@ -592,9 +592,9 @@
del atts[att_name]
if style:
atts['style'] = ' '.join(style)
- if (isinstance(node.parent, nodes.TextElement) or
- (isinstance(node.parent, nodes.reference) and
- not isinstance(node.parent.parent, nodes.TextElement))):
+ if (isinstance(node.parent, nodes.TextElement)
+ or (isinstance(node.parent, nodes.reference)
+ and not isinstance(node.parent.parent, nodes.TextElement))):
# Inline context or surrounded by <a>...</a>.
suffix = ''
else:
@@ -603,8 +603,8 @@
atts['class'] = 'align-%s' % node['align']
if ext in self.object_image_types:
# do NOT use an empty tag: incorrect rendering in browsers
- self.body.append(self.starttag(node, 'object', '', **atts) +
- node.get('alt', uri) + '</object>' + suffix)
+ self.body.append(self.starttag(node, 'object', '', **atts)
+ + node.get('alt', uri) + '</object>' + suffix)
else:
self.body.append(self.emptytag(node, 'img', suffix, **atts))
@@ -714,14 +714,15 @@
"""
Determine if the <p> tags around paragraph ``node`` can be omitted.
"""
- if (isinstance(node.parent, nodes.document) or
- isinstance(node.parent, nodes.compound)):
+ if (isinstance(node.parent, nodes.document)
+ or isinstance(node.parent, nodes.compound)):
# Never compact paragraphs in document or compound.
return False
for key, value in node.attlist():
- if (node.is_not_default(key) and
- not (key == 'classes' and value in
- ([], ['first'], ['last'], ['first', 'last']))):
+ if (node.is_not_default(key)
+ and not (key == 'classes'
+ and value in ([], ['first'],
+ ['last'], ['first', 'last']))):
# Attribute which needs to survive.
return False
first = isinstance(node.parent[0], nodes.label) # skip label
@@ -788,8 +789,8 @@
elif isinstance(node.parent, nodes.section):
tag = 'h%s' % (self.section_level + self.initial_header_level - 1)
self.body.append(
- self.starttag(node, tag, '', CLASS='section-subtitle') +
- self.starttag({}, 'span', '', CLASS='section-subtitle'))
+ self.starttag(node, tag, '', CLASS='section-subtitle')
+ + self.starttag({}, 'span', '', CLASS='section-subtitle'))
self.context.append('</span></%s>\n' % tag)
def depart_subtitle(self, node):
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -290,9 +290,9 @@
if getattr(self.settings, 'image_loading', None) == 'lazy':
atts['loading'] = 'lazy'
# No newline in inline context or if surrounded by <a>...</a>.
- if (isinstance(node.parent, nodes.TextElement) or
- (isinstance(node.parent, nodes.reference) and
- not isinstance(node.parent.parent, nodes.TextElement))):
+ if (isinstance(node.parent, nodes.TextElement)
+ or (isinstance(node.parent, nodes.reference)
+ and not isinstance(node.parent.parent, nodes.TextElement))):
suffix = ''
else:
suffix = '\n'
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -445,8 +445,8 @@
self.setup.extend([r'\makeatletter',
r' \addto\extrasbasque{\bbl@deactivate{~}}',
r'\makeatother'])
- if (languages[-1] == 'english' and
- 'french' in self.otherlanguages.keys()):
+ if (languages[-1] == 'english'
+ and 'french' in self.otherlanguages.keys()):
self.setup += ['% Prevent side-effects if French hyphenation '
'patterns are not loaded:',
r'\frenchbsetup{StandardLayout}',
@@ -1323,9 +1323,9 @@
self.requirements['_textquotedbl'] = (
r'\DeclareTextSymbolDefault{\textquotedbl}{T1}')
# page layout with typearea (if there are relevant document options)
- if (settings.documentclass.find('scr') == -1 and
- (self.documentoptions.find('DIV') != -1 or
- self.documentoptions.find('BCOR') != -1)):
+ if (settings.documentclass.find('scr') == -1
+ and (self.documentoptions.find('DIV') != -1
+ or self.documentoptions.find('BCOR') != -1)):
self.requirements['typearea'] = r'\usepackage{typearea}'
# Stylesheets
@@ -1382,8 +1382,8 @@
r'\setcounter{secnumdepth}{%d}'
% self.d_class.latex_section_depth(secnumdepth))
# start with specified number:
- if (hasattr(settings, 'sectnum_start') and
- settings.sectnum_start != 1):
+ if (hasattr(settings, 'sectnum_start')
+ and settings.sectnum_start != 1):
self.requirements['sectnum_start'] = (
r'\setcounter{%s}{%d}' % (self.d_class.sections[0],
settings.sectnum_start-1))
@@ -1995,8 +1995,8 @@
def visit_document(self, node):
# titled document?
- if (self.use_latex_docinfo or len(node) and
- isinstance(node[0], nodes.title)):
+ if (self.use_latex_docinfo or len(node)
+ and isinstance(node[0], nodes.title)):
protect = (self.settings.documentclass == 'memoir')
self.title_labels += self.ids_to_labels(node, set_anchor=False,
protect=protect)
@@ -2004,8 +2004,8 @@
def depart_document(self, node):
# Complete header with information gained from walkabout
# * language setup
- if (self.babel.otherlanguages or
- self.babel.language not in ('', 'english')):
+ if (self.babel.otherlanguages
+ or self.babel.language not in ('', 'english')):
self.requirements['babel'] = self.babel()
# * conditional requirements (before style sheet)
self.requirements = self.requirements.sortedvalues()
@@ -2434,11 +2434,11 @@
if 'width' in attrs:
include_graphics_options.append(
'width=%s' % self.to_latex_length(attrs['width']))
- if not (self.is_inline(node) or
- isinstance(node.parent, (nodes.figure, nodes.compound))):
+ if not (self.is_inline(node)
+ or isinstance(node.parent, (nodes.figure, nodes.compound))):
pre.append('\n')
- if not (self.is_inline(node) or
- isinstance(node.parent, nodes.figure)):
+ if not (self.is_inline(node)
+ or isinstance(node.parent, nodes.figure)):
post.append('\n')
pre.reverse()
self.out.extend(pre)
@@ -2506,8 +2506,8 @@
def visit_literal(self, node):
self.literal = True
- if ('code' in node['classes'] and
- self.settings.syntax_highlight != 'none'):
+ if ('code' in node['classes']
+ and self.settings.syntax_highlight != 'none'):
self.requirements['color'] = PreambleCmds.color
if not self.fallback_stylesheet:
self.fallbacks['code'] = PreambleCmds.highlight_rules
@@ -2980,10 +2980,11 @@
self.active_table = Table(self, 'tabular')
# A longtable moves before \paragraph and \subparagraph
# section titles if it immediately follows them:
- if (self.active_table._latex_type == 'longtable' and
- isinstance(node.parent, nodes.section) and
- node.parent.index(node) == 1 and
- self.d_class.section(self.section_level).find('paragraph') != -1):
+ if (self.active_table._latex_type == 'longtable'
+ and isinstance(node.parent, nodes.section)
+ and node.parent.index(node) == 1
+ and self.d_class.section(
+ self.section_level).find('paragraph') != -1):
self.out.append('\\leavevmode')
self.active_table.open()
self.active_table.set_table_style(node, self.settings)
@@ -3090,9 +3091,9 @@
self.pdfinfo.append(' pdftitle={%s},' %
self.encode(node.astext()))
# Topic titles (topic, admonition, sidebar)
- elif (isinstance(node.parent, nodes.topic) or
- isinstance(node.parent, nodes.admonition) or
- isinstance(node.parent, nodes.sidebar)):
+ elif (isinstance(node.parent, nodes.topic)
+ or isinstance(node.parent, nodes.admonition)
+ or isinstance(node.parent, nodes.sidebar)):
classes = node.parent['classes'] or [node.parent.tagname]
if self.settings.legacy_class_functions:
self.fallbacks['title'] = PreambleCmds.title_legacy
@@ -3235,8 +3236,8 @@
# table of contents:
if 'contents' in node['classes']:
self.visit_contents(node)
- elif ('abstract' in node['classes'] and
- self.settings.use_latex_abstract):
+ elif ('abstract' in node['classes']
+ and self.settings.use_latex_abstract):
self.push_output_collector(self.abstract)
self.out.append('\\begin{abstract}')
if isinstance(node.next_node(), nodes.title):
@@ -3265,8 +3266,8 @@
self.duclass_close(node)
else:
self.depart_block_quote(node)
- if ('abstract' in node['classes'] or
- 'dedication' in node['classes']):
+ if ('abstract' in node['classes']
+ or 'dedication' in node['classes']):
self.pop_output_collector()
def visit_transition(self, node):
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -1008,9 +1008,7 @@
def find_first_text_p(self, el):
"""Search the generated doc and return the first <text:p> element.
"""
- if (
- el.tag == 'text:p' or
- el.tag == 'text:h'):
+ if el.tag == 'text:p' or el.tag == 'text:h':
return el
else:
for child in el:
@@ -1053,10 +1051,10 @@
def setup_page(self):
self.setup_paper(self.dom_stylesheet)
- if (len(self.header_content) > 0 or
- len(self.footer_content) > 0 or
- self.settings.custom_header or
- self.settings.custom_footer):
+ if (len(self.header_content) > 0
+ or len(self.footer_content) > 0
+ or self.settings.custom_header
+ or self.settings.custom_footer):
self.add_header_footer(self.dom_stylesheet)
return etree.tostring(self.dom_stylesheet)
@@ -2318,9 +2316,9 @@
margin_right = node.get(
'{urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0}'
'margin-right')
- if (page_width is None or
- margin_left is None or
- margin_right is None):
+ if (page_width is None
+ or margin_left is None
+ or margin_right is None):
continue
try:
page_width, _ = self.convert_to_cm(page_width)
@@ -2882,9 +2880,8 @@
if self.settings.create_links:
if 'refuri' in node:
href = node['refuri']
- if (
- self.settings.cloak_email_addresses and
- href.startswith('mailto:')):
+ if (self.settings.cloak_email_addresses
+ and href.startswith('mailto:')):
href = self.cloak_mailto(href)
el = self.append_child('text:a', attrib={
'xlink:href': '%s' % href,
@@ -2901,10 +2898,9 @@
else:
self.document.reporter.warning(
'References must have "refuri" or "refid" attribute.')
- if (
- self.in_table_of_contents and
- len(node.children) >= 1 and
- isinstance(node.children[0], docutils.nodes.generated)):
+ if (self.in_table_of_contents
+ and len(node.children) >= 1
+ and isinstance(node.children[0], docutils.nodes.generated)):
node.remove(node.children[0])
def depart_reference(self, node):
@@ -3198,9 +3194,8 @@
self.set_current_element(el1)
def depart_title(self, node):
- if (
- isinstance(node.parent, docutils.nodes.section) or
- isinstance(node.parent, docutils.nodes.document)):
+ if (isinstance(node.parent, docutils.nodes.section)
+ or isinstance(node.parent, docutils.nodes.document)):
self.set_to_parent()
def visit_subtitle(self, node, move_ids=1):
@@ -3333,9 +3328,8 @@
def update_toc_add_numbers(self, collection):
for level, el1 in collection:
- if (
- el1.tag == 'text:p' and
- el1.text != 'Table of Contents'):
+ if (el1.tag == 'text:p'
+ and el1.text != 'Table of Contents'):
el2 = SubElement(el1, 'text:tab')
el2.tail = '9999'
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2022-03-05 23:29:31 UTC (rev 9034)
+++ trunk/docutils/test/DocutilsTestSupport.py 2022-03-05 23:29:48 UTC (rev 9035)
@@ -852,9 +852,9 @@
assert quote_char in ("'", '"'), quote_char
assert r[0] == r[-1]
r = r[1:-1]
- r = (stripped + 3 * quote_char + '\\\n' +
- re.sub(r'(?<!\\)((\\\\)*)\\n', r'\1\n', r) +
- 3 * quote_char)
+ r = (stripped + 3*quote_char + '\\\n'
+ + re.sub(r'(?<!\\)((\\\\)*)\\n', r'\1\n', r)
+ + 3*quote_char)
r = re.sub(r' \n', r' \\n\\\n', r)
return_tuple.append(r)
return tuple(return_tuple)
Modified: trunk/docutils/test/package_unittest.py
====================...
[truncated message content] |
|
From: <mi...@us...> - 2022-03-05 23:30:03
|
Revision: 9036
http://sourceforge.net/p/docutils/code/9036
Author: milde
Date: 2022-03-05 23:29:59 +0000 (Sat, 05 Mar 2022)
Log Message:
-----------
Fix invalid escape sequences.
flake 8 rule W605
Modified Paths:
--------------
trunk/docutils/test/test_parsers/test_recommonmark/test_section_headers.py
trunk/docutils/tox.ini
Modified: trunk/docutils/test/test_parsers/test_recommonmark/test_section_headers.py
===================================================================
--- trunk/docutils/test/test_parsers/test_recommonmark/test_section_headers.py 2022-03-05 23:29:48 UTC (rev 9035)
+++ trunk/docutils/test/test_parsers/test_recommonmark/test_section_headers.py 2022-03-05 23:29:59 UTC (rev 9036)
@@ -119,8 +119,7 @@
-------
Paragraph 4.
""",
-"""\
-<document source="test data">
+r"""<document source="test data">
<paragraph>
Test return to existing, highest-level section (Title 3).
<section ids="title-1" names="title\ 1">
@@ -157,8 +156,7 @@
### Title 5
""",
-"""\
-<document source="test data">
+r"""<document source="test data">
<paragraph>
Test bad subsection order.
<section ids="title-1" names="title\ 1">
@@ -185,7 +183,7 @@
""",
"""\
<document source="test data">
- <section ids="title-containing-inline-markup" names="title\ containing\ inline\ markup">
+ <section ids="title-containing-inline-markup" names="title\\ containing\\ inline\\ markup">
<title>
Title containing \n\
<emphasis>
@@ -232,7 +230,7 @@
""",
"""\
<document source="test data">
- <section ids="empty-section" names="empty\ section">
+ <section ids="empty-section" names="empty\\ section">
<title>
Empty Section
"""],
Modified: trunk/docutils/tox.ini
===================================================================
--- trunk/docutils/tox.ini 2022-03-05 23:29:48 UTC (rev 9035)
+++ trunk/docutils/tox.ini 2022-03-05 23:29:59 UTC (rev 9036)
@@ -41,7 +41,6 @@
W503, # line break before binary operator
# this is the recommended style (changed on April 16th, 2016)
- W605, # invalid escape sequence
F401, # 'foo' imported but unused
F841, # local variable 'foo' is assigned to but never used
#
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-03-05 23:31:14
|
Revision: 9037
http://sourceforge.net/p/docutils/code/9037
Author: milde
Date: 2022-03-05 23:31:10 +0000 (Sat, 05 Mar 2022)
Log Message:
-----------
Remove unused imports.
flake8 rule F401
Modified Paths:
--------------
trunk/docutils/docutils/core.py
trunk/docutils/docutils/parsers/recommonmark_wrapper.py
trunk/docutils/docutils/parsers/rst/directives/__init__.py
trunk/docutils/docutils/parsers/rst/directives/admonitions.py
trunk/docutils/docutils/parsers/rst/directives/html.py
trunk/docutils/docutils/parsers/rst/directives/images.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/readers/pep.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/transforms/components.py
trunk/docutils/docutils/transforms/misc.py
trunk/docutils/docutils/transforms/parts.py
trunk/docutils/docutils/transforms/peps.py
trunk/docutils/docutils/transforms/references.py
trunk/docutils/docutils/transforms/universal.py
trunk/docutils/docutils/transforms/writer_aux.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/math/math2html.py
trunk/docutils/docutils/utils/punctuation_chars.py
trunk/docutils/docutils/writers/__init__.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/docutils/writers/pep_html/__init__.py
trunk/docutils/docutils/writers/s5_html/__init__.py
trunk/docutils/docutils/writers/xetex/__init__.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/local-reader.py
trunk/docutils/test/local-writer.py
trunk/docutils/test/test__init__.py
trunk/docutils/test/test_command_line.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_io.py
trunk/docutils/test/test_language.py
trunk/docutils/test/test_nodes.py
trunk/docutils/test/test_parsers/__init__.py
trunk/docutils/test/test_parsers/test_get_parser_class.py
trunk/docutils/test/test_parsers/test_parser.py
trunk/docutils/test/test_parsers/test_recommonmark/__init__.py
trunk/docutils/test/test_parsers/test_recommonmark/test_block_quotes.py
trunk/docutils/test/test_parsers/test_recommonmark/test_bullet_lists.py
trunk/docutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py
trunk/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py
trunk/docutils/test/test_parsers/test_recommonmark/test_inline_markup.py
trunk/docutils/test/test_parsers/test_recommonmark/test_line_length_limit.py
trunk/docutils/test/test_parsers/test_recommonmark/test_line_length_limit_default.py
trunk/docutils/test/test_parsers/test_recommonmark/test_literal_blocks.py
trunk/docutils/test/test_parsers/test_recommonmark/test_misc.py
trunk/docutils/test/test_parsers/test_recommonmark/test_paragraphs.py
trunk/docutils/test/test_parsers/test_recommonmark/test_section_headers.py
trunk/docutils/test/test_parsers/test_recommonmark/test_targets.py
trunk/docutils/test/test_parsers/test_recommonmark/test_transitions.py
trunk/docutils/test/test_parsers/test_rst/__init__.py
trunk/docutils/test/test_parsers/test_rst/test_SimpleTableParser.py
trunk/docutils/test/test_parsers/test_rst/test_TableParser.py
trunk/docutils/test/test_parsers/test_rst/test_block_quotes.py
trunk/docutils/test/test_parsers/test_rst/test_bullet_lists.py
trunk/docutils/test/test_parsers/test_rst/test_character_level_inline_markup.py
trunk/docutils/test/test_parsers/test_rst/test_citations.py
trunk/docutils/test/test_parsers/test_rst/test_comments.py
trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py
trunk/docutils/test/test_parsers/test_rst/test_directives/__init__.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test__init__.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions_de.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions_dummy_lang.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_block_quotes.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_class.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_none.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_parsing.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_compound.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_container.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_contents.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_decorations.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_default_role.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_figures.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_images.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_line_blocks.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_math.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_parsed_literals.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_raw.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace_fr.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_role.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_rubrics.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_sectnum.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_sidebars.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_target_notes.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_test_directives.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_title.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_topics.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_unknown.py
trunk/docutils/test/test_parsers/test_rst/test_doctest_blocks.py
trunk/docutils/test/test_parsers/test_rst/test_east_asian_text.py
trunk/docutils/test/test_parsers/test_rst/test_enumerated_lists.py
trunk/docutils/test/test_parsers/test_rst/test_field_lists.py
trunk/docutils/test/test_parsers/test_rst/test_footnotes.py
trunk/docutils/test/test_parsers/test_rst/test_inline_markup.py
trunk/docutils/test/test_parsers/test_rst/test_interpreted.py
trunk/docutils/test/test_parsers/test_rst/test_interpreted_fr.py
trunk/docutils/test/test_parsers/test_rst/test_line_blocks.py
trunk/docutils/test/test_parsers/test_rst/test_line_length_limit.py
trunk/docutils/test/test_parsers/test_rst/test_line_length_limit_default.py
trunk/docutils/test/test_parsers/test_rst/test_literal_blocks.py
trunk/docutils/test/test_parsers/test_rst/test_option_lists.py
trunk/docutils/test/test_parsers/test_rst/test_outdenting.py
trunk/docutils/test/test_parsers/test_rst/test_paragraphs.py
trunk/docutils/test/test_parsers/test_rst/test_section_headers.py
trunk/docutils/test/test_parsers/test_rst/test_source_line.py
trunk/docutils/test/test_parsers/test_rst/test_substitutions.py
trunk/docutils/test/test_parsers/test_rst/test_tables.py
trunk/docutils/test/test_parsers/test_rst/test_targets.py
trunk/docutils/test/test_parsers/test_rst/test_transitions.py
trunk/docutils/test/test_pickle.py
trunk/docutils/test/test_readers/__init__.py
trunk/docutils/test/test_readers/test_get_reader_class.py
trunk/docutils/test/test_readers/test_pep/__init__.py
trunk/docutils/test/test_readers/test_pep/test_inline_markup.py
trunk/docutils/test/test_readers/test_pep/test_rfc2822.py
trunk/docutils/test/test_settings.py
trunk/docutils/test/test_transforms/__init__.py
trunk/docutils/test/test_transforms/itest_hyperlinks_de.py
trunk/docutils/test/test_transforms/test___init__.py
trunk/docutils/test/test_transforms/test_class.py
trunk/docutils/test/test_transforms/test_contents.py
trunk/docutils/test/test_transforms/test_docinfo.py
trunk/docutils/test/test_transforms/test_doctitle.py
trunk/docutils/test/test_transforms/test_expose_internals.py
trunk/docutils/test/test_transforms/test_filter.py
trunk/docutils/test/test_transforms/test_filter_messages.py
trunk/docutils/test/test_transforms/test_footnotes.py
trunk/docutils/test/test_transforms/test_hyperlinks.py
trunk/docutils/test/test_transforms/test_messages.py
trunk/docutils/test/test_transforms/test_peps.py
trunk/docutils/test/test_transforms/test_sectnum.py
trunk/docutils/test/test_transforms/test_smartquotes.py
trunk/docutils/test/test_transforms/test_strip_comments.py
trunk/docutils/test/test_transforms/test_strip_elements_with_class.py
trunk/docutils/test/test_transforms/test_substitution_expansion_length_limit.py
trunk/docutils/test/test_transforms/test_substitutions.py
trunk/docutils/test/test_transforms/test_target_notes.py
trunk/docutils/test/test_transforms/test_transitions.py
trunk/docutils/test/test_transforms/test_writer_aux.py
trunk/docutils/test/test_traversals.py
trunk/docutils/test/test_writers/__init__.py
trunk/docutils/test/test_writers/test_docutils_xml.py
trunk/docutils/test/test_writers/test_get_writer_class.py
trunk/docutils/test/test_writers/test_html4css1_misc.py
trunk/docutils/test/test_writers/test_html4css1_parts.py
trunk/docutils/test/test_writers/test_html4css1_template.py
trunk/docutils/test/test_writers/test_html5_polyglot_misc.py
trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
trunk/docutils/test/test_writers/test_latex2e.py
trunk/docutils/test/test_writers/test_latex2e_misc.py
trunk/docutils/test/test_writers/test_manpage.py
trunk/docutils/test/test_writers/test_null.py
trunk/docutils/test/test_writers/test_odt.py
trunk/docutils/test/test_writers/test_pseudoxml.py
trunk/docutils/test/test_writers/test_s5.py
trunk/docutils/tools/dev/generate_punctuation_chars.py
trunk/docutils/tox.ini
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/core.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -17,10 +17,9 @@
import sys
import pprint
-from docutils import __version__, __version_details__, SettingsSpec
-from docutils import frontend, io, utils, readers, writers
+from docutils import __version__, SettingsSpec
+from docutils import io, utils, readers, writers
from docutils.frontend import OptionParser
-from docutils.transforms import Transformer
import docutils.readers.doctree
Modified: trunk/docutils/docutils/parsers/recommonmark_wrapper.py
===================================================================
--- trunk/docutils/docutils/parsers/recommonmark_wrapper.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/parsers/recommonmark_wrapper.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -24,7 +24,6 @@
* The API is not settled and may change with any minor Docutils version.
"""
-import docutils.parsers
from docutils import nodes, Component
try:
Modified: trunk/docutils/docutils/parsers/rst/directives/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/__init__.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/parsers/rst/directives/__init__.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -13,7 +13,7 @@
from importlib import import_module
from docutils import nodes, parsers
-from docutils.utils import split_escaped_whitespace, escape2null, unescape
+from docutils.utils import split_escaped_whitespace, escape2null
from docutils.parsers.rst.languages import en as _fallback_language_module
@@ -204,7 +204,8 @@
raise ValueError('argument required but none supplied')
else:
parts = split_escaped_whitespace(escape2null(argument))
- return ' '.join(''.join(unescape(part).split()) for part in parts)
+ return ' '.join(''.join(nodes.unescape(part).split())
+ for part in parts)
def nonnegative_int(argument):
Modified: trunk/docutils/docutils/parsers/rst/directives/admonitions.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/admonitions.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/parsers/rst/directives/admonitions.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -10,7 +10,7 @@
from docutils.parsers.rst import Directive
-from docutils.parsers.rst import states, directives
+from docutils.parsers.rst import directives
from docutils.parsers.rst.roles import set_classes
from docutils import nodes
Modified: trunk/docutils/docutils/parsers/rst/directives/html.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/html.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/parsers/rst/directives/html.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -12,7 +12,7 @@
import warnings
-from docutils.parsers.rst.directives.misc import MetaBody, Meta
+from docutils.parsers.rst.directives.misc import MetaBody, Meta # noqa: F401
warnings.warn('The `docutils.parsers.rst.directive.html` module'
' will be removed in Docutils 1.2.'
Modified: trunk/docutils/docutils/parsers/rst/directives/images.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/images.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/parsers/rst/directives/images.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -20,10 +20,10 @@
except ImportError:
PIL = None
-from docutils import nodes, utils
+from docutils import nodes
+from docutils.nodes import fully_normalize_name, whitespace_normalize_name
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives, states
-from docutils.nodes import fully_normalize_name, whitespace_normalize_name
from docutils.parsers.rst.roles import set_classes
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -13,7 +13,6 @@
from docutils.parsers.rst import Directive, convert_directive_function
from docutils.parsers.rst import directives, roles, states
from docutils.parsers.rst.directives.body import CodeBlock, NumberLines
-from docutils.parsers.rst.roles import set_classes
from docutils.transforms import misc
@@ -521,11 +520,11 @@
def parsemeta(self, match):
name = self.parse_field_marker(match)
- name = utils.unescape(utils.escape2null(name))
+ name = nodes.unescape(utils.escape2null(name))
(indented, indent, line_offset, blank_finish
) = self.state_machine.get_first_known_indented(match.end())
node = nodes.meta()
- node['content'] = utils.unescape(utils.escape2null(
+ node['content'] = nodes.unescape(utils.escape2null(
' '.join(indented)))
if not indented:
line = self.state_machine.line
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -77,7 +77,7 @@
__docformat__ = 'reStructuredText'
-from docutils import nodes, utils
+from docutils import nodes
from docutils.parsers.rst import directives
from docutils.parsers.rst.languages import en as _fallback_language_module
from docutils.utils.code_analyzer import Lexer, LexerError
@@ -268,7 +268,7 @@
options=None, content=None):
options = normalized_role_options(options)
try:
- pepnum = int(utils.unescape(text))
+ pepnum = int(nodes.unescape(text))
if pepnum < 0 or pepnum > 9999:
raise ValueError
except ValueError:
@@ -290,9 +290,9 @@
options=None, content=None):
options = normalized_role_options(options)
if "#" in text:
- rfcnum, section = utils.unescape(text).split("#", 1)
+ rfcnum, section = nodes.unescape(text).split("#", 1)
else:
- rfcnum, section = utils.unescape(text), None
+ rfcnum, section = nodes.unescape(text), None
try:
rfcnum = int(rfcnum)
if rfcnum < 1:
@@ -328,7 +328,7 @@
'an associated format.' % role, line=lineno)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
- node = nodes.raw(rawtext, utils.unescape(text, True), **options)
+ node = nodes.raw(rawtext, nodes.unescape(text, True), **options)
node.source, node.line = inliner.reporter.get_source_and_line(lineno)
return [node], []
@@ -348,7 +348,7 @@
if language and language not in classes:
classes.append(language)
try:
- tokens = Lexer(utils.unescape(text, True), language,
+ tokens = Lexer(nodes.unescape(text, True), language,
inliner.document.settings.syntax_highlight)
except LexerError as error:
msg = inliner.reporter.warning(error)
@@ -376,7 +376,7 @@
def math_role(role, rawtext, text, lineno, inliner,
options=None, content=None):
options = normalized_role_options(options)
- text = utils.unescape(text, True) # raw text without inline role markup
+ text = nodes.unescape(text, True) # raw text without inline role markup
node = nodes.math(rawtext, text, **options)
return [node], []
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/parsers/rst/states.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -110,11 +110,10 @@
from docutils import ApplicationError, DataError
from docutils.statemachine import StateMachineWS, StateWS
from docutils.nodes import fully_normalize_name as normalize_name
-from docutils.nodes import whitespace_normalize_name
+from docutils.nodes import unescape, whitespace_normalize_name
import docutils.parsers.rst
from docutils.parsers.rst import directives, languages, tableparser, roles
-from docutils.parsers.rst.languages import en as _fallback_language_module
-from docutils.utils import escape2null, unescape, column_width
+from docutils.utils import escape2null, column_width
from docutils.utils import punctuation_chars, roman, urischemes
from docutils.utils import split_escaped_whitespace
Modified: trunk/docutils/docutils/readers/pep.py
===================================================================
--- trunk/docutils/docutils/readers/pep.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/readers/pep.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -10,7 +10,7 @@
from docutils.readers import standalone
-from docutils.transforms import peps, references, misc, frontmatter
+from docutils.transforms import peps, frontmatter
from docutils.parsers import rst
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/statemachine.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -110,7 +110,7 @@
import re
from unicodedata import east_asian_width
-from docutils import io, utils
+from docutils import utils
class StateMachine:
Modified: trunk/docutils/docutils/transforms/components.py
===================================================================
--- trunk/docutils/docutils/transforms/components.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/transforms/components.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -6,13 +6,11 @@
Docutils component-related transforms.
"""
+from docutils.transforms import Transform
+
__docformat__ = 'reStructuredText'
-from docutils import nodes, utils
-from docutils import ApplicationError, DataError
-from docutils.transforms import Transform, TransformError
-
class Filter(Transform):
"""
Modified: trunk/docutils/docutils/transforms/misc.py
===================================================================
--- trunk/docutils/docutils/transforms/misc.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/transforms/misc.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -9,7 +9,7 @@
__docformat__ = 'reStructuredText'
from docutils import nodes
-from docutils.transforms import Transform, TransformError
+from docutils.transforms import Transform
class CallBack(Transform):
Modified: trunk/docutils/docutils/transforms/parts.py
===================================================================
--- trunk/docutils/docutils/transforms/parts.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/transforms/parts.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -10,8 +10,8 @@
import sys
-from docutils import nodes, utils
-from docutils.transforms import TransformError, Transform
+from docutils import nodes
+from docutils.transforms import Transform
class SectNum(Transform):
Modified: trunk/docutils/docutils/transforms/peps.py
===================================================================
--- trunk/docutils/docutils/transforms/peps.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/transforms/peps.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -17,8 +17,8 @@
import re
import time
from docutils import nodes, utils, languages
-from docutils import ApplicationError, DataError
-from docutils.transforms import Transform, TransformError
+from docutils import DataError
+from docutils.transforms import Transform
from docutils.transforms import parts, references, misc
Modified: trunk/docutils/docutils/transforms/references.py
===================================================================
--- trunk/docutils/docutils/transforms/references.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/transforms/references.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -9,7 +9,7 @@
__docformat__ = 'reStructuredText'
from docutils import nodes, utils
-from docutils.transforms import TransformError, Transform
+from docutils.transforms import Transform
class PropagateTargets(Transform):
Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/transforms/universal.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -23,7 +23,7 @@
import re
import time
from docutils import nodes, utils
-from docutils.transforms import TransformError, Transform
+from docutils.transforms import Transform
from docutils.utils import smartquotes
Modified: trunk/docutils/docutils/transforms/writer_aux.py
===================================================================
--- trunk/docutils/docutils/transforms/writer_aux.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/transforms/writer_aux.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -16,7 +16,7 @@
import warnings
-from docutils import nodes, utils, languages
+from docutils import nodes, languages
from docutils.transforms import Transform
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/utils/__init__.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -15,9 +15,10 @@
import itertools
import warnings
import unicodedata
+
from docutils import ApplicationError, DataError, __version_info__
from docutils import io, nodes
-from docutils.nodes import unescape
+from docutils.nodes import unescape # noqa: F401 backwards compatibility
class SystemMessage(ApplicationError):
Modified: trunk/docutils/docutils/utils/math/math2html.py
===================================================================
--- trunk/docutils/docutils/utils/math/math2html.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/utils/math/math2html.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -24,7 +24,6 @@
import os.path
import sys
import unicodedata
-from urllib.parse import quote_plus
from docutils.utils.math import tex2unichar
Modified: trunk/docutils/docutils/utils/punctuation_chars.py
===================================================================
--- trunk/docutils/docutils/utils/punctuation_chars.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/utils/punctuation_chars.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -15,7 +15,6 @@
# ::
import sys
-import unicodedata
"""Docutils character category patterns.
Modified: trunk/docutils/docutils/writers/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/__init__.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/writers/__init__.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -8,7 +8,6 @@
__docformat__ = 'reStructuredText'
-import os.path
from importlib import import_module
import docutils
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -16,9 +16,8 @@
import os.path
import re
-import docutils
-from docutils import frontend, nodes, writers, io
-from docutils.transforms import writer_aux
+
+from docutils import frontend, nodes, writers
from docutils.writers import _html_base
from docutils.writers._html_base import PIL, url2pathname
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -29,13 +29,11 @@
import mimetypes
import os.path
-import docutils
-from docutils import frontend, nodes, writers, io
-from docutils.transforms import writer_aux
+from docutils import frontend, nodes
from docutils.writers import _html_base
-class Writer(writers._html_base.Writer):
+class Writer(_html_base.Writer):
supported = ('html', 'html5', 'xhtml')
"""Formats this writer supports."""
@@ -47,7 +45,7 @@
# use a copy of the parent spec with some modifications
settings_spec = frontend.filter_settings_spec(
- writers._html_base.Writer.settings_spec,
+ _html_base.Writer.settings_spec,
template=(
'Template file. (UTF-8 encoded, default: "%s")'
% default_template,
@@ -114,7 +112,7 @@
self.translator_class = HTMLTranslator
-class HTMLTranslator(writers._html_base.HTMLTranslator):
+class HTMLTranslator(_html_base.HTMLTranslator):
"""
This writer generates `polyglot markup`: HTML5 that is also valid XML.
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/writers/manpage.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -45,7 +45,6 @@
import re
-import docutils
from docutils import nodes, writers, languages
try:
import roman
Modified: trunk/docutils/docutils/writers/pep_html/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/pep_html/__init__.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/writers/pep_html/__init__.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -11,8 +11,8 @@
import os
import os.path
-import docutils
-from docutils import frontend, nodes, utils, writers
+
+from docutils import frontend, nodes, utils
from docutils.writers import html4css1
Modified: trunk/docutils/docutils/writers/s5_html/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/s5_html/__init__.py 2022-03-05 23:29:59 UTC (rev 9036)
+++ trunk/docutils/docutils/writers/s5_html/__init__.py 2022-03-05 23:31:10 UTC (rev 9037)
@@ -16,7 +16,6 @@
import docutils
from docutils import frontend, nodes, utils
from docutils.writers import html4css1
-from docutils.parsers.rst import directives
themes_dir_path = utils.relative_path(
os.path.join(os.getcwd(), 'dummy'),
Modified: trunk/docutils/docutils/writers/xetex/__init__.py
===================================================================
---...
[truncated message content] |
|
From: <mi...@us...> - 2022-03-05 23:31:49
|
Revision: 9038
http://sourceforge.net/p/docutils/code/9038
Author: milde
Date: 2022-03-05 23:31:46 +0000 (Sat, 05 Mar 2022)
Log Message:
-----------
Remove unused local variables
flake rule F841: local variable 'foo' is assigned to but never used
In test_odt.py, a no-op class definition is removed completely.
Modified Paths:
--------------
trunk/docutils/docutils/core.py
trunk/docutils/docutils/io.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/parsers/rst/tableparser.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/transforms/parts.py
trunk/docutils/docutils/utils/math/math2html.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/docutils_xml.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/test_functional.py
trunk/docutils/test/test_io.py
trunk/docutils/test/test_language.py
trunk/docutils/test/test_parsers/test_get_parser_class.py
trunk/docutils/test/test_readers/test_get_reader_class.py
trunk/docutils/test/test_traversals.py
trunk/docutils/test/test_writers/test_get_writer_class.py
trunk/docutils/test/test_writers/test_odt.py
trunk/docutils/tox.ini
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/docutils/core.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -475,7 +475,7 @@
settings_spec, settings_overrides, config_section)
pub.set_source(source, source_path)
pub.set_destination(None, None)
- output = pub.publish(enable_exit_status=enable_exit_status)
+ pub.publish(enable_exit_status=enable_exit_status)
return pub.document
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/docutils/io.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -362,7 +362,7 @@
data = b'\n'.join(data.splitlines()+[b''])
else:
data = self.source.read()
- except (UnicodeError, LookupError) as err:
+ except (UnicodeError, LookupError):
if not self.encoding and self.source_path:
# re-read in binary mode and decode with heuristics
b_source = open(self.source_path, 'rb')
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -73,7 +73,7 @@
include_file = io.FileInput(source_path=path,
encoding=encoding,
error_handler=e_handler)
- except UnicodeEncodeError as error:
+ except UnicodeEncodeError:
raise self.severe('Problems with "%s" directive path:\n'
'Cannot encode input file path "%s" '
'(wrong locale?).' %
Modified: trunk/docutils/docutils/parsers/rst/tableparser.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/tableparser.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/docutils/parsers/rst/tableparser.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -473,10 +473,8 @@
return
if spanline:
columns = self.parse_columns(*spanline)
- span_offset = spanline[1]
else:
columns = self.columns[:]
- span_offset = start
self.check_columns(lines, start, columns)
row = self.init_row(columns, start)
for i in range(len(columns)):
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/docutils/statemachine.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -430,7 +430,6 @@
"""
if transitions is None:
transitions = state.transition_order
- state_correction = None
if self.debug:
print('\nStateMachine.check_line: state="%s", transitions=%r.'
% (state.__class__.__name__, transitions), file=sys.stderr)
Modified: trunk/docutils/docutils/transforms/parts.py
===================================================================
--- trunk/docutils/docutils/transforms/parts.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/docutils/transforms/parts.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -116,7 +116,6 @@
level += 1
sections = [sect for sect in node if isinstance(sect, nodes.section)]
entries = []
- autonum = 0
depth = self.startnode.details.get('depth', sys.maxsize)
for section in sections:
title = section[0]
Modified: trunk/docutils/docutils/utils/math/math2html.py
===================================================================
--- trunk/docutils/docutils/utils/math/math2html.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/docutils/utils/math/math2html.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -1394,7 +1394,6 @@
def extracttext(self):
"Extract all text from allowed containers."
- result = ''
constants = ContainerExtractor(ContainerConfig.extracttext).extract(self)
return ''.join(constant.string for constant in constants)
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/docutils/writers/_html_base.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -1043,11 +1043,6 @@
atts['class'] = 'align-%s' % node['align']
# Embed image file (embedded SVG or data URI):
if self.image_loading == 'embed':
- err_msg = ''
- if not mimetype:
- err_msg = 'unknown MIME type'
- if not self.settings.file_insertion_enabled:
- err_msg = 'file insertion disabled.'
try:
with open(url2pathname(uri), 'rb') as imagefile:
imagedata = imagefile.read()
Modified: trunk/docutils/docutils/writers/docutils_xml.py
===================================================================
--- trunk/docutils/docutils/writers/docutils_xml.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/docutils/writers/docutils_xml.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -170,7 +170,7 @@
# Check validity of raw XML:
try:
self.xmlparser.parse(StringIO(xml_string))
- except xml.sax._exceptions.SAXParseException as error:
+ except xml.sax._exceptions.SAXParseException:
col_num = self.the_handle.locator.getColumnNumber()
line_num = self.the_handle.locator.getLineNumber()
srcline = node.line
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/docutils/writers/manpage.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -1054,7 +1054,6 @@
# Level is too low to display:
# raise nodes.SkipNode
attr = {}
- backref_text = ''
if node.hasattr('id'):
attr['name'] = node['id']
if node.hasattr('line'):
Modified: trunk/docutils/test/test_functional.py
===================================================================
--- trunk/docutils/test/test_functional.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/test/test_functional.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -150,8 +150,6 @@
# Get output (automatically written to the output/ directory
# by publish_file):
output = docutils.core.publish_file(**params)
- # ensure output is unicode
- output_encoding = params.get('output_encoding', 'utf-8')
# Normalize line endings:
output = '\n'.join(output.splitlines())
# Get the expected output *after* writing the actual output.
Modified: trunk/docutils/test/test_io.py
===================================================================
--- trunk/docutils/test/test_io.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/test/test_io.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -94,7 +94,7 @@
data
blah
""")
- data = input.read()
+ data = input.read() # noqa: F841
self.assertEqual(input.successful_encoding, 'ascii')
input = io.StringInput(source=b"""\
#! python
@@ -101,7 +101,7 @@
# -*- coding: ascii -*-
print("hello world")
""")
- data = input.read()
+ data = input.read() # noqa: F841
self.assertEqual(input.successful_encoding, 'ascii')
input = io.StringInput(source=b"""\
#! python
@@ -109,7 +109,6 @@
# -*- coding: ascii -*-
print("hello world")
""")
- data = input.read()
self.assertNotEqual(input.successful_encoding, 'ascii')
def test_bom_detection(self):
@@ -121,7 +120,7 @@
data = input.read()
self.assertEqual(input.successful_encoding, 'utf-16-le')
input = io.StringInput(source=source.encode('utf-8'))
- data = input.read()
+ data = input.read() # noqa: F841
self.assertEqual(input.successful_encoding, 'utf-8')
def test_readlines(self):
@@ -183,7 +182,7 @@
def test_FileOutput_hande_io_errors_deprection_warning(self):
with self.assertWarnsRegex(DeprecationWarning,
'"handle_io_errors" is ignored'):
- fo = io.FileOutput(handle_io_errors=True)
+ io.FileOutput(handle_io_errors=True)
# With destination in binary mode, data must be binary string
# and is written as-is:
Modified: trunk/docutils/test/test_language.py
===================================================================
--- trunk/docutils/test/test_language.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/test/test_language.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -182,9 +182,7 @@
failures = []
for d in module.roles.values():
try:
- method = roles._role_registry[d]
- # if not method:
- # failures.append('"%s": unknown role' % d)
+ roles._role_registry[d]
except KeyError as error:
failures.append('"%s": %s' % (d, error))
inverted = self._invert(module.roles)
Modified: trunk/docutils/test/test_parsers/test_get_parser_class.py
===================================================================
--- trunk/docutils/test/test_parsers/test_get_parser_class.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/test/test_parsers/test_get_parser_class.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -18,7 +18,7 @@
class GetParserClassTestCase(DocutilsTestSupport.StandardTestCase):
def test_registered_parser(self):
- rdr = get_parser_class('rst')
+ get_parser_class('rst')
# raises ImportError on failure
def test_bogus_parser(self):
@@ -27,7 +27,8 @@
def test_local_parser(self):
# requires local-parser.py in test directory (testroot)
- wr = get_parser_class('local-parser')
+ get_parser_class('local-parser')
+ # raises ImportError on failure
if __name__ == '__main__':
Modified: trunk/docutils/test/test_readers/test_get_reader_class.py
===================================================================
--- trunk/docutils/test/test_readers/test_get_reader_class.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/test/test_readers/test_get_reader_class.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -18,7 +18,7 @@
class GetReaderClassTestCase(DocutilsTestSupport.StandardTestCase):
def test_registered_reader(self):
- rdr = get_reader_class('pep')
+ get_reader_class('pep')
# raises ImportError on failure
def test_bogus_reader(self):
@@ -27,7 +27,8 @@
def test_local_reader(self):
# requires local-reader.py in test directory (testroot)
- wr = get_reader_class('local-reader')
+ get_reader_class('local-reader')
+ # raises ImportError on failure
if __name__ == '__main__':
Modified: trunk/docutils/test/test_traversals.py
===================================================================
--- trunk/docutils/test/test_traversals.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/test/test_traversals.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -66,7 +66,7 @@
settings_spec=self)
self.assertTrue(isinstance(doctree, nodes.document))
- parts = core.publish_parts(
+ core.publish_parts(
reader_name='doctree', source_class=docutils.io.DocTreeInput,
source=doctree, source_path='test',
writer=AttentiveWriter())
Modified: trunk/docutils/test/test_writers/test_get_writer_class.py
===================================================================
--- trunk/docutils/test/test_writers/test_get_writer_class.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/test/test_writers/test_get_writer_class.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -18,7 +18,7 @@
class GetWriterClassTestCase(DocutilsTestSupport.StandardTestCase):
def test_registered_writer(self):
- wr = get_writer_class('manpage')
+ get_writer_class('manpage')
# raises ImportError on failure
def test_bogus_writer(self):
@@ -27,7 +27,8 @@
def test_local_writer(self):
# requires local-writer.py in test directory (testroot)
- wr = get_writer_class('local-writer')
+ get_writer_class('local-writer')
+ # raises ImportError on failure
if __name__ == '__main__':
Modified: trunk/docutils/test/test_writers/test_odt.py
===================================================================
--- trunk/docutils/test/test_writers/test_odt.py 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/test/test_writers/test_odt.py 2022-03-05 23:31:46 UTC (rev 9038)
@@ -108,17 +108,6 @@
# return doc.toprettyxml(indent=' ')
return etree.tostring(doc)
- def assertEqual(self, first, second, msg=None):
- if msg is None:
- msg2 = msg
- else:
- sep = '+' * 60
- msg1 = '\n%s\nresult:\n%s\n%s\nexpected:\n%s\n%s' % (
- sep, first, sep, second, sep, )
- # msg2 = '%s\n%s' % (msg1, msg, )
- msg2 = '%s' % (msg, )
- super().assertEqual(first, second, msg2)
-
#
# Unit test methods
#
Modified: trunk/docutils/tox.ini
===================================================================
--- trunk/docutils/tox.ini 2022-03-05 23:31:10 UTC (rev 9037)
+++ trunk/docutils/tox.ini 2022-03-05 23:31:46 UTC (rev 9038)
@@ -41,9 +41,8 @@
W503, # line break before binary operator
# this is the recommended style (changed on April 16th, 2016)
- F841, # local variable 'foo' is assigned to but never used
- #
# The following rules are required for Python 3 support
+
exclude = .venv,.tox,dist,*egg,build
max-complexity = 35
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-03-11 12:09:19
|
Revision: 9043
http://sourceforge.net/p/docutils/code/9043
Author: milde
Date: 2022-03-11 12:09:16 +0000 (Fri, 11 Mar 2022)
Log Message:
-----------
core.Publisher.publish(): Prompt when waiting for input from a terminal.
When front-end tools are used without arguments,
Docutils reads from stdin.
Currently, when a user calls a front-end without arguments,
there is no response until the user presses Ctrl-D (Ctrl-Z on Windows)
or aborts with Ctrl-C.
This commit changes the behaviour to tell the user what the front-end
expects and where to get more help.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/dev/todo.txt
trunk/docutils/docutils/__init__.py
trunk/docutils/docutils/core.py
trunk/docutils/docutils/io.py
trunk/docutils/docutils/parsers/recommonmark_wrapper.py
trunk/docutils/docutils/parsers/rst/__init__.py
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/docutils/writers/pseudoxml.py
trunk/docutils/docutils/writers/xetex/__init__.py
trunk/docutils/docutils.conf
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-03-11 12:08:58 UTC (rev 9042)
+++ trunk/docutils/HISTORY.txt 2022-03-11 12:09:16 UTC (rev 9043)
@@ -21,6 +21,11 @@
- Code cleanup,
check PEP 8 conformity with `flake8` (exceptions in file tox.ini).
+* docutils/core.py:
+
+ Publisher.publish(): Print info and prompt when waiting for input from
+ a terminal cf. https://clig.dev/#interactivity.
+
* docutils/parsers/__init__.py
- Alias for the "myst" parser (https://pypi.org/project/myst-docutils).
Modified: trunk/docutils/docs/dev/todo.txt
===================================================================
--- trunk/docutils/docs/dev/todo.txt 2022-03-11 12:08:58 UTC (rev 9042)
+++ trunk/docutils/docs/dev/todo.txt 2022-03-11 12:09:16 UTC (rev 9043)
@@ -2866,6 +2866,16 @@
directive should override the ``--no-section-numbering`` command
line option then.
+* Implement the following suggestions from clig.dev?
+
+ Display output on success, but keep it brief.
+ provide a --quiet option to suppress all non-essential output.
+
+ Consider chaining several args as input and use --output
+ (or redirection) for output.
+
+ -- https://clig.dev/#help
+
.. _partial parsing:
https://docs.python.org/3/library/argparse.html#partial-parsing
Modified: trunk/docutils/docutils/__init__.py
===================================================================
--- trunk/docutils/docutils/__init__.py 2022-03-11 12:08:58 UTC (rev 9042)
+++ trunk/docutils/docutils/__init__.py 2022-03-11 12:09:16 UTC (rev 9043)
@@ -268,7 +268,7 @@
subclasses."""
supported = ()
- """Names for this component. Override in subclasses."""
+ """Name and aliases for this component. Override in subclasses."""
def supports(self, format):
"""
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2022-03-11 12:08:58 UTC (rev 9042)
+++ trunk/docutils/docutils/core.py 2022-03-11 12:09:16 UTC (rev 9043)
@@ -15,6 +15,7 @@
__docformat__ = 'reStructuredText'
+import os
import sys
import pprint
from docutils import __version__, SettingsSpec
@@ -203,6 +204,7 @@
argv, usage, description, settings_spec, config_section,
**(settings_overrides or {}))
self.set_io()
+ self.prompt()
self.document = self.reader.read(self.source, self.parser,
self.settings)
self.apply_transforms()
@@ -252,6 +254,27 @@
print(self.document.pformat().encode(
'raw_unicode_escape'), file=self._stderr)
+ def prompt(self):
+ """Print info and prompt when waiting for input from a terminal."""
+ try:
+ if not (self.source.isatty() and self._stderr.isatty()):
+ return
+ except AttributeError:
+ return
+ eot_key = 'Ctrl+Z' if os.name == 'nt' else 'Ctrl+D on an empty line'
+ in_format = 'plaintext'
+ out_format = 'useful formats'
+ try:
+ in_format = self.parser.supported[0]
+ out_format = self.writer.supported[0]
+ except (AttributeError, IndexError):
+ pass
+ print(f'Docutils {__version__} <https://docutils.sourceforge.io>\n'
+ f'converting "{in_format}" into "{out_format}".\n'
+ f'Call with option "--help" for more info.\n'
+ f'.. Waiting for source text (finish with {eot_key}):',
+ file=self._stderr)
+
def report_Exception(self, error):
if isinstance(error, utils.SystemMessage):
self.report_SystemMessage(error)
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2022-03-11 12:08:58 UTC (rev 9042)
+++ trunk/docutils/docutils/io.py 2022-03-11 12:09:16 UTC (rev 9043)
@@ -175,7 +175,13 @@
return match.group(1).decode('ascii')
return None
+ def isatty(self):
+ try:
+ return self.source.isatty()
+ except AttributeError:
+ return False
+
class Output(TransformSpec):
"""
@@ -304,7 +310,13 @@
except AttributeError:
pass
+ def isatty(self):
+ try:
+ return self.destination.isatty()
+ except AttributeError:
+ return False
+
class FileInput(Input):
"""
Modified: trunk/docutils/docutils/parsers/recommonmark_wrapper.py
===================================================================
--- trunk/docutils/docutils/parsers/recommonmark_wrapper.py 2022-03-11 12:08:58 UTC (rev 9042)
+++ trunk/docutils/docutils/parsers/recommonmark_wrapper.py 2022-03-11 12:09:16 UTC (rev 9043)
@@ -55,6 +55,8 @@
the API is not settled and may change with any minor Docutils version.
"""
supported = ('recommonmark', 'commonmark', 'markdown', 'md')
+ """Formats this parser supports."""
+
config_section = 'recommonmark parser'
config_section_dependencies = ('parsers',)
Modified: trunk/docutils/docutils/parsers/rst/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/__init__.py 2022-03-11 12:08:58 UTC (rev 9042)
+++ trunk/docutils/docutils/parsers/rst/__init__.py 2022-03-11 12:09:16 UTC (rev 9043)
@@ -81,7 +81,7 @@
"""The reStructuredText parser."""
- supported = ('restructuredtext', 'rst', 'rest', 'restx', 'rtxt', 'rstx')
+ supported = ('rst', 'restructuredtext', 'rest', 'restx', 'rtxt', 'rstx')
"""Aliases this parser supports."""
settings_spec = docutils.parsers.Parser.settings_spec + (
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-03-11 12:08:58 UTC (rev 9042)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-03-11 12:09:16 UTC (rev 9043)
@@ -35,7 +35,7 @@
class Writer(_html_base.Writer):
- supported = ('html', 'html5', 'xhtml')
+ supported = ('html5', 'xhtml', 'html')
"""Formats this writer supports."""
default_stylesheets = ['minimal.css', 'plain.css']
Modified: trunk/docutils/docutils/writers/pseudoxml.py
===================================================================
--- trunk/docutils/docutils/writers/pseudoxml.py 2022-03-11 12:08:58 UTC (rev 9042)
+++ trunk/docutils/docutils/writers/pseudoxml.py 2022-03-11 12:09:16 UTC (rev 9043)
@@ -14,7 +14,7 @@
class Writer(writers.Writer):
- supported = ('pprint', 'pformat', 'pseudoxml')
+ supported = ('pseudoxml', 'pprint', 'pformat')
"""Formats this writer supports."""
settings_spec = (
Modified: trunk/docutils/docutils/writers/xetex/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/xetex/__init__.py 2022-03-11 12:08:58 UTC (rev 9042)
+++ trunk/docutils/docutils/writers/xetex/__init__.py 2022-03-11 12:09:16 UTC (rev 9043)
@@ -29,7 +29,7 @@
class Writer(latex2e.Writer):
"""A writer for Unicode-aware LaTeX variants (XeTeX, LuaTeX)"""
- supported = ('lxtex', 'xetex', 'xelatex', 'luatex', 'lualatex')
+ supported = ('latex', 'tex', 'xetex', 'xelatex', 'luatex', 'lualatex')
"""Formats this writer supports."""
default_template = 'xelatex.tex'
Modified: trunk/docutils/docutils.conf
===================================================================
--- trunk/docutils/docutils.conf 2022-03-11 12:08:58 UTC (rev 9042)
+++ trunk/docutils/docutils.conf 2022-03-11 12:09:16 UTC (rev 9043)
@@ -16,6 +16,7 @@
stylesheet-dirs: docutils/writers/html5_polyglot/
stylesheet-path: minimal.css, responsive.css
section-self-link: yes
+table-style: colwidths-grid
# Prevent tools/buildhtml.py from processing certain text files.
[buildhtml application]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-03-13 18:04:08
|
Revision: 9045
http://sourceforge.net/p/docutils/code/9045
Author: milde
Date: 2022-03-13 18:04:05 +0000 (Sun, 13 Mar 2022)
Log Message:
-----------
Update PEP base URL and template.
The canonical PEP base URL changed to "peps.python.org/".
The PEP-writer template.txt added a "source" link that no longer
works due to sources now only be stored on github and having
two possible file extensions ("txt" or "rst").
Adapt the header to resemble the header of official PEP documents
(which are now produced using Sphinx).
Fixes [bug:#445].
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docutils/parsers/rst/__init__.py
trunk/docutils/docutils/writers/pep_html/template.txt
trunk/docutils/test/functional/expected/latex_literal_block.tex
trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex
trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex
trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/pep_html.html
trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/test_parsers/test_rst/test_interpreted.py
trunk/docutils/test/test_readers/test_pep/test_inline_markup.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/HISTORY.txt 2022-03-13 18:04:05 UTC (rev 9045)
@@ -45,7 +45,8 @@
* docutils/parsers/rst/__init__.py
- - use "https:" scheme in PEP and RFC base link defaults.
+ - Update PEP base URL (fixes bug #445),
+ use "https:" scheme in RFC base URL.
- Add `reporter` to `Directive` class attributes.
* docutils/parsers/rst/directives/__init__.py
@@ -62,9 +63,9 @@
* docutils/utils/__init__.py
- - decode_path() returns `str` instance instead of `nodes.reprunicode`.
- - new function error_string() obsoletes utils.error_reporting.ErrorString.
- - class ErrorOutput moved here from docutils/utils/error_reporting.py
+ - `decode_path()` returns `str` instance instead of `nodes.reprunicode`.
+ - New function error_string() obsoletes utils.error_reporting.ErrorString.
+ - Class `ErrorOutput` moved here from docutils/utils/error_reporting.py
* docutils/utils/error_reporting.py
@@ -77,12 +78,13 @@
* docutils/writers/pep_html/
- - use "https:" scheme in "python_home" URL default.
+ - Use "https:" scheme in "python_home" URL default.
+ - Fix links in template.txt.
* test/DocutilsTestSupport.py
- - exception_data() now returns None if no exception was raised.
- - recommonmark_wrapper only imported if upstream parser is present.
+ - `exception_data()` now returns None if no exception was raised.
+ - `recommonmark_wrapper` only imported if upstream parser is present.
* test/test_parsers/test_rst/test_directives/test_tables.py
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/RELEASE-NOTES.txt 2022-03-13 18:04:05 UTC (rev 9045)
@@ -102,6 +102,8 @@
* The default values for the "pep-references", "rfc-base-url",
and "python-home" `configuration settings`_ now uses the "https:" scheme.
+ The PEP-writer template's header is updated to fix links and
+ resemble the header of official PEPs.
.. _configuration settings: docs/user/config.html
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/docs/user/config.txt 2022-03-13 18:04:05 UTC (rev 9045)
@@ -695,7 +695,7 @@
~~~~~~~~~~~~
Base URL for PEP references.
-Default: "https://www.python.org/dev/peps/".
+Default: "https://peps.python.org/".
Option: ``--pep-base-url``.
pep_file_url_template
Modified: trunk/docutils/docutils/parsers/rst/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/__init__.py 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/docutils/parsers/rst/__init__.py 2022-03-13 18:04:05 UTC (rev 9045)
@@ -91,9 +91,9 @@
['--pep-references'],
{'action': 'store_true', 'validator': frontend.validate_boolean}),
('Base URL for PEP references '
- '(default "https://www.python.org/dev/peps/").',
+ '(default "https://peps.python.org/").',
['--pep-base-url'],
- {'metavar': '<URL>', 'default': 'https://www.python.org/dev/peps/',
+ {'metavar': '<URL>', 'default': 'https://peps.python.org/',
'validator': frontend.validate_url_trailing_slash}),
('Template for PEP file part of URL. (default "pep-%04d")',
['--pep-file-url-template'],
Modified: trunk/docutils/docutils/writers/pep_html/template.txt
===================================================================
--- trunk/docutils/docutils/writers/pep_html/template.txt 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/docutils/writers/pep_html/template.txt 2022-03-13 18:04:05 UTC (rev 9045)
@@ -3,27 +3,23 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
This HTML is auto-generated. DO NOT EDIT THIS FILE! If you are writing a new
-PEP, see http://www.python.org/dev/peps/pep-0001 for instructions and links
+PEP, see http://peps.python.org/pep-0001 for instructions and links
to templates. DO NOT USE THIS HTML FILE AS YOUR TEMPLATE!
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=%(encoding)s" />
<meta name="generator" content="Docutils %(version)s: https://docutils.sourceforge.io/" />
- <title>PEP %(pep)s -- %(title)s</title>
+ <title>PEP %(pep)s - %(title)s</title>
%(stylesheet)s
</head>
<body bgcolor="white">
-<table class="navigation" cellpadding="0" cellspacing="0"
- width="100%%" border="0">
-<tr><td class="navicon" width="150" height="35">
-<a href="%(pyhome)s/" title="Python Home Page">
-<img src="%(pyhome)s/pics/PyBanner%(banner)03d.gif" alt="[Python]"
- border="0" width="150" height="35" /></a></td>
-<td class="textlinks" align="left">
-[<b><a href="%(pyhome)s/">Python Home</a></b>]
-[<b><a href="%(pepindex)s/">PEP Index</a></b>]
-[<b><a href="%(pephome)s/pep-%(pepnum)s.txt">PEP Source</a></b>]
-</td></tr></table>
+<div class="header">
+<strong>Python Enhancement Proposals</strong>
+| <a href="%(pyhome)s/">Python</a>
+» <a href="https://peps.python.org/pep-0000/">PEP Index</a>
+» PEP %(pep)s – %(title)s
+<hr class="header"/>
+</div>
<div class="document">
%(body)s
%(body_suffix)s
Modified: trunk/docutils/test/functional/expected/latex_literal_block.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block.tex 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/functional/expected/latex_literal_block.tex 2022-03-13 18:04:05 UTC (rev 9045)
@@ -137,7 +137,7 @@
citation~references~(\hyperlink{cit2002}{[CIT2002]}),~and~more.\\
~\\
~~~Here~are~some~explicit~interpreted~text~roles:\\
-a~PEP~reference~(\href{https://www.python.org/dev/peps/pep-0287}{PEP~287}),\\
+a~PEP~reference~(\href{https://peps.python.org/pep-0287}{PEP~287}),\\
an~RFC~reference~(\href{https://tools.ietf.org/html/rfc2822.html}{RFC~2822}),\\
an~abbreviation~(\DUrole{abbreviation}{abb.}),~an~acronym~(\DUrole{acronym}{reST}),\\
code~(\texttt{\DUrole{code}{print~\textquotedbl{}hello~world\textquotedbl{}}}),\\
Modified: trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex 2022-03-13 18:04:05 UTC (rev 9045)
@@ -137,7 +137,7 @@
citation~references~(\hyperlink{cit2002}{[CIT2002]}),~and~more.\\
~\\
~~~Here~are~some~explicit~interpreted~text~roles:\\
-a~PEP~reference~(\href{https://www.python.org/dev/peps/pep-0287}{PEP~287}),\\
+a~PEP~reference~(\href{https://peps.python.org/pep-0287}{PEP~287}),\\
an~RFC~reference~(\href{https://tools.ietf.org/html/rfc2822.html}{RFC~2822}),\\
an~abbreviation~(\DUrole{abbreviation}{abb.}),~an~acronym~(\DUrole{acronym}{reST}),\\
code~(\texttt{\DUrole{code}{print~\textquotedbl{}hello~world\textquotedbl{}}}),\\
Modified: trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_listings.tex 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/functional/expected/latex_literal_block_listings.tex 2022-03-13 18:04:05 UTC (rev 9045)
@@ -140,7 +140,7 @@
citation~references~(\hyperlink{cit2002}{[CIT2002]}),~and~more.\\
~\\
~~~Here~are~some~explicit~interpreted~text~roles:\\
-a~PEP~reference~(\href{https://www.python.org/dev/peps/pep-0287}{PEP~287}),\\
+a~PEP~reference~(\href{https://peps.python.org/pep-0287}{PEP~287}),\\
an~RFC~reference~(\href{https://tools.ietf.org/html/rfc2822.html}{RFC~2822}),\\
an~abbreviation~(\DUrole{abbreviation}{abb.}),~an~acronym~(\DUrole{acronym}{reST}),\\
code~(\texttt{\DUrole{code}{print~\textquotedbl{}hello~world\textquotedbl{}}}),\\
Modified: trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex 2022-03-13 18:04:05 UTC (rev 9045)
@@ -136,7 +136,7 @@
citation~references~(\hyperlink{cit2002}{[CIT2002]}),~and~more.\\
~\\
~~~Here~are~some~explicit~interpreted~text~roles:\\
-a~PEP~reference~(\href{https://www.python.org/dev/peps/pep-0287}{PEP~287}),\\
+a~PEP~reference~(\href{https://peps.python.org/pep-0287}{PEP~287}),\\
an~RFC~reference~(\href{https://tools.ietf.org/html/rfc2822.html}{RFC~2822}),\\
an~abbreviation~(\DUrole{abbreviation}{abb.}),~an~acronym~(\DUrole{acronym}{reST}),\\
code~(\texttt{\DUrole{code}{print~\textquotedbl{}hello~world\textquotedbl{}}}),\\
Modified: trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex 2022-03-13 18:04:05 UTC (rev 9045)
@@ -137,7 +137,7 @@
citation~references~(\hyperlink{cit2002}{[CIT2002]}),~and~more.\\
~\\
~~~Here~are~some~explicit~interpreted~text~roles:\\
-a~PEP~reference~(\href{https://www.python.org/dev/peps/pep-0287}{PEP~287}),\\
+a~PEP~reference~(\href{https://peps.python.org/pep-0287}{PEP~287}),\\
an~RFC~reference~(\href{https://tools.ietf.org/html/rfc2822.html}{RFC~2822}),\\
an~abbreviation~(\DUrole{abbreviation}{abb.}),~an~acronym~(\DUrole{acronym}{reST}),\\
code~(\texttt{\DUrole{code}{print~\textquotedbl{}hello~world\textquotedbl{}}}),\\
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2022-03-13 18:04:05 UTC (rev 9045)
@@ -345,7 +345,7 @@
reference to the \hyperref[doctitle]{doctitle} and the \hyperref[subtitle]{subtitle}.
The default role for interpreted text is \DUroletitlereference{Title Reference}. Here are
-some explicit interpreted text roles: a PEP reference (\href{https://www.python.org/dev/peps/pep-0287}{PEP 287}); an
+some explicit interpreted text roles: a PEP reference (\href{https://peps.python.org/pep-0287}{PEP 287}); an
RFC reference (\href{https://tools.ietf.org/html/rfc2822.html}{RFC 2822}); an abbreviation (\DUrole{abbreviation}{abb.}), an acronym
(\DUrole{acronym}{reST}), code (\texttt{\DUrole{code}{print \textquotedbl{}hello world\textquotedbl{}}}); a \textsubscript{subscript};
a \textsuperscript{superscript} and explicit roles for \DUroletitlereference{Docutils}'
Modified: trunk/docutils/test/functional/expected/pep_html.html
===================================================================
--- trunk/docutils/test/functional/expected/pep_html.html 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/functional/expected/pep_html.html 2022-03-13 18:04:05 UTC (rev 9045)
@@ -3,27 +3,23 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
This HTML is auto-generated. DO NOT EDIT THIS FILE! If you are writing a new
-PEP, see http://www.python.org/dev/peps/pep-0001 for instructions and links
+PEP, see http://peps.python.org/pep-0001 for instructions and links
to templates. DO NOT USE THIS HTML FILE AS YOUR TEMPLATE!
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.19b.dev: https://docutils.sourceforge.io/" />
- <title>PEP 100 -- Test PEP</title>
+ <title>PEP 100 - Test PEP</title>
<link rel="stylesheet" href="../input/data/html4css1.css" type="text/css" />
</head>
<body bgcolor="white">
-<table class="navigation" cellpadding="0" cellspacing="0"
- width="100%" border="0">
-<tr><td class="navicon" width="150" height="35">
-<a href="http://www.python.org/" title="Python Home Page">
-<img src="http://www.python.org/pics/PyBanner000.gif" alt="[Python]"
- border="0" width="150" height="35" /></a></td>
-<td class="textlinks" align="left">
-[<b><a href="http://www.python.org/">Python Home</a></b>]
-[<b><a href="http://www.python.org/dev/peps/">PEP Index</a></b>]
-[<b><a href="http://www.python.org/peps/pep-0100.txt">PEP Source</a></b>]
-</td></tr></table>
+<div class="header">
+<strong>Python Enhancement Proposals</strong>
+| <a href="http://www.python.org/">Python</a>
+» <a href="https://peps.python.org/pep-0000/">PEP Index</a>
+» PEP 100 – Test PEP
+<hr class="header"/>
+</div>
<div class="document">
<table class="rfc2822 docutils field-list" frame="void" rules="none">
<col class="field-name" />
@@ -45,7 +41,7 @@
</tr>
<tr class="field"><th class="field-name">Type:</th><td class="field-body">Standards Track</td>
</tr>
-<tr class="field"><th class="field-name">Content-Type:</th><td class="field-body"><a class="reference external" href="https://www.python.org/dev/peps/pep-0012">text/x-rst</a></td>
+<tr class="field"><th class="field-name">Content-Type:</th><td class="field-body"><a class="reference external" href="https://peps.python.org/pep-0012">text/x-rst</a></td>
</tr>
<tr class="field"><th class="field-name">Created:</th><td class="field-body">01-Jun-2001</td>
</tr>
Modified: trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2022-03-13 18:04:05 UTC (rev 9045)
@@ -255,7 +255,7 @@
<target anonymous="1" ids="target-1" refuri="http://www.python.org/"></target>
<target anonymous="1" ids="target-2" refuri="https://docutils.sourceforge.io/"></target>
<paragraph>The default role for interpreted text is <title_reference>Title Reference</title_reference>. Here are
- some explicit interpreted text roles: a PEP reference (<reference refuri="https://www.python.org/dev/peps/pep-0287">PEP 287</reference>); an
+ some explicit interpreted text roles: a PEP reference (<reference refuri="https://peps.python.org/pep-0287">PEP 287</reference>); an
RFC reference (<reference refuri="https://tools.ietf.org/html/rfc2822.html">RFC 2822</reference>); an abbreviation (<abbreviation>abb.</abbreviation>), an acronym
(<acronym>reST</acronym>), code (<literal classes="code">print "hello world"</literal>); a <subscript>subscript</subscript>;
a <superscript>superscript</superscript> and explicit roles for <title_reference>Docutils</title_reference>'
Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2022-03-13 18:04:05 UTC (rev 9045)
@@ -185,7 +185,7 @@
(generated by processing errors; this one is intentional). Here is a
reference to the <a class="reference internal" href="#doctitle">doctitle</a> and the <a class="reference internal" href="#subtitle">subtitle</a>.</p>
<p>The default role for interpreted text is <cite>Title Reference</cite>. Here are
-some explicit interpreted text roles: a PEP reference (<a class="reference external" href="https://www.python.org/dev/peps/pep-0287">PEP 287</a>); an
+some explicit interpreted text roles: a PEP reference (<a class="reference external" href="https://peps.python.org/pep-0287">PEP 287</a>); an
RFC reference (<a class="reference external" href="https://tools.ietf.org/html/rfc2822.html">RFC 2822</a>); an abbreviation (<abbr>abb.</abbr>), an acronym
(<acronym>reST</acronym>), code (<code>print "hello world"</code>); a <sub>subscript</sub>;
a <sup>superscript</sup> and explicit roles for <cite>Docutils</cite>'
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2022-03-13 18:04:05 UTC (rev 9045)
@@ -203,7 +203,7 @@
(generated by processing errors; this one is intentional). Here is a
reference to the <a class="reference internal" href="#doctitle">doctitle</a> and the <a class="reference internal" href="#subtitle">subtitle</a>.</p>
<p>The default role for interpreted text is <cite>Title Reference</cite>. Here are
-some explicit interpreted text roles: a PEP reference (<a class="reference external" href="https://www.python.org/dev/peps/pep-0287">PEP 287</a>); an
+some explicit interpreted text roles: a PEP reference (<a class="reference external" href="https://peps.python.org/pep-0287">PEP 287</a>); an
RFC reference (<a class="reference external" href="https://tools.ietf.org/html/rfc2822.html">RFC 2822</a>); an abbreviation (<abbr>abb.</abbr>), an acronym
(<abbr>reST</abbr>), code (<code>print "hello world"</code>); a <sub>subscript</sub>;
a <sup>superscript</sup> and explicit roles for <cite>Docutils</cite>'
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2022-03-13 18:04:05 UTC (rev 9045)
@@ -346,7 +346,7 @@
reference to the \hyperref[doctitle]{doctitle} and the \hyperref[subtitle]{subtitle}.
The default role for interpreted text is \DUroletitlereference{Title Reference}. Here are
-some explicit interpreted text roles: a PEP reference (\href{https://www.python.org/dev/peps/pep-0287}{PEP 287}); an
+some explicit interpreted text roles: a PEP reference (\href{https://peps.python.org/pep-0287}{PEP 287}); an
RFC reference (\href{https://tools.ietf.org/html/rfc2822.html}{RFC 2822}); an abbreviation (\DUrole{abbreviation}{abb.}), an acronym
(\DUrole{acronym}{reST}), code (\texttt{\DUrole{code}{print \textquotedbl{}hello world\textquotedbl{}}}); a \textsubscript{subscript};
a \textsuperscript{superscript} and explicit roles for \DUroletitlereference{Docutils}’
Modified: trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2022-03-13 18:04:05 UTC (rev 9045)
@@ -505,7 +505,7 @@
Title Reference
. Here are
some explicit interpreted text roles: a PEP reference (
- <reference refuri="https://www.python.org/dev/peps/pep-0287">
+ <reference refuri="https://peps.python.org/pep-0287">
PEP 287
); an
RFC reference (
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2022-03-13 18:04:05 UTC (rev 9045)
@@ -347,7 +347,7 @@
reference to the \hyperref[doctitle]{doctitle} and the \hyperref[subtitle]{subtitle}.
The default role for interpreted text is \DUroletitlereference{Title Reference}. Here are
-some explicit interpreted text roles: a PEP reference (\href{https://www.python.org/dev/peps/pep-0287}{PEP 287}); an
+some explicit interpreted text roles: a PEP reference (\href{https://peps.python.org/pep-0287}{PEP 287}); an
RFC reference (\href{https://tools.ietf.org/html/rfc2822.html}{RFC 2822}); an abbreviation (\DUrole{abbreviation}{abb.}), an acronym
(\DUrole{acronym}{reST}), code (\texttt{\DUrole{code}{print \textquotedbl{}hello world\textquotedbl{}}}); a \textsubscript{subscript};
a \textsuperscript{superscript} and explicit roles for \DUroletitlereference{Docutils}’
Modified: trunk/docutils/test/test_parsers/test_rst/test_interpreted.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_interpreted.py 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/test_parsers/test_rst/test_interpreted.py 2022-03-13 18:04:05 UTC (rev 9045)
@@ -302,7 +302,7 @@
"""\
<document source="test data">
<paragraph>
- <reference refuri="https://www.python.org/dev/peps/pep-0000">
+ <reference refuri="https://peps.python.org/pep-0000">
PEP 0
"""],
["""\
Modified: trunk/docutils/test/test_readers/test_pep/test_inline_markup.py
===================================================================
--- trunk/docutils/test/test_readers/test_pep/test_inline_markup.py 2022-03-13 18:03:45 UTC (rev 9044)
+++ trunk/docutils/test/test_readers/test_pep/test_inline_markup.py 2022-03-13 18:04:05 UTC (rev 9045)
@@ -30,10 +30,10 @@
<document source="test data">
<paragraph>
See \n\
- <reference refuri="https://www.python.org/dev/peps/pep-0287">
+ <reference refuri="https://peps.python.org/pep-0287">
PEP 287
(
- <reference refuri="https://www.python.org/dev/peps/pep-0287">
+ <reference refuri="https://peps.python.org/pep-0287">
pep-0287.txt
),
and \n\
@@ -61,7 +61,7 @@
<paragraph>
References split across lines:
<paragraph>
- <reference refuri="https://www.python.org/dev/peps/pep-0287">
+ <reference refuri="https://peps.python.org/pep-0287">
PEP
287
<paragraph>
@@ -72,7 +72,7 @@
["""\
Test PEP-specific implicit references before a URL:
-PEP 287 (https://www.python.org/dev/peps/pep-0287), RFC 2822.
+PEP 287 (https://peps.python.org/pep-0287), RFC 2822.
""",
"""\
<document source="test data">
@@ -79,11 +79,11 @@
<paragraph>
Test PEP-specific implicit references before a URL:
<paragraph>
- <reference refuri="https://www.python.org/dev/peps/pep-0287">
+ <reference refuri="https://peps.python.org/pep-0287">
PEP 287
(
- <reference refuri="https://www.python.org/dev/peps/pep-0287">
- https://www.python.org/dev/peps/pep-0287
+ <reference refuri="https://peps.python.org/pep-0287">
+ https://peps.python.org/pep-0287
), \n\
<reference refuri="https://tools.ietf.org/html/rfc2822.html">
RFC 2822
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-03-17 13:40:14
|
Revision: 9047
http://sourceforge.net/p/docutils/code/9047
Author: milde
Date: 2022-03-17 13:40:11 +0000 (Thu, 17 Mar 2022)
Log Message:
-----------
Prepare switch from optparse to argparse.
New interface function: frontend.get_default_settings()
easy access to default settings for programmatic use.
Add deprecation warnings.
Catch them when accessing the deprecated functions from Docutils.
Make docstrings conform to the Documentation Policies
(first line: summary, next line empty).
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/core.py
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_language.py
trunk/docutils/test/test_parsers/test_parser.py
trunk/docutils/test/test_settings.py
trunk/docutils/tools/quicktest.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-03-17 13:12:22 UTC (rev 9046)
+++ trunk/docutils/HISTORY.txt 2022-03-17 13:40:11 UTC (rev 9047)
@@ -135,6 +135,7 @@
* docutils/frontend.py
- mark as provisional (will switch from using "optparse" to "argparse").
- remove hack for the now obsolete "mod_python" Apache module.
+ - new function get_default_settings()
* docutils/nodes.py
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2022-03-17 13:12:22 UTC (rev 9046)
+++ trunk/docutils/docutils/core.py 2022-03-17 13:40:11 UTC (rev 9047)
@@ -18,6 +18,7 @@
import pprint
import os
import sys
+import warnings
from docutils import (__version__, __version_details__, SettingsSpec,
io, utils, readers, writers)
@@ -102,6 +103,9 @@
def setup_option_parser(self, usage=None, description=None,
settings_spec=None, config_section=None,
**defaults):
+ warnings.warn('Publisher.setup_option_parser is deprecated, '
+ 'and will be removed in Docutils 0.21.',
+ DeprecationWarning, stacklevel=2)
if config_section:
if not settings_spec:
settings_spec = SettingsSpec()
@@ -110,22 +114,32 @@
if len(parts) > 1 and parts[-1] == 'application':
settings_spec.config_section_dependencies = ['applications']
# @@@ Add self.source & self.destination to components in future?
- option_parser = OptionParser(
+ return OptionParser(
components=(self.parser, self.reader, self.writer, settings_spec),
defaults=defaults, read_config_files=True,
usage=usage, description=description)
- return option_parser
+ def _setup_settings_parser(self, *args, **kwargs):
+ # Provisional: will change (docutils.frontend.OptionParser will
+ # be replaced by a parser based on arparse.ArgumentParser)
+ # and may be removed later.
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore', category=DeprecationWarning)
+ return self.setup_option_parser(*args, **kwargs)
+
def get_settings(self, usage=None, description=None,
settings_spec=None, config_section=None, **defaults):
"""
- Set and return default settings (overrides in `defaults` dict).
+ Return settings from components and config files.
- Set components first (`self.set_reader` & `self.set_writer`).
- Explicitly setting `self.settings` disables command line option
- processing from `self.publish()`.
+ Please set components first (`self.set_reader` & `self.set_writer`).
+ Use keyword arguments to override component defaults
+ (before updating from configuration files).
+
+ Calling this function also sets `self.settings` which makes
+ `self.publish()` skip parsing command line options.
"""
- option_parser = self.setup_option_parser(
+ option_parser = self._setup_settings_parser(
usage, description, settings_spec, config_section, **defaults)
self.settings = option_parser.get_default_values()
return self.settings
@@ -145,7 +159,7 @@
settings_spec=None, config_section=None,
**defaults):
"""
- Set parse command line arguments and set ``self.settings``.
+ Parse command line arguments and set ``self.settings``.
Pass an empty sequence to `argv` to avoid reading `sys.argv`
(the default behaviour).
@@ -152,7 +166,7 @@
Set components first (`self.set_reader` & `self.set_writer`).
"""
- option_parser = self.setup_option_parser(
+ option_parser = self._setup_settings_parser(
usage, description, settings_spec, config_section, **defaults)
if argv is None:
argv = sys.argv[1:]
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2022-03-17 13:12:22 UTC (rev 9046)
+++ trunk/docutils/docutils/frontend.py 2022-03-17 13:40:11 UTC (rev 9047)
@@ -15,23 +15,39 @@
Exports the following classes:
* `OptionParser`: Standard Docutils command-line processing.
+ Deprecated. Will be replaced by an ArgumentParser.
* `Option`: Customized version of `optparse.Option`; validation support.
+ Deprecated. Will be removed.
* `Values`: Runtime settings; objects are simple structs
(``object.attribute``). Supports cumulative list settings (attributes).
+ Deprecated. Will be removed.
* `ConfigParser`: Standard Docutils config file processing.
+ Provisional. Details will change.
Also exports the following functions:
-* Option callbacks: `store_multiple()`, `read_config_file()`.
-* Setting validators: `validate_encoding()`,
- `validate_encoding_error_handler()`,
+Interface function:
+ `get_default_settings()`. New in 0.19.
+
+Option callbacks:
+ `store_multiple()`, `read_config_file()`. Deprecated.
+
+Setting validators:
+ `validate_encoding()`, `validate_encoding_error_handler()`,
`validate_encoding_and_error_handler()`,
- `validate_boolean()`, `validate_ternary()`, `validate_threshold()`,
+ `validate_boolean()`, `validate_ternary()`,
+ `validate_nonnegative_int()`, `validate_threshold()`,
`validate_colon_separated_string_list()`,
`validate_comma_separated_list()`,
- `validate_dependency_file()`.
-* `make_paths_absolute()`.
-* SettingSpec creation: `filter_settings_spec()`.
+ `validate_url_trailing_slash()`,
+ `validate_dependency_file()`,
+ `validate_strip_class()`
+ `validate_smartquotes_locales()`.
+
+ Provisional.
+
+Misc:
+ `make_paths_absolute()`, `filter_settings_spec()`. Provisional.
"""
__docformat__ = 'reStructuredText'
@@ -47,7 +63,7 @@
import warnings
import docutils
-from docutils import io
+from docutils import io, utils
def store_multiple(option, opt, value, parser, *args, **kwargs):
@@ -207,10 +223,10 @@
def validate_dependency_file(setting, value, option_parser,
config_parser=None, config_section=None):
try:
- return docutils.utils.DependencyList(value)
+ return utils.DependencyList(value)
except OSError:
# TODO: warn/info?
- return docutils.utils.DependencyList(None)
+ return utils.DependencyList(None)
def validate_strip_class(setting, value, option_parser,
@@ -317,17 +333,22 @@
class Values(optparse.Values):
+ """Storage for option values.
- """
Updates list attributes by extension rather than by replacement.
Works in conjunction with the `OptionParser.lists` instance attribute.
+
+ Deprecated. Will be removed.
"""
def __init__(self, *args, **kwargs):
- optparse.Values.__init__(self, *args, **kwargs)
+ warnings.warn('frontend.Values class will be removed '
+ 'in Docutils 0.21 or later.',
+ DeprecationWarning, stacklevel=2)
+ super().__init__(*args, **kwargs)
if getattr(self, 'record_dependencies', None) is None:
# Set up dummy dependency list.
- self.record_dependencies = docutils.utils.DependencyList()
+ self.record_dependencies = utils.DependencyList()
def update(self, other_dict, option_parser):
if isinstance(other_dict, Values):
@@ -354,9 +375,19 @@
class Option(optparse.Option):
+ """Add validation and override support to `optparse.Option`.
+ Deprecated. Will be removed.
+ """
+
ATTRS = optparse.Option.ATTRS + ['validator', 'overrides']
+ def __init__(self, *args, **kwargs):
+ warnings.warn('The frontend.Option class will be removed '
+ 'in Docutils 0.21 or later.',
+ DeprecationWarning, stacklevel=2)
+ super().__init__(*args, **kwargs)
+
def process(self, opt, value, values, parser):
"""
Call the validator function on applicable settings and
@@ -381,15 +412,19 @@
class OptionParser(optparse.OptionParser, docutils.SettingsSpec):
-
"""
- Parser for command-line and library use. The `settings_spec`
- specification here and in other Docutils components are merged to build
- the set of command-line options and runtime settings for this process.
+ Settings parser for command-line and library use.
+ The `settings_spec` specification here and in other Docutils components
+ are merged to build the set of command-line options and runtime settings
+ for this process.
+
Common settings (defined below) and component-specific settings must not
conflict. Short options are reserved for common settings, and components
are restricted to using long options.
+
+ Deprecated.
+ Will be replaced by a subclass of `argparse.ArgumentParser`.
"""
standard_config_files = [
@@ -396,9 +431,11 @@
'/etc/docutils.conf', # system-wide
'./docutils.conf', # project-specific
'~/.docutils'] # user-specific
- """Docutils configuration files, using ConfigParser syntax. Filenames
- will be tilde-expanded later. Later files override earlier ones."""
+ """Docutils configuration files, using ConfigParser syntax.
+ Filenames will be tilde-expanded later. Later files override earlier ones.
+ """
+
threshold_choices = 'info 1 warning 2 error 3 severe 4 none 5'.split()
"""Possible inputs for for --report and --halt threshold values."""
@@ -588,9 +625,10 @@
'_source': None,
'_destination': None,
'_config_files': None}
- """Defaults for settings without command-line option equivalents."""
+ """Defaults for settings without command-line option equivalents.
- relative_path_settings = ('warning_stream',)
+ See https://docutils.sourceforge.io/docs/user/config.html#internal-settings
+ """
config_section = 'general'
@@ -601,12 +639,13 @@
sys.version.split()[0], sys.platform))
"""Default version message."""
- def __init__(self, components=(), defaults=None, read_config_files=None,
+ def __init__(self, components=(), defaults=None, read_config_files=False,
*args, **kwargs):
- """
+ """Set up OptionParser instance.
+
`components` is a list of Docutils components each containing a
- ``.settings_spec`` attribute. `defaults` is a mapping of setting
- default overrides.
+ ``.settings_spec`` attribute.
+ `defaults` is a mapping of setting default overrides.
"""
self.lists = {}
@@ -615,14 +654,17 @@
self.config_files = []
"""List of paths of applied configuration files."""
- optparse.OptionParser.__init__(
- self, option_class=Option, add_help_option=None,
- formatter=optparse.TitledHelpFormatter(width=78),
- *args, **kwargs)
+ self.relative_path_settings = ['warning_stream'] # will be modified
+
+ warnings.warn('The frontend.OptionParser class will be replaced '
+ 'by a subclass of argparse.ArgumentParser '
+ 'in Docutils 0.21 or later.',
+ DeprecationWarning, stacklevel=2)
+ super().__init__(option_class=Option, add_help_option=None,
+ formatter=optparse.TitledHelpFormatter(width=78),
+ *args, **kwargs)
if not self.version:
self.version = self.version_template
- # Make an instance copy (it will be modified):
- self.relative_path_settings = list(self.relative_path_settings)
self.components = (self, *components)
self.populate_from_components(self.components)
self.defaults.update(defaults or {})
@@ -668,14 +710,16 @@
@classmethod
def get_standard_config_files(cls):
"""Return list of config files, from environment or standard."""
- try:
+ if 'DOCUTILSCONFIG' in os.environ:
config_files = os.environ['DOCUTILSCONFIG'].split(os.pathsep)
- except KeyError:
+ else:
config_files = cls.standard_config_files
return [os.path.expanduser(f) for f in config_files if f.strip()]
def get_standard_config_settings(self):
- settings = Values()
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore', category=DeprecationWarning)
+ settings = Values()
for filename in self.get_standard_config_files():
settings.update(self.get_config_file_settings(filename), self)
return settings
@@ -683,11 +727,12 @@
def get_config_file_settings(self, config_file):
"""Returns a dictionary containing appropriate config file settings."""
config_parser = ConfigParser()
- # parse config file, add filename if found and successfull read.
- self.config_files += config_parser.read(config_file, self)
- base_path = os.path.dirname(config_file)
+ # parse config file, add filename if found and successfully read.
applied = set()
- settings = Values()
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore', category=DeprecationWarning)
+ self.config_files += config_parser.read(config_file, self)
+ settings = Values()
for component in self.components:
if not component:
continue
@@ -696,9 +741,11 @@
if section in applied:
continue
applied.add(section)
- settings.update(config_parser.get_section(section), self)
- make_paths_absolute(
- settings.__dict__, self.relative_path_settings, base_path)
+ if config_parser.has_section(section):
+ settings.update(config_parser[section], self)
+ make_paths_absolute(settings.__dict__,
+ self.relative_path_settings,
+ os.path.dirname(config_file))
return settings.__dict__
def check_values(self, values, args):
@@ -731,7 +778,9 @@
def get_default_values(self):
"""Needed to get custom `Values` instances."""
- defaults = Values(self.defaults)
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore', category=DeprecationWarning)
+ defaults = Values(self.defaults)
defaults._config_files = self.config_files
return defaults
@@ -792,7 +841,7 @@
warnings.warn('frontend.ConfigParser.read(): parameter '
'"option_parser" will be removed '
'in Docutils 0.21 or later.',
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
read_ok = []
if isinstance(filenames, str):
filenames = [filenames]
@@ -845,12 +894,10 @@
setting, value, option_parser,
config_parser=self, config_section=section)
except Exception as err:
- raise ValueError(
- 'Error in config file "%s", section "[%s]":\n'
- ' %s\n'
- ' %s = %s'
- % (filename, section, io.error_string(err),
- setting, value))
+ raise ValueError(f'Error in config file "{filename}", '
+ f'section "[{section}]":\n'
+ f' {io.error_string(err)}\n'
+ f' {setting} = {value}')
self.set(section, setting, new_value)
if option.overrides:
self.set(section, option.overrides, None)
@@ -873,8 +920,8 @@
catch KeyError.
"""
warnings.warn('frontend.OptionParser.get_section() '
- 'will be removed in Docutils 0.22 or later.',
- PendingDeprecationWarning, stacklevel=2)
+ 'will be removed in Docutils 0.21 or later.',
+ DeprecationWarning, stacklevel=2)
try:
return dict(self[section])
except KeyError:
@@ -883,3 +930,19 @@
class ConfigDeprecationWarning(FutureWarning):
"""Warning for deprecated configuration file features."""
+
+
+def get_default_settings(*components):
+ """Return default runtime settings for `components`.
+
+ Return a `frontend.Values` instance with defaults for generic Docutils
+ settings and settings from the `components` (`SettingsSpec` instances).
+
+ This corresponds to steps 1 and 2 in the `runtime settings priority`__.
+
+ __ https://docutils.sourceforge.io/docs/api/runtime-settings.html
+ #settings-priority
+ """
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore', category=DeprecationWarning)
+ return OptionParser(components).get_default_values()
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2022-03-17 13:12:22 UTC (rev 9046)
+++ trunk/docutils/docutils/utils/__init__.py 2022-03-17 13:40:11 UTC (rev 9047)
@@ -18,7 +18,8 @@
from docutils import ApplicationError, DataError, __version_info__
from docutils import io, nodes
-from docutils.nodes import unescape # noqa: F401 backwards compatibility
+# for backwards compatibility
+from docutils.nodes import unescape # noqa: F401
class SystemMessage(ApplicationError):
@@ -436,17 +437,26 @@
`settings` : optparse.Values object
Runtime settings. If none are provided, a default core set will
be used. If you will use the document object with any Docutils
- components, you must provide their default settings as well. For
- example, if parsing rST, at least provide the rst-parser settings,
- obtainable as follows::
+ components, you must provide their default settings as well.
- settings = docutils.frontend.OptionParser(
- components=(docutils.parsers.rst.Parser,)
- ).get_default_values()
+ For example, if parsing rST, at least provide the rst-parser
+ settings, obtainable as follows:
+
+ Defaults for parser component::
+
+ settings = docutils.frontend.get_default_settings(
+ docutils.parsers.rst.Parser)
+
+ Defaults and configuration file customizations::
+
+ settings = docutils.core.Publisher(
+ parser=docutils.parsers.rst.Parser).get_settings()
+
"""
+ # Import at top of module would lead to circular dependency!
from docutils import frontend
if settings is None:
- settings = frontend.OptionParser().get_default_values()
+ settings = frontend.get_default_settings()
source_path = decode_path(source_path)
reporter = new_reporter(source_path, settings)
document = nodes.document(settings, reporter, source=source_path)
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2022-03-17 13:12:22 UTC (rev 9046)
+++ trunk/docutils/test/DocutilsTestSupport.py 2022-03-17 13:40:11 UTC (rev 9047)
@@ -311,8 +311,7 @@
cases that have nothing to do with the input and output of the transform.
"""
- option_parser = frontend.OptionParser(components=(rst.Parser,))
- settings = option_parser.get_default_values()
+ settings = frontend.get_default_settings(rst.Parser)
settings.report_level = 1
settings.halt_level = 5
settings.debug = package_unittest.debug
@@ -433,8 +432,7 @@
parser = rst.Parser()
"""Parser shared by all ParserTestCases."""
- option_parser = frontend.OptionParser(components=(rst.Parser,))
- settings = option_parser.get_default_values()
+ settings = frontend.get_default_settings(rst.Parser)
settings.report_level = 5
settings.halt_level = 5
settings.debug = package_unittest.debug
@@ -495,8 +493,7 @@
parser = rst.Parser(rfc2822=True, inliner=rst.states.Inliner())
"""Parser shared by all PEPParserTestCases."""
- option_parser = frontend.OptionParser(components=(rst.Parser, pep.Reader))
- settings = option_parser.get_default_values()
+ settings = frontend.get_default_settings(rst.Parser, pep.Reader)
settings.report_level = 5
settings.halt_level = 5
settings.debug = package_unittest.debug
@@ -536,8 +533,7 @@
if md_parser_class:
parser = md_parser_class()
- option_parser = frontend.OptionParser(components=(md_parser_class,))
- settings = option_parser.get_default_values()
+ settings = frontend.get_default_settings(md_parser_class)
settings.report_level = 5
settings.halt_level = 5
settings.debug = package_unittest.debug
Modified: trunk/docutils/test/test_error_reporting.py
===================================================================
--- trunk/docutils/test/test_error_reporting.py 2022-03-17 13:12:22 UTC (rev 9046)
+++ trunk/docutils/test/test_error_reporting.py 2022-03-17 13:40:11 UTC (rev 9047)
@@ -32,10 +32,9 @@
from docutils import frontend, utils
import docutils.parsers.rst
-from docutils.utils.error_reporting import SafeString, ErrorString, ErrorOutput
-
warnings.filterwarnings('ignore', category=DeprecationWarning,
- message=r'.*utils\.error_reporting')
+ module='.*error_reporting')
+from docutils.utils.error_reporting import SafeString, ErrorString, ErrorOutput # noqa: E402, E501
class SafeStringTests(unittest.TestCase):
@@ -241,8 +240,7 @@
parser = docutils.parsers.rst.Parser()
"""Parser shared by all ParserTestCases."""
- option_parser = frontend.OptionParser(components=(parser,))
- settings = option_parser.get_default_values()
+ settings = frontend.get_default_settings(parser)
settings.report_level = 1
settings.halt_level = 1
settings.warning_stream = ''
Modified: trunk/docutils/test/test_language.py
===================================================================
--- trunk/docutils/test/test_language.py 2022-03-17 13:12:22 UTC (rev 9046)
+++ trunk/docutils/test/test_language.py 2022-03-17 13:40:11 UTC (rev 9047)
@@ -23,7 +23,7 @@
import docutils.utils
import docutils.frontend
-_settings = docutils.frontend.OptionParser().get_default_values()
+_settings = docutils.frontend.get_default_settings()
_reporter = docutils.utils.new_reporter('', _settings)
reference_language = 'en'
Modified: trunk/docutils/test/test_parsers/test_parser.py
===================================================================
--- trunk/docutils/test/test_parsers/test_parser.py 2022-03-17 13:12:22 UTC (rev 9046)
+++ trunk/docutils/test/test_parsers/test_parser.py 2022-03-17 13:40:11 UTC (rev 9047)
@@ -17,8 +17,8 @@
def test_inputrestrictions(self):
parser_class = parsers.get_parser_class('rst')
parser = parser_class()
- document = utils.new_document('test data', frontend.OptionParser(
- components=(parser, )).get_default_values())
+ document = utils.new_document('test data',
+ frontend.get_default_settings(parser))
# input must be unicode at all times
self.assertRaises(TypeError, parser.parse, b'hol', document)
Modified: trunk/docutils/test/test_settings.py
===================================================================
--- trunk/docutils/test/test_settings.py 2022-03-17 13:12:22 UTC (rev 9046)
+++ trunk/docutils/test/test_settings.py 2022-03-17 13:40:11 UTC (rev 9047)
@@ -108,10 +108,9 @@
"""Comparison method shared by all tests."""
def setUp(self):
- warnings.filterwarnings(action='ignore',
+ warnings.filterwarnings('ignore',
category=frontend.ConfigDeprecationWarning)
- warnings.filterwarnings(action='ignore', module='docutils.frontend',
- category=PendingDeprecationWarning)
+ warnings.filterwarnings('ignore', category=DeprecationWarning)
self.option_parser = frontend.OptionParser(
components=(pep_html.Writer, rst.Parser), read_config_files=None)
@@ -357,5 +356,6 @@
reporter.set_conditions('foo', 1, 4) # trigger warning
+
if __name__ == '__main__':
unittest.main()
Modified: trunk/docutils/tools/quicktest.py
===================================================================
--- trunk/docutils/tools/quicktest.py 2022-03-17 13:12:22 UTC (rev 9046)
+++ trunk/docutils/tools/quicktest.py 2022-03-17 13:40:11 UTC (rev 9047)
@@ -15,7 +15,7 @@
import os
import getopt
import docutils
-from docutils.frontend import OptionParser
+from docutils import frontend
from docutils.utils import new_document
from docutils.parsers.rst import Parser
@@ -206,7 +206,7 @@
def main():
# process cmdline arguments:
inputFile, outputFile, outputFormat, optargs = getArgs()
- settings = OptionParser(components=(Parser,)).get_default_values()
+ settings = frontend.get_default_settings(Parser)
settings.debug = optargs['debug']
parser = Parser()
input = inputFile.read()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-03-29 21:50:17
|
Revision: 9048
http://sourceforge.net/p/docutils/code/9048
Author: milde
Date: 2022-03-29 21:50:15 +0000 (Tue, 29 Mar 2022)
Log Message:
-----------
New wrapper module for "CommonMark" parsers.
The parser names 'commonmark' and 'markdown' now
select the first locally installed parser
from a list of compatible 3rd-party parser packages
(pycmark, myst, and recommonmark).
The parsers return slightly different doctrees.
This should not matter for HTML output but leads to false
negatives with the "include" directive test. Therefore the test
case now specifies "recommonmark".
The "pycmark" parser defines transformations to comlete nested parsing
and clean up non-standard nodes. These transformations must also
be run when including a document fragment.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/parsers/__init__.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
Added Paths:
-----------
trunk/docutils/docutils/parsers/commonmark_wrapper.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-03-17 13:40:11 UTC (rev 9047)
+++ trunk/docutils/HISTORY.txt 2022-03-29 21:50:15 UTC (rev 9048)
@@ -28,6 +28,7 @@
* docutils/parsers/__init__.py
+ - Aliases "markdown" and "commonmark" point to "commonmark_wrapper".
- Alias for the "myst" parser (https://pypi.org/project/myst-docutils).
- Use absolute module names in ``_parser_aliases`` instead of two
import attempts. (Keeps details if the `recommonmark_wrapper.py` module
@@ -34,6 +35,11 @@
raises an ImportError.)
- Prepend parser name to ImportError if importing a parser class fails.
+* docutils/parsers/commonmark_wrapper.py
+
+ - New module for parsing CommonMark input. Selects a locally installed
+ 3rd-party parser (pycmark, myst, or recommonmark).
+
* docutils/parsers/recommonmark_wrapper.py
- Raise ImportError, if import of the upstream parser module fails.
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2022-03-17 13:40:11 UTC (rev 9047)
+++ trunk/docutils/RELEASE-NOTES.txt 2022-03-29 21:50:15 UTC (rev 9048)
@@ -95,10 +95,10 @@
Release 0.19b (unpublished)
===========================
-Docutils 0.19 is compatible with Python versions 3.7 and later.
+* Drop support for Python 2.7, 3.5, and 3.6.
-* Support calling the "myst" parser (https://pypi.org/project/myst-docutils)
- from docutils-cli.py_.
+* Support parsing "Markdown" input with 3rd party parsers
+ myst_, pycmark_, or recommonmark_.
* The default values for the "pep-references", "rfc-base-url",
and "python-home" `configuration settings`_ now uses the "https:" scheme.
@@ -105,6 +105,9 @@
The PEP-writer template's header is updated to fix links and
resemble the header of official PEPs.
+.. _myst: https://pypi.org/project/myst-docutils
+.. _pycmark: https://pypi.org/project/pycmark/
+.. _recommonmark: https://pypi.org/project/recommonmark/
.. _configuration settings: docs/user/config.html
Modified: trunk/docutils/docutils/parsers/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/__init__.py 2022-03-17 13:40:11 UTC (rev 9047)
+++ trunk/docutils/docutils/parsers/__init__.py 2022-03-29 21:50:15 UTC (rev 9048)
@@ -76,9 +76,9 @@
'recommonmark': 'docutils.parsers.recommonmark_wrapper',
'myst': 'myst_parser.docutils_',
# 'pycmark': works out of the box
- # TODO: the following two could be either of the above
- 'commonmark': 'docutils.parsers.recommonmark_wrapper',
- 'markdown': 'docutils.parsers.recommonmark_wrapper',
+ # dispatcher for 3rd-party Markdown parsers
+ 'commonmark': 'docutils.parsers.commonmark_wrapper',
+ 'markdown': 'docutils.parsers.commonmark_wrapper',
}
Added: trunk/docutils/docutils/parsers/commonmark_wrapper.py
===================================================================
--- trunk/docutils/docutils/parsers/commonmark_wrapper.py (rev 0)
+++ trunk/docutils/docutils/parsers/commonmark_wrapper.py 2022-03-29 21:50:15 UTC (rev 9048)
@@ -0,0 +1,56 @@
+#! /usr/bin/env python3
+# :Copyright: © 2022 Günter Milde.
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+#
+# Revision: $Revision$
+# Date: $Date$
+"""
+An interface for parsing CommonMark input.
+
+Select a locally installed parser from the following 3rd-party
+parser packages:
+
+:pycmark: https://pypi.org/project/pycmark/
+:myst: https://pypi.org/project/pycmark/
+:recommonmark: https://pypi.org/project/pycmark/ (unmaintained, deprecated)
+
+The first parser class that can be successfully imported is mapped to
+`commonmark_wrapper.Parser`.
+
+This module is provisional:
+the API is not settled and may change with any minor Docutils version.
+"""
+
+import docutils.parsers
+
+
+commonmark_parser_names = ('pycmark', 'myst', 'recommonmark')
+"""Names of compatible drop-in CommonMark parsers"""
+
+Parser = None
+parser_name = ''
+
+for name in commonmark_parser_names:
+ try:
+ Parser = docutils.parsers.get_parser_class(name)
+ except ImportError:
+ continue
+ parser_name = name
+ break
+
+if Parser is None:
+ raise ImportError(
+ 'Parsing "CommonMark" requires one of the packages\n'
+ f'{commonmark_parser_names} available at https://pypi.org')
+
+if parser_name == 'myst':
+ if not Parser.settings_defaults:
+ Parser.settings_defaults = {}
+ Parser.settings_defaults['myst_commonmark_only'] = True
Property changes on: trunk/docutils/docutils/parsers/commonmark_wrapper.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2022-03-17 13:40:11 UTC (rev 9047)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2022-03-29 21:50:15 UTC (rev 9048)
@@ -184,10 +184,13 @@
if 'parser' in self.options:
# parse into a dummy document and return created nodes
- parser = self.options['parser']()
document = utils.new_document(path, self.state.document.settings)
document.include_log = include_log + [(path, clip_options)]
+ parser = self.options['parser']()
parser.parse('\n'.join(include_lines), document)
+ # clean up doctree and complete parsing
+ document.transformer.populate_from_components((parser,))
+ document.transformer.apply_transforms()
return document.children
# Include as rST source:
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2022-03-17 13:40:11 UTC (rev 9047)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2022-03-29 21:50:15 UTC (rev 9048)
@@ -14,9 +14,10 @@
from docutils import parsers
from docutils.utils.code_analyzer import with_pygments
-# check markdown parser availability:
-try:
- md_parser_class = parsers.get_parser_class('markdown')
+# optional 3rd-party markdown parser
+md_parser_name = 'recommonmark'
+try: # check availability
+ md_parser_class = parsers.get_parser_class(md_parser_name)
except ImportError:
md_parser_class = None
@@ -1312,17 +1313,16 @@
Some include text."""],
]
-# Parsing with Markdown (recommonmark) is an optional feature depending
-# on 3rd-party modules:
+# Parsing with Markdown is an optional feature depending on 3rd-party modules:
totest['include-markdown'] = [
-["""\
+[f"""\
Include Markdown source.
-.. include:: %s
- :parser: markdown
+.. include:: {include_md}
+ :parser: {md_parser_name}
A paragraph.
-""" % include_md,
+""",
"""\
<document source="test data">
<paragraph>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-04-29 16:24:21
|
Revision: 9054
http://sourceforge.net/p/docutils/code/9054
Author: milde
Date: 2022-04-29 16:24:18 +0000 (Fri, 29 Apr 2022)
Log Message:
-----------
Small fixes to HTML5 output.
Stop writing an empty line before the "footer" closing tag.
Add space before "charset" meta tag closing sequence.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/test/functional/expected/footnotes_html5.html
trunk/docutils/test/functional/expected/math_output_mathml.html
trunk/docutils/test/functional/expected/misc_rst_html5.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
Added Paths:
-----------
trunk/docutils/test/test_writers/test_html5_template.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-04-14 14:52:57 UTC (rev 9053)
+++ trunk/docutils/HISTORY.txt 2022-04-29 16:24:18 UTC (rev 9054)
@@ -81,7 +81,12 @@
- Add 'html writers' to `config_section_dependencies`. Fixes bug #443.
- Write table column widths with 3 digits precision. Fixes bug #444.
+ - Stop writing an empty line before the "footer" closing tag.
+* docutils/writers/html5_polyglot/__init__.py
+
+ - Add space before "charset" meta tag closing sequence.
+
* docutils/writers/pep_html/
- Use "https:" scheme in "python_home" URL default.
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2022-04-14 14:52:57 UTC (rev 9053)
+++ trunk/docutils/docutils/writers/_html_base.py 2022-04-29 16:24:18 UTC (rev 9054)
@@ -239,7 +239,7 @@
head_prefix_template = ('<html xmlns="http://www.w3.org/1999/xhtml"'
' xml:lang="%(lang)s" lang="%(lang)s">\n<head>\n')
- content_type = '<meta charset="%s"/>\n'
+ content_type = '<meta charset="%s" />\n'
generator = ('<meta name="generator" content="Docutils %s: '
'https://docutils.sourceforge.io/" />\n')
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-04-14 14:52:57 UTC (rev 9053)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-04-29 16:24:18 UTC (rev 9054)
@@ -248,7 +248,7 @@
start = self.context.pop()
footer = [self.starttag(node, 'footer')]
footer.extend(self.body[start:])
- footer.append('\n</footer>\n')
+ footer.append('</footer>\n')
self.footer.extend(footer)
self.body_suffix[:0] = footer
del self.body[start:]
Modified: trunk/docutils/test/functional/expected/footnotes_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/footnotes_html5.html 2022-04-14 14:52:57 UTC (rev 9053)
+++ trunk/docutils/test/functional/expected/footnotes_html5.html 2022-04-29 16:24:18 UTC (rev 9054)
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
-<meta charset="utf-8"/>
+<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="Docutils 0.19b.dev: https://docutils.sourceforge.io/" />
<title>Test footnote and citation rendering</title>
Modified: trunk/docutils/test/functional/expected/math_output_mathml.html
===================================================================
--- trunk/docutils/test/functional/expected/math_output_mathml.html 2022-04-14 14:52:57 UTC (rev 9053)
+++ trunk/docutils/test/functional/expected/math_output_mathml.html 2022-04-29 16:24:18 UTC (rev 9054)
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
-<meta charset="utf-8"/>
+<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="Docutils 0.19b.dev: https://docutils.sourceforge.io/" />
<title>Mathematics</title>
Modified: trunk/docutils/test/functional/expected/misc_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/misc_rst_html5.html 2022-04-14 14:52:57 UTC (rev 9053)
+++ trunk/docutils/test/functional/expected/misc_rst_html5.html 2022-04-29 16:24:18 UTC (rev 9054)
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
-<meta charset="utf-8"/>
+<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="Docutils 0.19b.dev: https://docutils.sourceforge.io/" />
<title>Additional tests with HTML 5</title>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2022-04-14 14:52:57 UTC (rev 9053)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2022-04-29 16:24:18 UTC (rev 9054)
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
-<meta charset="utf-8"/>
+<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="Docutils 0.19b.dev: https://docutils.sourceforge.io/" />
<title>reStructuredText Test Document</title>
@@ -1783,7 +1783,6 @@
<footer>
<p>Document footer</p>
<p><a class="reference external image-reference" href="http://www.w3.org/TR/html5/"><img alt="Conforms to HTML 5" src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" style="width: 88px; height: 31px;" /></a> <a class="reference external image-reference" href="http://validator.w3.org/check?uri=referer"><img alt="Check validity!" src="https://www.w3.org/Icons/ValidatorSuite/vs-blue-190.png" style="width: 88px; height: 31px;" /></a> <a class="reference external image-reference" href="http://jigsaw.w3.org/css-validator/check/referer"><img alt="Valid CSS 2.1!" src="http://jigsaw.w3.org/css-validator/images/vcss" style="width: 88px; height: 31px;" /></a></p>
-
</footer>
</body>
</html>
Modified: trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2022-04-14 14:52:57 UTC (rev 9053)
+++ trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2022-04-29 16:24:18 UTC (rev 9054)
@@ -26,7 +26,7 @@
settings_default_overrides = HtmlWriterPublishPartsTestCase.settings_default_overrides.copy()
settings_default_overrides['section_self_link'] = True
- standard_content_type_template = '<meta charset="%s"/>\n'
+ standard_content_type_template = '<meta charset="%s" />\n'
standard_generator_template = '<meta name="generator"' \
' content="Docutils %s: https://docutils.sourceforge.io/" />\n'
standard_viewport_template = '<meta name="viewport"' \
Added: trunk/docutils/test/test_writers/test_html5_template.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_template.py (rev 0)
+++ trunk/docutils/test/test_writers/test_html5_template.py 2022-04-29 16:24:18 UTC (rev 9054)
@@ -0,0 +1,234 @@
+#!/usr/bin/env python3
+
+# $Id$
+# Author: David Goodger <go...@py...>
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for the HTML writer.
+"""
+
+import os
+import platform
+
+if __name__ == '__main__':
+ import __init__ # noqa: F401
+from test_writers import DocutilsTestSupport
+
+
+def suite():
+ settings = {'template': os.path.join(DocutilsTestSupport.testroot,
+ 'data', 'full-template.txt'),
+ 'stylesheet_path': '/test.css',
+ 'embed_stylesheet': 0}
+ s = DocutilsTestSupport.PublishTestSuite('html5', suite_settings=settings)
+ s.generateTests(totest)
+ return s
+
+
+if platform.system() == "Windows":
+ drive_prefix = os.path.splitdrive(os.getcwd())[0]
+else:
+ drive_prefix = ""
+
+
+totest = {}
+
+totest['template'] = [
+["""\
+================
+ Document Title
+================
+----------
+ Subtitle
+----------
+
+:Author: Me
+
+.. footer:: footer text
+
+Section
+=======
+
+Some text.
+""",
+r'''head_prefix = """\
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>"""
+
+
+head = """\
+<meta charset="utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1" />
+<meta name="generator" content="Docutils %(version)s: https://docutils.sourceforge.io/" />
+<title>Document Title</title>
+<meta name="author" content="Me" />"""
+
+
+stylesheet = """\
+<link rel="stylesheet" href="%(drive)s/test.css" type="text/css" />"""
+
+
+body_prefix = """\
+</head>
+<body>
+<main id="document-title">"""
+
+
+body_pre_docinfo = """\
+<h1 class="title">Document Title</h1>
+<p class="subtitle" id="subtitle">Subtitle</p>"""
+
+
+docinfo = """\
+<dl class="docinfo simple">
+<dt class="author">Author<span class="colon">:</span></dt>
+<dd class="author"><p>Me</p></dd>
+</dl>"""
+
+
+body = """\
+<section id="section">
+<h2>Section</h2>
+<p>Some text.</p>
+</section>"""
+
+
+body_suffix = """\
+</main>
+<footer>
+<p>footer text</p>
+</footer>
+</body>
+</html>"""
+
+
+head_prefix = """\
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>"""
+
+
+head = """\
+<meta charset="utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1" />
+<meta name="generator" content="Docutils %(version)s: https://docutils.sourceforge.io/" />
+<title>Document Title</title>
+<meta name="author" content="Me" />"""
+
+
+stylesheet = """\
+<link rel="stylesheet" href="%(drive)s/test.css" type="text/css" />"""
+
+
+body_prefix = """\
+</head>
+<body>
+<main id="document-title">"""
+
+
+body_pre_docinfo = """\
+<h1 class="title">Document Title</h1>
+<p class="subtitle" id="subtitle">Subtitle</p>"""
+
+
+docinfo = """\
+<dl class="docinfo simple">
+<dt class="author">Author<span class="colon">:</span></dt>
+<dd class="author"><p>Me</p></dd>
+</dl>"""
+
+
+body = """\
+<section id="section">
+<h2>Section</h2>
+<p>Some text.</p>
+</section>"""
+
+
+body_suffix = """\
+</main>
+<footer>
+<p>footer text</p>
+</footer>
+</body>
+</html>"""
+
+
+title = """\
+Document Title"""
+
+
+subtitle = """\
+Subtitle"""
+
+
+header = """\
+"""
+
+
+footer = """\
+<footer>
+<p>footer text</p>
+</footer>"""
+
+
+meta = """\
+<meta charset="utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1" />
+<meta name="generator" content="Docutils %(version)s: https://docutils.sourceforge.io/" />
+<meta name="author" content="Me" />"""
+
+
+fragment = """\
+<section id="section">
+<h2>Section</h2>
+<p>Some text.</p>
+</section>"""
+
+
+html_prolog = """\
+<!DOCTYPE html>"""
+
+
+html_head = """\
+<meta charset="%%s" />
+<meta name="viewport" content="width=device-width, initial-scale=1" />
+<meta name="generator" content="Docutils %(version)s: https://docutils.sourceforge.io/" />
+<title>Document Title</title>
+<meta name="author" content="Me" />"""
+
+
+html_title = """\
+<h1 class="title">Document Title</h1>"""
+
+
+html_subtitle = """\
+<p class="subtitle" id="subtitle">Subtitle</p>"""
+
+
+html_body = """\
+<main id="document-title">
+<h1 class="title">Document Title</h1>
+<p class="subtitle" id="subtitle">Subtitle</p>
+<dl class="docinfo simple">
+<dt class="author">Author<span class="colon">:</span></dt>
+<dd class="author"><p>Me</p></dd>
+</dl>
+<section id="section">
+<h2>Section</h2>
+<p>Some text.</p>
+</section>
+</main>
+<footer>
+<p>footer text</p>
+</footer>"""
+''' % {'version': DocutilsTestSupport.docutils.__version__,
+ 'drive': drive_prefix,
+ }]
+]
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
Property changes on: trunk/docutils/test/test_writers/test_html5_template.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-05-06 10:30:18
|
Revision: 9056
http://sourceforge.net/p/docutils/code/9056
Author: milde
Date: 2022-05-06 10:29:55 +0000 (Fri, 06 May 2022)
Log Message:
-----------
Remove class value "controls" from an `image` node with video content
after converting it to a "control" attribute of the `<video>` tag.
Thanks to Agathe Porte for the hint.
TODO: discuss other special `<video>` attributes.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/test/functional/expected/misc_rst_html5.html
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-04-29 16:24:29 UTC (rev 9055)
+++ trunk/docutils/HISTORY.txt 2022-05-06 10:29:55 UTC (rev 9056)
@@ -86,6 +86,8 @@
* docutils/writers/html5_polyglot/__init__.py
- Add space before "charset" meta tag closing sequence.
+ - Remove class value "controls" from an `image` node with video content
+ after converting it to a "control" attribute of the <video> tag.
* docutils/writers/pep_html/
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-04-29 16:24:29 UTC (rev 9055)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-05-06 10:29:55 UTC (rev 9056)
@@ -284,6 +284,7 @@
atts['class'] = 'align-%s' % node['align']
if 'controls' in node['classes']:
atts['controls'] = 'controls'
+ node['classes'].remove('controls')
atts['title'] = node.get('alt', uri)
if getattr(self.settings, 'image_loading', None) == 'lazy':
atts['loading'] = 'lazy'
Modified: trunk/docutils/test/functional/expected/misc_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/misc_rst_html5.html 2022-04-29 16:24:29 UTC (rev 9055)
+++ trunk/docutils/test/functional/expected/misc_rst_html5.html 2022-05-06 10:29:55 UTC (rev 9056)
@@ -134,7 +134,7 @@
loads. According to the <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video">HTML5 spec</a>, hight and width must be
specified as pixel values.</p>
<figure class="align-center">
-<video class="controls" controls="controls" src="../../../docs/user/rst/images/pens.mp4" title="test video in a figure" width="200">
+<video controls="controls" src="../../../docs/user/rst/images/pens.mp4" title="test video in a figure" width="200">
<a href="../../../docs/user/rst/images/pens.mp4">test video in a figure</a>
</video>
<figcaption>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-05-30 16:54:35
|
Revision: 9060
http://sourceforge.net/p/docutils/code/9060
Author: milde
Date: 2022-05-30 16:54:33 +0000 (Mon, 30 May 2022)
Log Message:
-----------
Command line "entry point" to the docutils package. Part 1/2.
Move the generic command line interface to docutils/__main__.py.
Added Paths:
-----------
trunk/docutils/docutils/__main__.py
Removed Paths:
-------------
trunk/docutils/tools/docutils-cli.py
Copied: trunk/docutils/docutils/__main__.py (from rev 9059, trunk/docutils/tools/docutils-cli.py)
===================================================================
--- trunk/docutils/docutils/__main__.py (rev 0)
+++ trunk/docutils/docutils/__main__.py 2022-05-30 16:54:33 UTC (rev 9060)
@@ -0,0 +1,106 @@
+#!/usr/bin/env python3
+# :Copyright: © 2020 Günter Milde.
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+#
+# Revision: $Revision$
+# Date: $Date$
+
+"""
+A generic front end to the Docutils Publisher.
+"""
+
+import argparse
+import locale
+import sys
+
+import docutils
+from docutils.core import Publisher, publish_cmdline
+
+
+class CliSettingsSpec(docutils.SettingsSpec):
+ """Runtime settings & command-line options for the generic CLI."""
+
+ settings_spec = (
+ 'Docutils CLI Options',
+ None,
+ # options: ('help text', [<option strings>], {<keyword arguments>})
+ (('Reader name (default/current: "%default").',
+ ['--reader'], {'metavar': '<reader>'}),
+ ('Parser name (default/current: "%default").',
+ ['--parser'], {'metavar': '<parser>'}),
+ ('Writer name (default/current: "%default").',
+ ['--writer'], {'metavar': '<writer>'}),
+ )
+ )
+ config_section = 'docutils-cli application'
+ config_section_dependencies = ('applications',)
+
+
+def main(settings_spec=CliSettingsSpec,
+ reader='standalone', parser='rst', writer='html'):
+ """Generic command line interface for the Docutils Publisher.
+ """
+ locale.setlocale(locale.LC_ALL, '')
+
+ description = ('Convert plaintext documentation into useful formats. '
+ 'Available options depend on the selected reader, '
+ 'writer, and parser. '
+ + docutils.core.default_description)
+
+ default_settings = Publisher().get_settings(settings_spec=settings_spec,
+ reader=reader,
+ parser=parser,
+ writer=writer)
+
+ # Pre-parse the command-line with "argparse" for component-setting options
+ argparser = argparse.ArgumentParser(add_help=False)
+ argparser.add_argument('--reader', default=default_settings.reader)
+ argparser.add_argument('--parser', default=default_settings.parser)
+ argparser.add_argument('--writer', default=default_settings.writer)
+ (args, remainder) = argparser.parse_known_args()
+
+ # TODO: require source ('-' for stdin)
+ # argparser.add_argument('source')
+ # argparser.add_argument('destination', nargs='?')
+ #
+ # print usage if there is no arg
+ # (always or if sys.stdout.isatty() ?)
+ # Alternatively, print a log message to stderr.
+ #
+ # Display output on success, but keep it brief.
+ # provide a -q option to suppress all non-essential output.
+ #
+ # Consider chaining several args as input
+ # and use --output (or redirection) for output
+ # argparser.add_argument('source', nargs='+')
+ #
+ # -- https://clig.dev/#help
+
+ # Update defaults (shown in help):
+ CliSettingsSpec.settings_default_overrides = args.__dict__
+
+ try:
+ publish_cmdline(reader_name=args.reader,
+ parser_name=args.parser,
+ writer_name=args.writer,
+ settings_spec=settings_spec,
+ description=description,
+ argv=remainder)
+ except ImportError as error:
+ print('%s.' % error, file=sys.stderr)
+ if '--traceback' in remainder:
+ raise
+ else:
+ print('Use "--traceback" to show details.')
+
+
+if __name__ == '__main__':
+ # backwards compatibility: docutils-cli.py defaults to "html5" writer:
+ main(writer='html5')
Deleted: trunk/docutils/tools/docutils-cli.py
===================================================================
--- trunk/docutils/tools/docutils-cli.py 2022-05-30 16:54:24 UTC (rev 9059)
+++ trunk/docutils/tools/docutils-cli.py 2022-05-30 16:54:33 UTC (rev 9060)
@@ -1,106 +0,0 @@
-#!/usr/bin/env python3
-# :Copyright: © 2020 Günter Milde.
-# :License: Released under the terms of the `2-Clause BSD license`_, in short:
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved.
-# This file is offered as-is, without any warranty.
-#
-# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
-#
-# Revision: $Revision$
-# Date: $Date$
-
-"""
-A generic front end to the Docutils Publisher.
-"""
-
-import argparse
-import locale
-import sys
-
-import docutils
-from docutils.core import Publisher, publish_cmdline
-
-
-class CliSettingsSpec(docutils.SettingsSpec):
- """Runtime settings & command-line options for the generic CLI."""
-
- settings_spec = (
- 'Docutils CLI Options',
- None,
- # options: ('help text', [<option strings>], {<keyword arguments>})
- (('Reader name (default/current: "%default").',
- ['--reader'], {'metavar': '<reader>'}),
- ('Parser name (default/current: "%default").',
- ['--parser'], {'metavar': '<parser>'}),
- ('Writer name (default/current: "%default").',
- ['--writer'], {'metavar': '<writer>'}),
- )
- )
- config_section = 'docutils-cli application'
- config_section_dependencies = ('applications',)
-
-
-def main(settings_spec=CliSettingsSpec,
- reader='standalone', parser='rst', writer='html'):
- """Generic command line interface for the Docutils Publisher.
- """
- locale.setlocale(locale.LC_ALL, '')
-
- description = ('Convert plaintext documentation into useful formats. '
- 'Available options depend on the selected reader, '
- 'writer, and parser. '
- + docutils.core.default_description)
-
- default_settings = Publisher().get_settings(settings_spec=settings_spec,
- reader=reader,
- parser=parser,
- writer=writer)
-
- # Pre-parse the command-line with "argparse" for component-setting options
- argparser = argparse.ArgumentParser(add_help=False)
- argparser.add_argument('--reader', default=default_settings.reader)
- argparser.add_argument('--parser', default=default_settings.parser)
- argparser.add_argument('--writer', default=default_settings.writer)
- (args, remainder) = argparser.parse_known_args()
-
- # TODO: require source ('-' for stdin)
- # argparser.add_argument('source')
- # argparser.add_argument('destination', nargs='?')
- #
- # print usage if there is no arg
- # (always or if sys.stdout.isatty() ?)
- # Alternatively, print a log message to stderr.
- #
- # Display output on success, but keep it brief.
- # provide a -q option to suppress all non-essential output.
- #
- # Consider chaining several args as input
- # and use --output (or redirection) for output
- # argparser.add_argument('source', nargs='+')
- #
- # -- https://clig.dev/#help
-
- # Update defaults (shown in help):
- CliSettingsSpec.settings_default_overrides = args.__dict__
-
- try:
- publish_cmdline(reader_name=args.reader,
- parser_name=args.parser,
- writer_name=args.writer,
- settings_spec=settings_spec,
- description=description,
- argv=remainder)
- except ImportError as error:
- print('%s.' % error, file=sys.stderr)
- if '--traceback' in remainder:
- raise
- else:
- print('Use "--traceback" to show details.')
-
-
-if __name__ == '__main__':
- # backwards compatibility: docutils-cli.py defaults to "html5" writer:
- main(writer='html5')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-05-30 16:54:50
|
Revision: 9061
http://sourceforge.net/p/docutils/code/9061
Author: milde
Date: 2022-05-30 16:54:46 +0000 (Mon, 30 May 2022)
Log Message:
-----------
Command line "entry point" to the docutils package. Part 2/2.
Support ``python -m docutils`` with new module `docutils.__main__`.
Support ``docutils`` CLI command via "entry point" in setup.py.
Keep tools/docutils-cli.py for backwards compatibility
and manual installation.
Calls `docutils.__main__.main()`.
Thanks to Adam Turner for contributions and review.
Modified Paths:
--------------
trunk/docutils/COPYING.txt
trunk/docutils/HISTORY.txt
trunk/docutils/README.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/dev/todo.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docs/user/tools.txt
trunk/docutils/docutils/__main__.py
trunk/docutils/docutils/core.py
trunk/docutils/setup.py
Added Paths:
-----------
trunk/docutils/test/data/help/
trunk/docutils/test/data/help/docutils.txt
trunk/docutils/tools/docutils-cli.py
Modified: trunk/docutils/COPYING.txt
===================================================================
--- trunk/docutils/COPYING.txt 2022-05-30 16:54:33 UTC (rev 9060)
+++ trunk/docutils/COPYING.txt 2022-05-30 16:54:46 UTC (rev 9061)
@@ -99,13 +99,18 @@
.. _eLyXer: https://github.com/alexfernandez/elyxer
-* docutils/parsers/recommonmark_wrapper.py,
+* docutils/__main__.py,
+ docutils/parsers/commonmark_wrapper.py,
+ docutils/parsers/recommonmark_wrapper.py,
docutils/utils/error_reporting.py,
docutils/utils/math/__init__.py,
docutils/utils/math/latex2mathml.py,
docutils/utils/math/tex2mathml_extern.py,
docutils/utils/punctuation_chars.py,
+ docutils/utils/smartquotes.py,
docutils/writers/html5_polyglot/__init__.py,
+ docutils/writers/html5_polyglot/*.css,
+ docutils/writers/latex2e/docutils.sty,
docutils/writers/xetex/__init__.py,
test/test_parsers/test_recommonmark/\*.py,
test/test_parsers/test_rst/test_directives/test__init__.py,
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-05-30 16:54:33 UTC (rev 9060)
+++ trunk/docutils/HISTORY.txt 2022-05-30 16:54:46 UTC (rev 9061)
@@ -21,10 +21,15 @@
- Code cleanup,
check PEP 8 conformity with `flake8` (exceptions in file tox.ini).
+* docutils/__main__.py
+
+ - New module. Support for ``python -m docutils``.
+ Also used for the ``docutils`` console script `entry point`.
+
* docutils/core.py:
- `Publisher.publish()`: Print info and prompt when waiting for input from
- a terminal cf. https://clig.dev/#interactivity.
+ Let `Publisher.publish()` print info and prompt when waiting for input
+ from a terminal (cf. https://clig.dev/#interactivity).
* docutils/parsers/__init__.py
@@ -65,7 +70,8 @@
* docutils/transforms/universal.py
- - Fix bug 435: invalid references in `problematic` nodes with report_level=4.
+ - Fix bug #435: invalid references in `problematic` nodes
+ with report_level=4.
* docutils/utils/__init__.py
@@ -79,9 +85,8 @@
* docutils/writers/_html_base.py
- - Add 'html writers' to `config_section_dependencies`. Fixes bug #443.
+ - Add "html writers" to `config_section_dependencies`. Fixes bug #443.
- Write table column widths with 3 digits precision. Fixes bug #444.
- - Stop writing an empty line before the "footer" closing tag.
* docutils/writers/html5_polyglot/__init__.py
@@ -93,7 +98,13 @@
- Use "https:" scheme in "python_home" URL default.
- Fix links in template.txt.
+
+* setup.py:
+ - New "docutils" console script `entry point`__. Fixes bug #447.
+
+ __ https://packaging.python.org/en/latest/specifications/entry-points/
+
* test/DocutilsTestSupport.py
- `exception_data()` now returns None if no exception was raised.
@@ -107,6 +118,7 @@
- Allow 3rd-party drop-in components for reader and parser, too.
- Fix help output.
+ - Actual code moved to docutils.__main__.py.
Release 0.18.1
Modified: trunk/docutils/README.txt
===================================================================
--- trunk/docutils/README.txt 2022-05-30 16:54:33 UTC (rev 9060)
+++ trunk/docutils/README.txt 2022-05-30 16:54:46 UTC (rev 9061)
@@ -149,7 +149,6 @@
(**not** directly in Python's ``site-packages``) first.
* Run ``setup.py install``.
- On Windows systems it may be sufficient to double-click ``install.py``.
See also OS-specific installation instructions below.
* For installing "by hand" or in "development mode", see the
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2022-05-30 16:54:33 UTC (rev 9060)
+++ trunk/docutils/RELEASE-NOTES.txt 2022-05-30 16:54:46 UTC (rev 9061)
@@ -20,11 +20,15 @@
Future changes
==============
-* Setup:
+* Setup:
- Do not install the auxilliary script ``tools/rst2odt_prepstyles.py``
in the binary PATH.
+ - Remove file ``install.py``. There are better ways, see README.txt__.
+
+ __ README.html#installation
+
* `html5` writer:
- Stop setting the "footnote-reference" class value for footnote
@@ -102,6 +106,11 @@
* Drop support for Python 2.7, 3.5, and 3.6.
+* After package installation, the CLI commands ``python -m docutils`` and
+ ``docutils`` start the `generic command line front end tool`__.
+
+ __ docs/user/tools.html#generic-command-line-front-end
+
* Support parsing "Markdown" input with 3rd party parsers
myst_, pycmark_, or recommonmark_.
Modified: trunk/docutils/docs/dev/todo.txt
===================================================================
--- trunk/docutils/docs/dev/todo.txt 2022-05-30 16:54:33 UTC (rev 9060)
+++ trunk/docutils/docs/dev/todo.txt 2022-05-30 16:54:46 UTC (rev 9061)
@@ -488,7 +488,7 @@
http://thread.gmane.org/gmane.text.docutils.user/1112
* Add a "disable_transforms" setting? Would allow for easy syntax
- checking. Where ("null" writer, generic, parser(s), docutils-cli.py)?
+ checking. Where ("null" writer, generic, parser(s))?
Cf. the `2004-02-18 "rest checking and source path"`_ thread.
* Add a generic meta-stylesheet mechanism? An external file could
@@ -2834,45 +2834,6 @@
Front-End Tools
===============
-* What about if we don't know which Reader and/or Writer we are
- going to use? If the Reader/Writer is specified on the
- command-line?
-
- The dynamic_ front end ``tools/docutils-cli.py`` (new in 0.17) is an
- implementation of concept d) below. It uses 2-stage argument parsing
- via the `argparse` module's `partial parsing`_. It still needs some
- polishing.
-
- Perhaps have different types of front ends:
-
- a) _`Fully qualified`: Reader and Writer are hard-coded into the
- front end (e.g. ``pep2html [options]``, ``pysource2pdf
- [options]``).
-
- b) _`Partially qualified`: Reader is hard-coded, and the Writer is
- specified a sub-command (e.g. ``pep2 html [options]``,
- ``pysource2 pdf [options]``). The Writer is known before option
- processing happens, allowing the OptionParser to be built
- dynamically. Alternatively, the Writer could be hard-coded and
- the Reader specified as a sub-command (e.g. ``htmlfrom pep
- [options]``).
-
- c) _`Unqualified`: Reader and Writer are specified as subcommands
- (e.g. ``publish pep html [options]``, ``publish pysource pdf
- [options]``). A single front end would be sufficient, but
- probably only useful for testing purposes.
-
- d) _`Dynamic`: Reader and/or Writer are specified by options, with
- defaults if unspecified (e.g. ``publish --writer manpage
- [options]``).
-
- Allow common options before subcommands, as in CVS? Or group all
- options together? In the case of the `fully qualified`_
- front ends, all the options will have to be grouped together
- anyway, so there's no advantage (we can't use it to avoid
- conflicts) to splitting common and component-specific options
- apart.
-
* Parameterize help text & defaults somehow? Perhaps a callback? Or
initialize ``settings_spec`` in ``__init__`` or ``init_options``?
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2022-05-30 16:54:33 UTC (rev 9060)
+++ trunk/docutils/docs/user/config.txt 2022-05-30 16:54:46 UTC (rev 9061)
@@ -849,7 +849,6 @@
__ https://pypi.org/project/pycmark/
-
.. _recommonmark:
[recommonmark parser]
@@ -2164,10 +2163,11 @@
.. _HTML writer: html.html
-[docutils-cli application]
+[docutils application]
--------------------------
New in 0.17. Config file support added in 0.18.
+Renamed in 0.19 (the old name "docutils-cli application" is kept as alias).
Support for reader/parser import names added in 0.19.
reader
@@ -2190,8 +2190,11 @@
Default: "rst".
Option: ``--parser``
-.. _writer [docutils-cli application]:
+.. _CommonMark: https://spec.commonmark.org/0.30/
+
+.. _writer [docutils application]:
+
writer
~~~~~~
Writer component name.
@@ -2202,9 +2205,7 @@
Default: "html5".
Option: ``--writer``
-.. _CommonMark: https://spec.commonmark.org/0.30/
-
Other Settings
==============
Modified: trunk/docutils/docs/user/tools.txt
===================================================================
--- trunk/docutils/docs/user/tools.txt 2022-05-30 16:54:33 UTC (rev 9060)
+++ trunk/docutils/docs/user/tools.txt 2022-05-30 16:54:46 UTC (rev 9061)
@@ -17,10 +17,10 @@
Introduction
--------------
-Once the Docutils package is unpacked, you will discover a "``tools``"
+Once the Docutils package is unpacked, you will discover a ``tools/``
directory containing several front ends for common Docutils
processing.
-In addition to the all-purpose program docutils-cli.py_, Docutils has
+In addition to the `generic command line front end`_, Docutils has
many small front ends, each specialized for a specific "Reader" (which
knows how to interpret a file in context), a "Parser" (which
understands the syntax of the text), and a "Writer" (which knows how
@@ -27,11 +27,10 @@
to generate a specific data format).
Most [#]_ front ends have common options and the same command-line usage
-pattern::
+pattern (see `the tools`_ below for concrete examples)::
toolname [options] [<source> [<destination>]]
-See rst2html4.py_ for examples.
Each tool has a "``--help``" option which lists the
`command-line options`_ and arguments it supports.
Processing can also be customized with `configuration files`_.
@@ -70,35 +69,38 @@
Generic Command Line Front End
==============================
-docutils-cli.py
----------------
-
:Readers: Standalone, PEP
-:Parser: reStructuredText, Markdown (reCommonMark)
+:Parsers: reStructuredText, Markdown (requires 3rd party packages)
:Writers: html_, html4css1_, html5_, latex__, manpage_,
odt_, pep_html_, pseudo-xml_, s5_html_, xelatex_, xml_,
-:Config_: See `[docutils-cli application]`_
+:Config_: See `[docutils application]`_
-The ``docutils-cli.py`` front allows combining reader, parser, and
-writer components.
+The generic front end allows combining "reader", "parser", and
+"writer" components from the Docutils package or 3rd party plug-ins.
+Since Docutils 0.19, it can be called by Python's ``-m`` option,
+the ``docutils`` script installed in the binary PATH, or the
+``docutils-cli.py`` script in the ``tools/`` directory.
+
For example, to process a Markdown_ file "``test.md``" into
Pseudo-XML_ ::
- docutils-cli.py --parser=markdown --writer=pseudoxml\
+ python3 -m docutils --parser=markdown --writer=pseudoxml\
test.md test.txt
Use the "--help" option together with the component-selection options
to get the correct list of supported command-line options. Example::
- docutils-cli.py --parser=markdown --writer=xml --help
+ docutils --parser=markdown --writer=xml --help
+
+
__
.. _latex2e:
.. _Generating LaTeX with Docutils: latex.html
.. _manpage: manpage.html
.. _Markdown: https://www.markdownguide.org/
-.. _[docutils-cli application]: config.html#docutils-cli-application
+.. _[docutils application]: config.html#docutils-application
HTML-Generating Tools
@@ -157,15 +159,12 @@
Docutils, and the web. Currently, it is html4css1_.
.. caution::
- Use docutils-cli.py_ with the `"writer" option`__ or
- a specific front end like rst2html4.py_ or rst2html5.py_,
+ Use a specific front end like rst2html4.py_ or rst2html5.py_,
if you depend on stability of the generated HTML code
(e.g., because you use a custom style sheet or post-processing
that may break otherwise).
- __ config.html#writer-docutils-cli-application
-
rst2html4.py
------------
Modified: trunk/docutils/docutils/__main__.py
===================================================================
--- trunk/docutils/docutils/__main__.py 2022-05-30 16:54:33 UTC (rev 9060)
+++ trunk/docutils/docutils/__main__.py 2022-05-30 16:54:46 UTC (rev 9061)
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-# :Copyright: © 2020 Günter Milde.
+# :Copyright: © 2020, 2022 Günter Milde.
# :License: Released under the terms of the `2-Clause BSD license`_, in short:
#
# Copying and distribution of this file, with or without modification,
@@ -12,9 +12,11 @@
# Revision: $Revision$
# Date: $Date$
+"""Generic command line interface for the `docutils` package.
+
+See also
+https://docs.python.org/3/library/__main__.html#main-py-in-python-packages
"""
-A generic front end to the Docutils Publisher.
-"""
import argparse
import locale
@@ -21,69 +23,55 @@
import sys
import docutils
-from docutils.core import Publisher, publish_cmdline
+from docutils.core import Publisher, publish_cmdline, default_description
class CliSettingsSpec(docutils.SettingsSpec):
- """Runtime settings & command-line options for the generic CLI."""
+ """Runtime settings & command-line options for the generic CLI.
+ Configurable reader, parser, and writer components.
+
+ The "--writer" default will change to 'html' when this becomes
+ an alias for 'html5'.
+ """
+
settings_spec = (
- 'Docutils CLI Options',
- None,
+ 'Docutils Application Options',
+ 'Reader, writer, and parser settings influence the available options. '
+ 'Example: use `--help --writer=latex` to see LaTeX writer options. ',
# options: ('help text', [<option strings>], {<keyword arguments>})
- (('Reader name (default/current: "%default").',
- ['--reader'], {'metavar': '<reader>'}),
- ('Parser name (default/current: "%default").',
- ['--parser'], {'metavar': '<parser>'}),
- ('Writer name (default/current: "%default").',
- ['--writer'], {'metavar': '<writer>'}),
+ (('Reader name (currently: "%default").',
+ ['--reader'], {'default': 'standalone', 'metavar': '<reader>'}),
+ ('Parser name (currently: "%default").',
+ ['--parser'], {'default': 'rst', 'metavar': '<parser>'}),
+ ('Writer name (currently: "%default").',
+ ['--writer'], {'default': 'html5', 'metavar': '<writer>'}),
)
)
- config_section = 'docutils-cli application'
- config_section_dependencies = ('applications',)
+ config_section = 'docutils application'
+ config_section_dependencies = ('docutils-cli application', # back-compat
+ 'applications')
-def main(settings_spec=CliSettingsSpec,
- reader='standalone', parser='rst', writer='html'):
+def main():
"""Generic command line interface for the Docutils Publisher.
"""
locale.setlocale(locale.LC_ALL, '')
- description = ('Convert plaintext documentation into useful formats. '
- 'Available options depend on the selected reader, '
- 'writer, and parser. '
- + docutils.core.default_description)
+ description = ('Convert documents into useful formats. '
+ + default_description)
- default_settings = Publisher().get_settings(settings_spec=settings_spec,
- reader=reader,
- parser=parser,
- writer=writer)
+ # Update component selection from config file(s)
+ components = Publisher().get_settings(settings_spec=CliSettingsSpec)
- # Pre-parse the command-line with "argparse" for component-setting options
- argparser = argparse.ArgumentParser(add_help=False)
- argparser.add_argument('--reader', default=default_settings.reader)
- argparser.add_argument('--parser', default=default_settings.parser)
- argparser.add_argument('--writer', default=default_settings.writer)
+ # Update component selection from command-line
+ argparser = argparse.ArgumentParser(add_help=False, allow_abbrev=False)
+ argparser.add_argument('--reader', default=components.reader)
+ argparser.add_argument('--parser', default=components.parser)
+ argparser.add_argument('--writer', default=components.writer)
+ # other options are parsed in a second pass via `publish_cmdline()`
(args, remainder) = argparser.parse_known_args()
-
- # TODO: require source ('-' for stdin)
- # argparser.add_argument('source')
- # argparser.add_argument('destination', nargs='?')
- #
- # print usage if there is no arg
- # (always or if sys.stdout.isatty() ?)
- # Alternatively, print a log message to stderr.
- #
- # Display output on success, but keep it brief.
- # provide a -q option to suppress all non-essential output.
- #
- # Consider chaining several args as input
- # and use --output (or redirection) for output
- # argparser.add_argument('source', nargs='+')
- #
- # -- https://clig.dev/#help
-
- # Update defaults (shown in help):
+ # Ensure the current component selections are shown in help:
CliSettingsSpec.settings_default_overrides = args.__dict__
try:
@@ -90,7 +78,7 @@
publish_cmdline(reader_name=args.reader,
parser_name=args.parser,
writer_name=args.writer,
- settings_spec=settings_spec,
+ settings_spec=CliSettingsSpec,
description=description,
argv=remainder)
except ImportError as error:
@@ -102,5 +90,7 @@
if __name__ == '__main__':
- # backwards compatibility: docutils-cli.py defaults to "html5" writer:
- main(writer='html5')
+ if sys.argv[0].endswith('__main__.py'):
+ # fix "usage" message
+ sys.argv[0] = '%s -m docutils' % sys.executable
+ main()
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2022-05-30 16:54:33 UTC (rev 9060)
+++ trunk/docutils/docutils/core.py 2022-05-30 16:54:46 UTC (rev 9061)
@@ -277,7 +277,7 @@
except AttributeError:
return
eot_key = 'Ctrl+Z' if os.name == 'nt' else 'Ctrl+D on an empty line'
- in_format = 'plaintext'
+ in_format = ''
out_format = 'useful formats'
try:
in_format = self.parser.supported[0]
@@ -350,12 +350,20 @@
default_usage = '%prog [options] [<source> [<destination>]]'
default_description = (
- 'Reads from <source> (default is stdin) and writes to <destination> '
- '(default is stdout). '
+ 'Reads from <source> (default is stdin) '
+ 'and writes to <destination> (default is stdout). '
'See https://docutils.sourceforge.io/docs/user/config.html '
- ' for the full reference.')
+ 'for a detailed settings reference.')
+# TODO: or not to do? cf. https://clig.dev/#help
+#
+# Display output on success, but keep it brief.
+#
+# Provide a -q option to suppress all non-essential output.
+# Chain several args as input and use --output or redirection for output:
+# argparser.add_argument('source', nargs='+')
+#
def publish_cmdline(reader=None, reader_name='standalone',
parser=None, parser_name='restructuredtext',
writer=None, writer_name='pseudoxml',
Modified: trunk/docutils/setup.py
===================================================================
--- trunk/docutils/setup.py 2022-05-30 16:54:33 UTC (rev 9060)
+++ trunk/docutils/setup.py 2022-05-30 16:54:46 UTC (rev 9061)
@@ -67,6 +67,9 @@
'docutils.writers.xetex',
'docutils.writers.odf_odt',
],
+ 'entry_points': {
+ 'console_scripts': ['docutils=docutils.__main__:main']
+ },
'scripts': [
'tools/rst2html.py',
'tools/rst2html4.py',
Added: trunk/docutils/test/data/help/docutils.txt
===================================================================
--- trunk/docutils/test/data/help/docutils.txt (rev 0)
+++ trunk/docutils/test/data/help/docutils.txt 2022-05-30 16:54:46 UTC (rev 9061)
@@ -0,0 +1,216 @@
+Usage
+=====
+ docutils [options] [<source> [<destination>]]
+
+Convert documents into useful formats. Reads from <source> (default is stdin)
+and writes to <destination> (default is stdout). See
+https://docutils.sourceforge.io/docs/user/config.html for a detailed settings
+reference.
+
+Options
+=======
+General Docutils Options
+------------------------
+--title=TITLE Specify the document title as metadata.
+--generator, -g Include a "Generated by Docutils" credit and link.
+--no-generator Do not include a generator credit.
+--date, -d Include the date at the end of the document (UTC).
+--time, -t Include the time & date (UTC).
+--no-datestamp Do not include a datestamp of any kind.
+--source-link, -s Include a "View document source" link.
+--source-url=<URL> Use <URL> for a source link; implies --source-link.
+--no-source-link Do not include a "View document source" link.
+--toc-entry-backlinks Link from section headers to TOC entries. (default)
+--toc-top-backlinks Link from section headers to the top of the TOC.
+--no-toc-backlinks Disable backlinks to the table of contents.
+--footnote-backlinks Link from footnotes/citations to references. (default)
+--no-footnote-backlinks
+ Disable backlinks from footnotes and citations.
+--section-numbering Enable section numbering by Docutils. (default)
+--no-section-numbering Disable section numbering by Docutils.
+--strip-comments Remove comment elements from the document tree.
+--leave-comments Leave comment elements in the document tree. (default)
+--strip-elements-with-class=<class>
+ Remove all elements with classes="<class>" from the
+ document tree. Warning: potentially dangerous; use
+ with caution. (Multiple-use option.)
+--strip-class=<class> Remove all classes="<class>" attributes from elements
+ in the document tree. Warning: potentially dangerous;
+ use with caution. (Multiple-use option.)
+--report=<level>, -r <level>
+ Report system messages at or higher than <level>:
+ "info" or "1", "warning"/"2" (default), "error"/"3",
+ "severe"/"4", "none"/"5"
+--verbose, -v Report all system messages. (Same as "--report=1".)
+--quiet, -q Report no system messages. (Same as "--report=5".)
+--halt=<level> Halt execution at system messages at or above <level>.
+ Levels as in --report. Default: 4 (severe).
+--strict Halt at the slightest problem. Same as "--halt=info".
+--exit-status=<level> Enable a non-zero exit status for non-halting system
+ messages at or above <level>. Default: 5 (disabled).
+--debug Enable debug-level system messages and diagnostics.
+--no-debug Disable debug output. (default)
+--warnings=<file> Send the output of system messages to <file>.
+--traceback Enable Python tracebacks when Docutils is halted.
+--no-traceback Disable Python tracebacks. (default)
+--input-encoding=<name[:handler]>, -i <name[:handler]>
+ Specify the encoding and optionally the error handler
+ of input text. Default: <locale-dependent>:strict.
+--input-encoding-error-handler=INPUT_ENCODING_ERROR_HANDLER
+ Specify the error handler for undecodable characters.
+ Choices: "strict" (default), "ignore", and "replace".
+--output-encoding=<name[:handler]>, -o <name[:handler]>
+ Specify the text encoding and optionally the error
+ handler for output. Default: UTF-8:strict.
+--output-encoding-error-handler=OUTPUT_ENCODING_ERROR_HANDLER
+ Specify error handler for unencodable output
+ characters; "strict" (default), "ignore", "replace",
+ "xmlcharrefreplace", "backslashreplace".
+--error-encoding=<name[:handler]>, -e <name[:handler]>
+ Specify text encoding and error handler for error
+ output. Default: utf-8:backslashreplace.
+--error-encoding-error-handler=ERROR_ENCODING_ERROR_HANDLER
+ Specify the error handler for unencodable characters
+ in error output. Default: backslashreplace.
+--language=<name>, -l <name>
+ Specify the language (as BCP 47 language tag).
+ Default: en.
+--record-dependencies=<file>
+ Write output file dependencies to <file>.
+--config=<file> Read configuration settings from <file>, if it exists.
+--version, -V Show this program's version number and exit.
+--help, -h Show this help message and exit.
+
+Generic Parser Options
+----------------------
+--no-file-insertion Disable directives that insert the contents of an
+ external file; replaced with a "warning" system
+ message.
+--file-insertion-enabled
+ Enable directives that insert the contents of an
+ external file. (default)
+--no-raw Disable the "raw" directive; replaced with a "warning"
+ system message.
+--raw-enabled Enable the "raw" directive. (default)
+--line-length-limit=<length>
+ Maximal number of characters in an input line. Default
+ 10 000.
+
+reStructuredText Parser Options
+-------------------------------
+--pep-references Recognize and link to standalone PEP references (like
+ "PEP 258").
+--pep-base-url=<URL> Base URL for PEP references (default
+ "https://peps.python.org/").
+--pep-file-url-template=<URL>
+ Template for PEP file part of URL. (default
+ "pep-%04d")
+--rfc-references Recognize and link to standalone RFC references (like
+ "RFC 822").
+--rfc-base-url=<URL> Base URL for RFC references (default
+ "https://tools.ietf.org/html/").
+--tab-width=<width> Set number of spaces for tab expansion (default 8).
+--trim-footnote-reference-space
+ Remove spaces before footnote references.
+--leave-footnote-reference-space
+ Leave spaces before footnote references.
+--syntax-highlight=<format>
+ Token name set for parsing code with Pygments: one of
+ "long", "short", or "none" (no parsing). Default is
+ "long".
+--smart-quotes=<yes/no/alt>
+ Change straight quotation marks to typographic form:
+ one of "yes", "no", "alt[ernative]" (default "no").
+--smartquotes-locales=<language:quotes[,language:quotes,...]>
+ Characters to use as "smart quotes" for <language>.
+--word-level-inline-markup
+ Inline markup recognized at word boundaries only
+ (adjacent to punctuation or whitespace). Force
+ character-level inline markup recognition with "\ "
+ (backslash + space). Default.
+--character-level-inline-markup
+ Inline markup recognized anywhere, regardless of
+ surrounding characters. Backslash-escapes must be used
+ to avoid unwanted markup recognition. Useful for East
+ Asian languages. Experimental.
+
+Standalone Reader Options
+-------------------------
+--no-doc-title Disable the promotion of a lone top-level section
+ title to document title (and subsequent section title
+ to document subtitle promotion; enabled by default).
+--no-doc-info Disable the bibliographic field list transform
+ (enabled by default).
+--section-subtitles Activate the promotion of lone subsection titles to
+ section subtitles (disabled by default).
+--no-section-subtitles Deactivate the promotion of lone subsection titles.
+
+HTML Writer Options
+-------------------
+--template=<file> Template file. (UTF-8 encoded, default: [...])
+--stylesheet=<URL[,URL,...]>
+ Comma separated list of stylesheet URLs. Overrides
+ previous --stylesheet and --stylesheet-path settings.
+--stylesheet-path=<file[,file,...]>
+ Comma separated list of stylesheet paths. Relative
+ paths are expanded if a matching file is found in the
+ --stylesheet-dirs. With --link-stylesheet, the path is
+ rewritten relative to the output HTML file. (default:
+ "minimal.cs...
[truncated message content] |
|
From: <mi...@us...> - 2022-06-10 11:08:15
|
Revision: 9064
http://sourceforge.net/p/docutils/code/9064
Author: milde
Date: 2022-06-10 11:08:13 +0000 (Fri, 10 Jun 2022)
Log Message:
-----------
Avoid non-ASCII chars and use lowercase encoding name in help output.
Modified Paths:
--------------
trunk/docutils/docutils/__main__.py
trunk/docutils/docutils/frontend.py
trunk/docutils/test/data/help/docutils.txt
Modified: trunk/docutils/docutils/__main__.py
===================================================================
--- trunk/docutils/docutils/__main__.py 2022-05-30 21:09:18 UTC (rev 9063)
+++ trunk/docutils/docutils/__main__.py 2022-06-10 11:08:13 UTC (rev 9064)
@@ -38,7 +38,7 @@
settings_spec = (
'Docutils Application Options',
'Reader, writer, and parser settings influence the available options. '
- 'Example: use `--help --writer=latex` to see LaTeX writer options. ',
+ ' Example: use `--help --writer=latex` to see LaTeX writer options. ',
# options: ('help text', [<option strings>], {<keyword arguments>})
(('Reader name (currently: "%default").',
['--reader'], {'default': 'standalone', 'metavar': '<reader>'}),
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2022-05-30 21:09:18 UTC (rev 9063)
+++ trunk/docutils/docutils/frontend.py 2022-06-10 11:08:13 UTC (rev 9064)
@@ -571,7 +571,7 @@
['--input-encoding-error-handler'],
{'default': 'strict', 'validator': validate_encoding_error_handler}),
('Specify the text encoding and optionally the error handler for '
- 'output. Default: UTF-8:strict.',
+ 'output. Default: utf-8:strict.',
['--output-encoding', '-o'],
{'metavar': '<name[:handler]>', 'default': 'utf-8',
'validator': validate_encoding_and_error_handler}),
Modified: trunk/docutils/test/data/help/docutils.txt
===================================================================
--- trunk/docutils/test/data/help/docutils.txt 2022-05-30 21:09:18 UTC (rev 9063)
+++ trunk/docutils/test/data/help/docutils.txt 2022-06-10 11:08:13 UTC (rev 9064)
@@ -61,7 +61,7 @@
Choices: "strict" (default), "ignore", and "replace".
--output-encoding=<name[:handler]>, -o <name[:handler]>
Specify the text encoding and optionally the error
- handler for output. Default: UTF-8:strict.
+ handler for output. Default: utf-8:strict.
--output-encoding-error-handler=OUTPUT_ENCODING_ERROR_HANDLER
Specify error handler for unencodable output
characters; "strict" (default), "ignore", "replace",
@@ -209,7 +209,7 @@
Docutils Application Options
----------------------------
Reader, writer, and parser settings influence the available options.
-Example: use `--help --writer=latex` to see LaTeX writer options.
+Example: use `--help --writer=latex` to see LaTeX writer options.
--reader=<reader> Reader name (currently: "standalone").
--parser=<parser> Parser name (currently: "rst").
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-06-10 11:08:49
|
Revision: 9067
http://sourceforge.net/p/docutils/code/9067
Author: milde
Date: 2022-06-10 11:08:46 +0000 (Fri, 10 Jun 2022)
Log Message:
-----------
Fix `nodes.Node.findall()` for Text nodes.
As `nodes.Text` inherits from `str`, Text nodes with the same content
are considered equal and ``nodes.Element.index(Text('sample'))``
may return a preceding Text node with content "sample".
Therefore, Node.findall() must perform an additional test for identity
with the start node.
Fixes bug #448.
Thanks to Adam Turner.
Modified Paths:
--------------
trunk/docutils/docutils/nodes.py
trunk/docutils/test/test_nodes.py
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2022-06-10 11:08:38 UTC (rev 9066)
+++ trunk/docutils/docutils/nodes.py 2022-06-10 11:08:46 UTC (rev 9067)
@@ -297,6 +297,9 @@
node = self
while node.parent:
index = node.parent.index(node)
+ # extra check since Text nodes have value-equality
+ while node.parent[index] is not node:
+ index = node.parent.index(node, index + 1)
for sibling in node.parent[index+1:]:
yield from sibling.findall(
condition=condition,
@@ -734,8 +737,8 @@
def remove(self, item):
self.children.remove(item)
- def index(self, item):
- return self.children.index(item)
+ def index(self, item, start=0, stop=sys.maxsize):
+ return self.children.index(item, start, stop)
def is_not_default(self, key):
if self[key] == [] and key in self.list_attributes:
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2022-06-10 11:08:38 UTC (rev 9066)
+++ trunk/docutils/test/test_nodes.py 2022-06-10 11:08:46 UTC (rev 9067)
@@ -64,6 +64,11 @@
self.assertEqual(self.longtext.shortrepr(),
r"<#text: 'Mary had a lit ...'>")
+ def test_comparison(self):
+ # Text nodes are compared by value
+ self.assertEqual(self.text, 'Line 1.\nLine 2.')
+ self.assertEqual(self.text, nodes.Text('Line 1.\nLine 2.'))
+
def test_Text_rawsource_deprection_warning(self):
with self.assertWarnsRegex(DeprecationWarning,
'"rawsource" is ignored'):
@@ -119,6 +124,22 @@
self.assertEqual(element.pformat(),
'<Element attr="1">\n text\n more\n')
+ def test_index(self):
+ # Element.index() behaves like list.index() on the element's children
+ e = nodes.Element()
+ e += nodes.Element()
+ e += nodes.Text('sample')
+ e += nodes.Element()
+ e += nodes.Text('other sample')
+ e += nodes.Text('sample')
+ # return element's index for the first four children:
+ for i in range(4):
+ self.assertEqual(e.index(e[i]), i)
+ # Caution: mismatches are possible for Text nodes
+ # as they are compared by value (like `str` instances)
+ self.assertEqual(e.index(e[4]), 1)
+ self.assertEqual(e.index(e[4], start=2), 4)
+
def test_clear(self):
element = nodes.Element()
element += nodes.Element()
@@ -545,6 +566,24 @@
[e[0]])
self.assertEqual(list(e.findall(nodes.TextElement)), [e[0][1]])
+ def test_findall_duplicate_texts(self):
+ e = nodes.Element()
+ e += nodes.TextElement()
+ e[0] += nodes.Text('one')
+ e[0] += nodes.Text('two')
+ e[0] += nodes.Text('three')
+ e[0] += nodes.Text('two')
+ e[0] += nodes.Text('five')
+ full_list = list(e[0][0].findall(siblings=True))
+ self.assertEqual(len(full_list), 5)
+ for i in range(5):
+ self.assertIs(full_list[i], e[0][i])
+
+ partial_list = list(e[0][3].findall(siblings=True))
+ self.assertEqual(len(partial_list), 2)
+ self.assertIs(partial_list[0], e[0][3])
+ self.assertIs(partial_list[1], e[0][4])
+
def test_next_node(self):
e = nodes.Element()
e += nodes.Element()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-06-13 12:05:11
|
Revision: 9068
http://sourceforge.net/p/docutils/code/9068
Author: milde
Date: 2022-06-13 12:05:08 +0000 (Mon, 13 Jun 2022)
Log Message:
-----------
Unify naming of the "utf-8" codec.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/math/tex2mathml_extern.py
trunk/docutils/docutils/utils/smartquotes.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/test_dependencies.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_io.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py
trunk/docutils/test/test_writers/test_docutils_xml.py
trunk/docutils/tools/dev/generate_punctuation_chars.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-06-10 11:08:46 UTC (rev 9067)
+++ trunk/docutils/HISTORY.txt 2022-06-13 12:05:08 UTC (rev 9068)
@@ -25,7 +25,7 @@
- New module. Support for ``python -m docutils``.
Also used for the ``docutils`` console script `entry point`.
-
+
* docutils/core.py:
Let `Publisher.publish()` print info and prompt when waiting for input
@@ -98,11 +98,11 @@
- Use "https:" scheme in "python_home" URL default.
- Fix links in template.txt.
-
+
* setup.py:
- New "docutils" console script `entry point`__. Fixes bug #447.
-
+
__ https://packaging.python.org/en/latest/specifications/entry-points/
* test/DocutilsTestSupport.py
@@ -381,7 +381,7 @@
* docutils/writers/latex2e/__init__.py:
- - Open "docutils.sty" with encoding set to "utf8".
+ - Open "docutils.sty" with encoding set to "utf-8".
Fixes bug #414: error with Py3k when locale encoding is "ascii".
* docutils/parsers/*.py, docutils/transforms/*.py
@@ -1273,7 +1273,7 @@
__ RELEASE-NOTES.html
- - DependencyList uses io.FileOutput and 'utf8' encoding to prevent
+ - DependencyList uses io.FileOutput and 'utf-8' encoding to prevent
errors recording non-ASCII filenames (fixes [ 3434355 ]).
- Fix `relative_path()` with source=None and `unicode` target.
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2022-06-10 11:08:46 UTC (rev 9067)
+++ trunk/docutils/docutils/utils/__init__.py 2022-06-13 12:05:08 UTC (rev 9068)
@@ -748,7 +748,7 @@
else:
of = output_file
self.file = io.FileOutput(destination_path=of,
- encoding='utf8', autoclose=False)
+ encoding='utf-8', autoclose=False)
else:
self.file = None
Modified: trunk/docutils/docutils/utils/math/tex2mathml_extern.py
===================================================================
--- trunk/docutils/docutils/utils/math/tex2mathml_extern.py 2022-06-10 11:08:46 UTC (rev 9067)
+++ trunk/docutils/docutils/utils/math/tex2mathml_extern.py 2022-06-13 12:05:08 UTC (rev 9068)
@@ -40,10 +40,10 @@
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True)
- p.stdin.write((document_template % math_code).encode('utf8'))
+ p.stdin.write((document_template % math_code).encode('utf-8'))
p.stdin.close()
latexml_code = p.stdout.read()
- latexml_err = p.stderr.read().decode('utf8')
+ latexml_err = p.stderr.read().decode('utf-8')
if reporter and (latexml_err.find('Error') >= 0 or not latexml_code):
reporter.error(latexml_err)
@@ -60,8 +60,8 @@
close_fds=True)
post_p.stdin.write(latexml_code)
post_p.stdin.close()
- result = post_p.stdout.read().decode('utf8')
- post_p_err = post_p.stderr.read().decode('utf8')
+ result = post_p.stdout.read().decode('utf-8')
+ post_p_err = post_p.stderr.read().decode('utf-8')
if reporter and (post_p_err.find('Error') >= 0 or not result):
reporter.error(post_p_err)
@@ -87,10 +87,10 @@
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True)
- p.stdin.write((document_template % math_code).encode('utf8'))
+ p.stdin.write((document_template % math_code).encode('utf-8'))
p.stdin.close()
result = p.stdout.read()
- err = p.stderr.read().decode('utf8')
+ err = p.stderr.read().decode('utf-8')
if err.find('**** Unknown') >= 0:
msg = '\n'.join(line for line in err.splitlines()
if line.startswith('****'))
@@ -125,10 +125,10 @@
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True)
- p.stdin.write(math_code.encode('utf8'))
+ p.stdin.write(math_code.encode('utf-8'))
p.stdin.close()
- result = p.stdout.read().decode('utf8')
- err = p.stderr.read().decode('utf8')
+ result = p.stdout.read().decode('utf-8')
+ err = p.stderr.read().decode('utf-8')
if result.find('<error>') >= 0:
msg = result[result.find('<message>')+9:result.find('</message>')]
@@ -147,6 +147,6 @@
if __name__ == "__main__":
example = ('\\frac{\\partial \\sin^2(\\alpha)}{\\partial \\vec r}'
'\\varpi \\, \\text{Grüße}')
- # print(latexml(example).encode('utf8'))
+ # print(latexml(example).encode('utf-8'))
# print(ttm(example))
- print(blahtexml(example).encode('utf8'))
+ print(blahtexml(example).encode('utf-8'))
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2022-06-10 11:08:46 UTC (rev 9067)
+++ trunk/docutils/docutils/utils/smartquotes.py 2022-06-13 12:05:08 UTC (rev 9068)
@@ -927,7 +927,7 @@
# parser.add_argument("input", help="Input stream, use '-' for stdin.")
parser.add_argument("-a", "--action", default="1",
help="what to do with the input (see --actionhelp)")
- parser.add_argument("-e", "--encoding", default="utf8",
+ parser.add_argument("-e", "--encoding", default="utf-8",
help="text encoding")
parser.add_argument("-l", "--language", default=defaultlanguage,
help="text language (BCP47 tag), "
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2022-06-10 11:08:46 UTC (rev 9067)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2022-06-13 12:05:08 UTC (rev 9068)
@@ -271,12 +271,12 @@
# get template string from file
templatepath = self.document.settings.template
try:
- with open(templatepath, encoding='utf8') as fp:
+ with open(templatepath, encoding='utf-8') as fp:
template = fp.read()
except IOError:
templatepath = os.path.join(self.default_template_path,
templatepath)
- with open(templatepath, encoding='utf8') as fp:
+ with open(templatepath, encoding='utf-8') as fp:
template = fp.read()
# fill template
self.assemble_parts() # create dictionary of parts
@@ -597,7 +597,7 @@
_docutils_sty = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'docutils.sty')
-with open(_docutils_sty, encoding='utf8') as fp:
+with open(_docutils_sty, encoding='utf-8') as fp:
for line in fp:
line = line.strip('% \n')
if not line.endswith('::'):
@@ -1459,7 +1459,7 @@
# 'iso-8859-6': '' # arabic
# 'iso-8859-7': '' # greek
# 'iso-8859-8': '' # hebrew
- # 'iso-8859-10': '' # latin6, more complete iso-8859-4
+ # 'iso-8859-10': '' # latin6, more complete iso-8859-4
}
encoding = docutils_encoding.lower()
if encoding in tr:
Modified: trunk/docutils/test/test_dependencies.py
===================================================================
--- trunk/docutils/test/test_dependencies.py 2022-06-10 11:08:46 UTC (rev 9067)
+++ trunk/docutils/test/test_dependencies.py 2022-06-13 12:05:08 UTC (rev 9068)
@@ -46,7 +46,7 @@
recorder.close()
# Read the record file:
record = docutils.io.FileInput(source_path=recordfile,
- encoding='utf8')
+ encoding='utf-8')
return record.read().splitlines()
def test_dependencies_xml(self):
Modified: trunk/docutils/test/test_error_reporting.py
===================================================================
--- trunk/docutils/test/test_error_reporting.py 2022-06-10 11:08:46 UTC (rev 9067)
+++ trunk/docutils/test/test_error_reporting.py 2022-06-13 12:05:08 UTC (rev 9068)
@@ -144,7 +144,7 @@
e.write(AttributeError(u' e\xfc'))
self.assertEqual(buf.getvalue(), b'b\xfc u\\xfc e\\xfc')
# encode with `encoding` attribute
- e.encoding = 'utf8'
+ e.encoding = 'utf-8'
e.write(u' u\xfc')
self.assertEqual(buf.getvalue(), b'b\xfc u\\xfc e\\xfc u\xc3\xbc')
Modified: trunk/docutils/test/test_io.py
===================================================================
--- trunk/docutils/test/test_io.py 2022-06-10 11:08:46 UTC (rev 9067)
+++ trunk/docutils/test/test_io.py 2022-06-13 12:05:08 UTC (rev 9068)
@@ -33,7 +33,7 @@
class mock_stdout(UBuf):
- encoding = 'utf8'
+ encoding = 'utf-8'
def __init__(self):
self.buffer = BBuf()
@@ -44,8 +44,9 @@
def test_check_encoding_true(self):
"""Return `True` if lookup returns the same codec"""
+ self.assertEqual(io.check_encoding(mock_stdout, 'utf-8'), True)
+ self.assertEqual(io.check_encoding(mock_stdout, 'utf_8'), True)
self.assertEqual(io.check_encoding(mock_stdout, 'utf8'), True)
- self.assertEqual(io.check_encoding(mock_stdout, 'utf-8'), True)
self.assertEqual(io.check_encoding(mock_stdout, 'UTF-8'), True)
def test_check_encoding_false(self):
@@ -80,7 +81,7 @@
def test_bom(self):
input = io.StringInput(source=b'\xef\xbb\xbf foo \xef\xbb\xbf bar',
- encoding='utf8')
+ encoding='utf-8')
# Assert BOMs are gone.
self.assertEqual(input.read(), ' foo bar')
# With unicode input:
@@ -129,9 +130,9 @@
self.assertEqual(data, ['Some include text.\n'])
def test_heuristics_no_utf8(self):
- # if no encoding is given and decoding with utf8 fails,
+ # if no encoding is given and decoding with utf-8 fails,
# use either the locale encoding (if specified) or latin-1:
- if io.locale_encoding != "utf8":
+ if io.locale_encoding.lower() not in ('utf-8', 'utf8'):
# in Py3k, the locale encoding is used without --input-encoding
# skipping the heuristic unless decoding fails.
return
@@ -174,7 +175,7 @@
self.assertEqual(self.udrain.getvalue(), self.udata)
def test_write_utf8(self):
- fo = io.FileOutput(destination=self.udrain, encoding='utf8',
+ fo = io.FileOutput(destination=self.udrain, encoding='utf-8',
autoclose=False)
fo.write(self.udata)
self.assertEqual(self.udrain.getvalue(), self.udata)
@@ -187,7 +188,7 @@
# With destination in binary mode, data must be binary string
# and is written as-is:
def test_write_bytes(self):
- fo = io.FileOutput(destination=self.bdrain, encoding='utf8',
+ fo = io.FileOutput(destination=self.bdrain, encoding='utf-8',
mode='wb', autoclose=False)
fo.write(self.bdata)
self.assertEqual(self.bdrain.getvalue(), self.bdata)
@@ -233,7 +234,7 @@
e.write(AttributeError(' e\xfc'))
self.assertEqual(buf.getvalue(), b'b\xfc u\\xfc e\\xfc')
# encode with `encoding` attribute
- e.encoding = 'utf8'
+ e.encoding = 'utf-8'
e.write(' u\xfc')
self.assertEqual(buf.getvalue(), b'b\xfc u\\xfc e\\xfc u\xc3\xbc')
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py 2022-06-10 11:08:46 UTC (rev 9067)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py 2022-06-13 12:05:08 UTC (rev 9068)
@@ -62,15 +62,16 @@
]
# some locales return non-ASCII characters for names of days or months
-if locale_encoding in ['utf8', 'utf-8', 'latin-1']:
+# ensure the directive handles them correctly
+if locale_encoding.lower() in ('utf8', 'utf-8', 'latin-1', 'iso8859-1'):
totest['decode date'] = [
["""\
-.. |date| date:: t\xc3glich
+.. |date| date:: täglich
""",
"""\
<document source="test data">
<substitution_definition names="date">
- t\xc3glich
+ täglich
"""],
]
Modified: trunk/docutils/test/test_writers/test_docutils_xml.py
===================================================================
--- trunk/docutils/test/test_writers/test_docutils_xml.py 2022-06-10 11:08:46 UTC (rev 9067)
+++ trunk/docutils/test/test_writers/test_docutils_xml.py 2022-06-13 12:05:08 UTC (rev 9068)
@@ -122,7 +122,7 @@
def publish_xml(settings, source):
- return docutils.core.publish_string(source=source.encode('utf8'),
+ return docutils.core.publish_string(source=source.encode('utf-8'),
reader_name='standalone',
writer_name='docutils_xml',
settings_overrides=settings)
@@ -134,7 +134,7 @@
class DocutilsXMLTestCase(DocutilsTestSupport.StandardTestCase):
- settings = {'input_encoding': 'utf8',
+ settings = {'input_encoding': 'utf-8',
'output_encoding': 'iso-8859-1',
'_disable_config': True,
'indents': False,
Modified: trunk/docutils/tools/dev/generate_punctuation_chars.py
===================================================================
--- trunk/docutils/tools/dev/generate_punctuation_chars.py 2022-06-10 11:08:46 UTC (rev 9067)
+++ trunk/docutils/tools/dev/generate_punctuation_chars.py 2022-06-13 12:05:08 UTC (rev 9068)
@@ -213,10 +213,10 @@
# 301F LOW DOUBLE PRIME QUOTATION MARK misses the opening pendant:
ucharlists['Ps'].insert(ucharlists['Pe'].index('\u301f'), '\u301d')
- # print(''.join(ucharlists['Ps']).encode('utf8')
- # print(''.join(ucharlists['Pe']).encode('utf8')
- # print(''.join(ucharlists['Pi']).encode('utf8')
- # print(''.join(ucharlists['Pf']).encode('utf8')
+ # print(''.join(ucharlists['Ps']).encode('utf-8')
+ # print(''.join(ucharlists['Pe']).encode('utf-8')
+ # print(''.join(ucharlists['Pi']).encode('utf-8')
+ # print(''.join(ucharlists['Pf']).encode('utf-8')
# The Docutils character categories
# ---------------------------------
@@ -364,10 +364,10 @@
print_differences(openers, o, 'openers')
if o_wide:
- print('+ openers-wide = r"""%s"""' % o_wide.encode('utf8'))
+ print('+ openers-wide = r"""%s"""' % o_wide.encode('utf-8'))
print_differences(closers, c, 'closers')
if c_wide:
- print('+ closers-wide = r"""%s"""' % c_wide.encode('utf8'))
+ print('+ closers-wide = r"""%s"""' % c_wide.encode('utf-8'))
print_differences(delimiters, d + d_wide, 'delimiters')
print_differences(closing_delimiters, cd, 'closing_delimiters')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-06-13 12:05:21
|
Revision: 9069
http://sourceforge.net/p/docutils/code/9069
Author: milde
Date: 2022-06-13 12:05:18 +0000 (Mon, 13 Jun 2022)
Log Message:
-----------
Small documentation fixes and updates.
Modified Paths:
--------------
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/index.txt
trunk/docutils/docs/user/latex.txt
trunk/docutils/docs/user/links.txt
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2022-06-13 12:05:08 UTC (rev 9068)
+++ trunk/docutils/RELEASE-NOTES.txt 2022-06-13 12:05:18 UTC (rev 9069)
@@ -58,6 +58,9 @@
- Remove ``use_verbatim_when_possible`` setting
(use literal_block_env_: verbatim) in Docutils 2.0.
+
+ - Do not insert ``\usepackage[utf8]{inputenc}`` into UTF-8 encoded
+ LaTeX sources. UTF-8 is the default encoding for LaTeX2e since 2018.
* `xetex` writer:
Modified: trunk/docutils/docs/index.txt
===================================================================
--- trunk/docutils/docs/index.txt 2022-06-13 12:05:08 UTC (rev 9068)
+++ trunk/docutils/docs/index.txt 2022-06-13 12:05:18 UTC (rev 9069)
@@ -109,9 +109,9 @@
* `Quick reStructuredText <user/rst/quickref.html>`__ (user reference)
* `reStructuredText Cheat Sheet <user/rst/cheatsheet.txt>`__ (text
only; 1 page for syntax, 1 page directive & role reference)
- * `reStructuredText Demonstration <user/rst/demo.html>`_ (a
- demonstration of most reStructuredText features; you can also have a
- look at the `text source <user/rst/demo.txt>`__)
+ * `Demonstration <user/rst/demo.html>`_
+ of most reStructuredText features
+ (see also the `text source <user/rst/demo.txt>`__)
Editor support:
* `Emacs support for reStructuredText <user/emacs.html>`_
Modified: trunk/docutils/docs/user/latex.txt
===================================================================
--- trunk/docutils/docs/user/latex.txt 2022-06-13 12:05:08 UTC (rev 9068)
+++ trunk/docutils/docs/user/latex.txt 2022-06-13 12:05:18 UTC (rev 9069)
@@ -1778,7 +1778,7 @@
``--output-encoding=OUTPUT-ENCODING``
Default:
- "utf8"
+ "utf-8"
Example:
Encode the LaTeX source file with the ISO `latin-1` (west european)
@@ -1787,7 +1787,7 @@
--output-encoding=latin-1
Note:
- LaTeX comes with two options for UTF-8 support,
+ 8-bit LaTeX comes with two options for UTF-8 support,
:utf8: by the standard `inputenc`_ package with only limited coverage
(mainly accented characters).
@@ -1796,8 +1796,8 @@
characters than does "utf8". It is, however, a non-standard
extension and no longer developed.
- Currently (in version 0.6), "utf8" is used if the output-encoding is
- any of "utf_8", "U8", "UTF", or "utf8".
+ Currently, the "latex2e" writer inserts ``\usepackage[utf8]{inputenc}``
+ into the LaTeX source if it is UTF-8 encoded.
.. with utf8x:
If LaTeX issues a Warning about unloaded/unknown characters adding ::
Modified: trunk/docutils/docs/user/links.txt
===================================================================
--- trunk/docutils/docs/user/links.txt 2022-06-13 12:05:08 UTC (rev 9068)
+++ trunk/docutils/docs/user/links.txt 2022-06-13 12:05:18 UTC (rev 9069)
@@ -48,13 +48,17 @@
- `Riv: Take notes in rst <https://github.com/Rykka/riv.vim>`__ Vim
plugin to take notes in reStructured text.
-* `JED <https://www.jedsoft.org/jed/>`__ programmers editor with
- `rst mode <httpss://jedmodes.sourceforge.io/mode/rst/>`__
+* `reStructuredText Language Support for Visual Studio Code`__
+ __ https://github.com/vscode-restructuredtext/vscode-restructuredtext
+
* `reStructuredText editor plug-in for Eclipse`__
__ http://resteditor.sourceforge.net/
+* `JED <https://www.jedsoft.org/jed/>`__ programmers editor with
+ `rst mode <httpss://jedmodes.sourceforge.io/mode/rst/>`__
+
* Gnome's gedit offers syntax highlighting and a reST preview pane.
Latest version of the plugin is available from `bittner @ github`_
@@ -63,6 +67,7 @@
.. _bittner @ github: https://github.com/bittner/gedit-reST-plugin
__ https://wiki.gnome.org/Apps/Gedit/ThirdPartyPlugins-v3.8
+
* Gunnar Schwant's DocFactory_ is a wxPython GUI application for
Docutils.
@@ -72,6 +77,10 @@
.. _ReSTedit: https://svn.red-bean.com/restedit/trunk/README.html
+* `ReText <https://pypi.org/project/ReText/>`_ is a simple but powerful
+ editor for Markdown and reStructuredText markup languages.
+ It is written in Python using PyQt libraries.
+
* Leo_ is an outliner_, written in Python using PyQt. It can be used as IDE
for literal programming, as a filing cabinet holding any kind of data and
as `document editor`__ with outlines containing reStructuredText markup.
@@ -329,7 +338,7 @@
* `Project Gutenberg`_ uses Docutils for its "ebookmaker_"
xetex, nroff, and epub generator (with some `extensions to rST`__).
-
+
__ http://pgrst.pglaf.org/publish/181/181-h.html
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-06-13 12:05:47
|
Revision: 9070
http://sourceforge.net/p/docutils/code/9070
Author: milde
Date: 2022-06-13 12:05:32 +0000 (Mon, 13 Jun 2022)
Log Message:
-----------
Fix some problems with HTML5 stylesheets. Add tests for "tuftig.css".
Ignore footnote back-references, when copying from Firefox.
Small tweaks for tuftig.css.
Modified Paths:
--------------
trunk/docutils/docutils/writers/html5_polyglot/minimal.css
trunk/docutils/docutils/writers/html5_polyglot/tuftig.css
Added Paths:
-----------
trunk/docutils/test/functional/expected/rst_html5_tuftig.html
trunk/docutils/test/functional/input/data/tuftig.css
trunk/docutils/test/functional/input/rst_html5_tuftig.txt
trunk/docutils/test/functional/tests/standalone_rst_html5_tuftig.py
Modified: trunk/docutils/docutils/writers/html5_polyglot/minimal.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2022-06-13 12:05:18 UTC (rev 9069)
+++ trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2022-06-13 12:05:32 UTC (rev 9070)
@@ -172,6 +172,7 @@
vertical-align: inherit;
}
+.backrefs { user-select: none; }
.backrefs > a { font-style: italic; }
/* superscript footnotes */
Modified: trunk/docutils/docutils/writers/html5_polyglot/tuftig.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/tuftig.css 2022-06-13 12:05:18 UTC (rev 9069)
+++ trunk/docutils/docutils/writers/html5_polyglot/tuftig.css 2022-06-13 12:05:32 UTC (rev 9070)
@@ -45,6 +45,7 @@
/* vertical space (parskip) */
p, ol, ul, dl, li,
+h1, h2, h3, h4, h5, h6,
div.line-block,
.topic,
.footnote, .citation,
@@ -52,7 +53,6 @@
margin-top: 0.5em;
margin-bottom: 0.5em;
}
-h1, h2, h3, h4, h5, h6,
dl > dd {
margin-bottom: 0.5em;
}
@@ -110,8 +110,8 @@
margin-bottom: 2em;
font-size: 2.0em;
}
-h2, h3, h4 {
- margin-top: 2.0em;
+section {
+ margin-top: 2em;
}
h2, .contents > p.topic-title {
font-size: 2.2em;
@@ -222,6 +222,9 @@
}
/* Citation list (style as description list) */
+.citation-list {
+ display: contents;
+}
.citation {
padding-left: 1.5em;
}
@@ -469,7 +472,11 @@
}
.citation.align-left {
font-size: 1em;
+ padding-left: 1.5em;
}
+ .citation.align-left .label {
+ margin-left: -1.5em;
+ }
figure > img { /* indent */
margin: 0.5em 2%;
padding-left: 1em;
@@ -478,14 +485,14 @@
/* Margin Elements */
/* Sidebar, Footnotes, Citations, Captions */
aside.sidebar,
+ .citation,
.footnote,
- .citation-list,
figcaption,
/* table > caption, does not work :(*/
.marginal,
.admonition.marginal,
.topic.marginal {
- /* background-color: Lavender; */
+ /* color: red; */
grid-column: margin;
width: auto;
max-width: 55em;
@@ -503,13 +510,15 @@
display: block;
margin: 0.5em 0;
}
- .citation {
+ .citation,
+ .footnote {
padding-left: 0;
}
- .footnote .label,
- .citation .label {
+ .citation .label,
+ .footnote .label {
margin-left: 0;
}
+
/* Fullwidth Elements */
h1.title, p.subtitle,
dl.docinfo,
Added: trunk/docutils/test/functional/expected/rst_html5_tuftig.html
===================================================================
--- trunk/docutils/test/functional/expected/rst_html5_tuftig.html (rev 0)
+++ trunk/docutils/test/functional/expected/rst_html5_tuftig.html 2022-06-13 12:05:32 UTC (rev 9070)
@@ -0,0 +1,141 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta charset="utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1" />
+<meta name="generator" content="Docutils 0.19b.dev: https://docutils.sourceforge.io/" />
+<title>Special Features of the tuftig.css Stylesheet</title>
+<link rel="stylesheet" href="../input/data/minimal.css" type="text/css" />
+<link rel="stylesheet" href="../input/data/tuftig.css" type="text/css" />
+</head>
+<body>
+<main id="special-features-of-the-tuftig-css-stylesheet">
+<h1 class="title">Special Features of the <cite>tuftig.css</cite> Stylesheet</h1>
+
+<p><span class="docutils literal">tuftig.css</span> is a <a class="reference external" href="http://www.w3.org/TR/CSS3">CSS3</a> style sheet for the output of Docutils’
+HTML5 writer. The rules are inspired by <a class="citation-reference" href="#tufte-css" id="citation-reference-1" role="doc-biblioref">[tufte.css]</a> and
+<a class="citation-reference" href="#tufte-latex" id="citation-reference-2" role="doc-biblioref">[tufte-latex]</a> going back to Edward Tufte’s layout design.</p>
+<div role="list" class="citation-list">
+<div class="citation" id="tufte-css" role="doc-biblioentry">
+<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#citation-reference-1">tufte.css</a><span class="fn-bracket">]</span></span>
+<p>Dave Liepmann, <cite>Tufte CSS</cite>,
+<a class="reference external" href="https://edwardtufte.github.io/tufte-css/">https://edwardtufte.github.io/tufte-css/</a>.</p>
+</div>
+<div class="citation" id="tufte-latex" role="doc-biblioentry">
+<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#citation-reference-2">tufte-latex</a><span class="fn-bracket">]</span></span>
+<p>Bil Kleb, Bill Wood and Kevin Godby,
+<cite>A Tufte-Style Book</cite>,
+<a class="reference external" href="https://www.ctan.org/pkg/tufte-latex">https://www.ctan.org/pkg/tufte-latex</a>.</p>
+</div>
+</div>
+<section id="fullwidth-and-margin-objects">
+<h2>Fullwidth and Margin Objects</h2>
+<p class="fullwidth">Block elements (paragraphs, admonitions, topics, figures, tables, …)
+with the “fullwidth” class argument use full text width.</p>
+<table class="booktabs numbered captionbelow fullwidth">
+<caption>A fullwidth table with LaTeX math commands</caption>
+<tbody>
+<tr><td><p><cite>arccos</cite></p></td>
+<td><p><span class="docutils literal">\arccos</span></p></td>
+<td><p><cite>gcd</cite></p></td>
+<td><p><span class="docutils literal">\gcd</span></p></td>
+<td><p><cite>Pr</cite></p></td>
+<td><p><span class="docutils literal">\Pr</span></p></td>
+</tr>
+<tr><td><p><cite>arcsin</cite></p></td>
+<td><p><span class="docutils literal">\arcsin</span></p></td>
+<td><p><cite>hom</cite></p></td>
+<td><p><span class="docutils literal">\hom</span></p></td>
+<td><p><cite>projlim</cite></p></td>
+<td><p><span class="docutils literal">\projlim</span></p></td>
+</tr>
+</tbody>
+</table>
+<figure class="numbered fullwidth">
+<img alt="reStructuredText, the markup syntax" src="../../../docs/user/rst/images/title.svg" style="width: 90%; height: 1.5em;" />
+<figcaption>
+<p>A numbered fullwidth figure.</p>
+</figcaption>
+</figure>
+<p>Block elements (admonitions, figures, tables, …) with the
+“marginal” class argument are set in the right margin (if place permits).</p>
+<p class="marginal">An ordinary paragraph with the “marginal” class argument.</p>
+<p>Tight integration of graphics with text is central to Tufte’s work
+even when those graphics are ancillary to the main body of a text. In
+many of those cases, a margin figure may be most appropriate.</p>
+<figure class="marginal numbered">
+<img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 2em;" />
+<figcaption>
+<p>This is a marginal figure.</p>
+<div class="legend">
+<p>This is the legend.</p>
+</div>
+</figcaption>
+</figure>
+<p>To place an image in the margin, use a marginal figure without caption.</p>
+<figure class="marginal">
+<img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 2em;" />
+</figure>
+<p>Marginal objects are placed to the right of the preceding main text
+block.</p>
+<aside class="admonition marginal note">
+<p class="admonition-title">Note</p>
+<p>This is a “note” type admonition with a block-quote inside.</p>
+<blockquote>
+<p>This is a silly text that is only there to
+demonstrate line wrapping.</p>
+</blockquote>
+</aside>
+<p>By default, citations and footnotes are set in the margin.
+To have them in the main text area (like <a class="citation-reference" href="#testbook" id="citation-reference-3" role="doc-biblioref">[Testbook]</a> and <a class="citation-reference" href="#tb98" id="citation-reference-4" role="doc-biblioref">[tb98]</a> here),
+use the “align-left” class value.</p>
+<div role="list" class="citation-list">
+<div class="citation align-left" id="testbook" role="doc-biblioentry">
+<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#citation-reference-3">Testbook</a><span class="fn-bracket">]</span></span>
+<p>John Ex Ample, <cite>How to test web pages</cite>, Ontario, 1978.</p>
+</div>
+<div class="citation align-left" id="tb98" lang="de" role="doc-biblioentry">
+<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#citation-reference-4">tb98</a><span class="fn-bracket">]</span></span>
+<p>Horst Schramm, <cite>Docutils 0.5</cite>, in Testberichte III,
+Leipzig, 1998.</p>
+</div>
+</div>
+<table class="booktabs numbered captionbelow marginal">
+<caption>A marginal table</caption>
+<thead>
+<tr><th class="head"><p>A</p></th>
+<th class="head"><p>B</p></th>
+<th class="head"><p>A or B</p></th>
+</tr>
+</thead>
+<tbody>
+<tr><td><p>False</p></td>
+<td><p>False</p></td>
+<td><p>False</p></td>
+</tr>
+<tr><td><p>True</p></td>
+<td><p>False</p></td>
+<td><p>True</p></td>
+</tr>
+<tr><td><p>False</p></td>
+<td><p>True</p></td>
+<td><p>True</p></td>
+</tr>
+<tr><td><p>True</p></td>
+<td><p>True</p></td>
+<td><p>True</p></td>
+</tr>
+</tbody>
+</table>
+<aside class="footnote superscript align-left" id="not-in-margin" role="note">
+<span class="label"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></span>
+<p>The “align-left” class value ensures this footnote is set
+in the main text area.</p>
+</aside>
+</section>
+</main>
+<footer>
+<p><a class="reference external image-reference" href="http://www.w3.org/TR/html5/"><img alt="Conforms to HTML 5" src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" style="width: 88px; height: 31px;" /></a> <a class="reference external image-reference" href="http://validator.w3.org/check?uri=referer"><img alt="Check validity!" src="https://www.w3.org/Icons/ValidatorSuite/vs-blue-190.png" style="width: 88px; height: 31px;" /></a> <a class="reference external image-reference" href="http://jigsaw.w3.org/css-validator/check/referer"><img alt="Valid CSS 2.1!" src="http://jigsaw.w3.org/css-validator/images/vcss" style="width: 88px; height: 31px;" /></a></p>
+</footer>
+</body>
+</html>
Property changes on: trunk/docutils/test/functional/expected/rst_html5_tuftig.html
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/test/functional/input/data/tuftig.css
===================================================================
--- trunk/docutils/test/functional/input/data/tuftig.css (rev 0)
+++ trunk/docutils/test/functional/input/data/tuftig.css 2022-06-13 12:05:32 UTC (rev 9070)
@@ -0,0 +1 @@
+link ../../../../docutils/writers/html5_polyglot/tuftig.css
\ No newline at end of file
Property changes on: trunk/docutils/test/functional/input/data/tuftig.css
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/docutils/test/functional/input/rst_html5_tuftig.txt
===================================================================
--- trunk/docutils/test/functional/input/rst_html5_tuftig.txt (rev 0)
+++ trunk/docutils/test/functional/input/rst_html5_tuftig.txt 2022-06-13 12:05:32 UTC (rev 9070)
@@ -0,0 +1,125 @@
+Special Features of the `tuftig.css` Stylesheet
+===============================================
+
+``tuftig.css`` is a CSS3_ style sheet for the output of Docutils'
+HTML5 writer. The rules are inspired by [tufte.css]_ and
+[tufte-latex]_ going back to Edward Tufte's layout design.
+
+.. [tufte.css] Dave Liepmann, `Tufte CSS`,
+ https://edwardtufte.github.io/tufte-css/.
+.. [tufte-latex] Bil Kleb, Bill Wood and Kevin Godby,
+ `A Tufte-Style Book`,
+ https://www.ctan.org/pkg/tufte-latex.
+
+.. _CSS3: http://www.w3.org/TR/CSS3
+
+
+Fullwidth and Margin Objects
+----------------------------
+
+.. class:: fullwidth
+
+Block elements (paragraphs, admonitions, topics, figures, tables, ...)
+with the "fullwidth" class argument use full text width.
+
+
+.. table:: A fullwidth table with LaTeX math commands
+ :class: numbered colwidths-auto fullwidth
+
+ ========= =========== ========= =========== ============= ================
+ `\arccos` ``\arccos`` `\gcd` ``\gcd`` `\Pr` ``\Pr``
+ `\arcsin` ``\arcsin`` `\hom` ``\hom`` `\projlim` ``\projlim``
+ ========= =========== ========= =========== ============= ================
+
+.. figure:: ../../../docs/user/rst/images/title.svg
+ :alt: reStructuredText, the markup syntax
+ :width: 90%
+ :height: 1.5em
+ :figclass: numbered fullwidth
+
+ A numbered fullwidth figure.
+
+Block elements (admonitions, figures, tables, ...) with the
+"marginal" class argument are set in the right margin (if place permits).
+
+.. class:: marginal
+
+An ordinary paragraph with the "marginal" class argument.
+
+Tight integration of graphics with text is central to Tufte’s work
+even when those graphics are ancillary to the main body of a text. In
+many of those cases, a margin figure may be most appropriate.
+
+.. figure:: ../../../docs/user/rst/images/biohazard.png
+ :figclass: marginal numbered
+ :width: 2em
+
+ This is a marginal figure.
+
+ This is the legend.
+
+To place an image in the margin, use a marginal figure without caption.
+
+.. figure:: ../../../docs/user/rst/images/biohazard.png
+ :figclass: marginal
+ :width: 2em
+
+Marginal objects are placed to the right of the preceding main text
+block.
+
+.. Note:: This is a "note" type admonition with a block-quote inside.
+ :class: marginal
+
+ This is a silly text that is only there to
+ demonstrate line wrapping.
+
+By default, citations and footnotes are set in the margin.
+To have them in the main text area (like [Testbook]_ and [tb98]_ here),
+use the "align-left" class value.
+
+.. class:: align-left
+
+.. [Testbook] John Ex Ample, `How to test web pages`, Ontario, 1978.
+
+.. class:: align-left language-de
+
+.. [tb98] Horst Schramm, `Docutils 0.5`, in Testberichte III,
+ Leipzig, 1998.
+
+.. table:: A marginal table
+ :widths: auto
+ :class: marginal
+
+ ======= ======= ==========
+ A B A or B
+ ======= ======= ==========
+ False False False
+ True False True
+ False True True
+ True True True
+ ======= ======= ==========
+
+.. class:: align-left
+
+.. [#not-in-margin] The "align-left" class value ensures this footnote is set
+ in the main text area.
+
+.. footer:: |HTML 5| |validator| |valid-CSS2|
+
+.. |HTML 5| image:: http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png
+ :height: 31
+ :width: 88
+ :alt: Conforms to HTML 5
+ :target: http://www.w3.org/TR/html5/
+
+.. |validator| image:: https://www.w3.org/Icons/ValidatorSuite/vs-blue-190.png
+ :height: 31
+ :width: 88
+ :alt: Check validity!
+ :target: http://validator.w3.org/check?uri=referer
+
+.. |valid-CSS2| image:: http://jigsaw.w3.org/css-validator/images/vcss
+ :height: 31
+ :width: 88
+ :alt: Valid CSS 2.1!
+ :target: http://jigsaw.w3.org/css-validator/check/referer
Property changes on: trunk/docutils/test/functional/input/rst_html5_tuftig.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/test/functional/tests/standalone_rst_html5_tuftig.py
===================================================================
--- trunk/docutils/test/functional/tests/standalone_rst_html5_tuftig.py (rev 0)
+++ trunk/docutils/test/functional/tests/standalone_rst_html5_tuftig.py 2022-06-13 12:05:32 UTC (rev 9070)
@@ -0,0 +1,18 @@
+with open('functional/tests/_standalone_rst_defaults.py') as _f:
+ exec(_f.read())
+
+# Source and destination file names.
+test_source = "rst_html5_tuftig.txt"
+test_destination = "rst_html5_tuftig.html"
+
+# Keyword parameters passed to publish_file.
+writer_name = "html5"
+
+# Settings:
+settings_overrides['smart_quotes'] = 'yes'
+settings_overrides['footnote_references'] = 'superscript'
+settings_overrides['table_style'] = 'booktabs numbered captionbelow'
+# local copy of stylesheets:
+# (Test runs in ``docutils/test/``, we need relative path from there.)
+settings_overrides['stylesheet_dirs'] = ('.', 'functional/input/data')
+settings_overrides['stylesheet_path'] = 'minimal.css, tuftig.css'
Property changes on: trunk/docutils/test/functional/tests/standalone_rst_html5_tuftig.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-06-14 16:09:32
|
Revision: 9071
http://sourceforge.net/p/docutils/code/9071
Author: milde
Date: 2022-06-14 16:09:29 +0000 (Tue, 14 Jun 2022)
Log Message:
-----------
Document planned switch of the default HTML writer in Docutils 2.0.
Modified Paths:
--------------
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/user/html.txt
trunk/docutils/docs/user/tools.txt
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2022-06-13 12:05:32 UTC (rev 9070)
+++ trunk/docutils/RELEASE-NOTES.txt 2022-06-14 16:09:29 UTC (rev 9071)
@@ -83,8 +83,8 @@
__ docs/ref/transforms.html
-* The default HTML writer "html" with frontend ``rst2html.py`` may change
- from "html4css1" to "html5".
+* The default HTML writer "html" with frontend ``rst2html.py`` will change
+ from "html4css1" to "html5" in Docutils 2.0.
Use ``get_writer_by_name('html')`` or the rst2html.py_ front end, if you
want the output to be up-to-date automatically.
Modified: trunk/docutils/docs/user/html.txt
===================================================================
--- trunk/docutils/docs/user/html.txt 2022-06-13 12:05:32 UTC (rev 9070)
+++ trunk/docutils/docs/user/html.txt 2022-06-14 16:09:29 UTC (rev 9071)
@@ -10,10 +10,11 @@
----
`html` is an alias for the default Docutils HTML writer.
-Currently, `html` is mapped to html4css1_.
-The target may change with the development of HTML, browsers, Docutils, and
-the web.
+The default may change with the development of HTML, browsers, Docutils,
+and the web.
+Currently, `html` is mapped to html4css1_, it will become an alias for
+html5_ in Docutils 2.0.
* Use ``get_writer_by_name('html')`` or the rst2html.py_ front end, if you
want the output to be up-to-date automatically.
@@ -88,10 +89,10 @@
.. _theme: tools.html#themes
-html5_polyglot
---------------
+html5
+-----
-:aliases: html5
+:aliases: _`html5_polyglot`
:front-end: rst2html5.py_
:config: `[html5 writer]`_
Modified: trunk/docutils/docs/user/tools.txt
===================================================================
--- trunk/docutils/docs/user/tools.txt 2022-06-13 12:05:32 UTC (rev 9070)
+++ trunk/docutils/docs/user/tools.txt 2022-06-14 16:09:29 UTC (rev 9071)
@@ -156,7 +156,8 @@
`rst2html.py` is the front-end for the default Docutils HTML writer.
The default writer may change with the development of HTML, browsers,
-Docutils, and the web. Currently, it is html4css1_.
+Docutils, and the web.
+The current default is html4css1_, it will change to html5_ in Docutils 2.0.
.. caution::
Use a specific front end like rst2html4.py_ or rst2html5.py_,
@@ -223,7 +224,7 @@
CSS style sheet. The provided style sheets ``minimal.css`` and ``plain.css``
define required and optional styling rules respectively.
-.. _html5: html.html#html5-polyglot
+.. _html5: html.html#html5
rstpep2html.py
--------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-06-15 11:31:11
|
Revision: 9072
http://sourceforge.net/p/docutils/code/9072
Author: milde
Date: 2022-06-15 11:31:09 +0000 (Wed, 15 Jun 2022)
Log Message:
-----------
Add encoding arguments when opening files.
Specify intended incoding, when possible.
Avoids `EncodingWarning` in PEP 597 and nasty surprises
if the default encoding is not what the user expects.
Keep encoding unspecified where this may be an API change.
Based on patch by Adam Turner.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/user/slide-shows.txt
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/docutils/writers/s5_html/__init__.py
trunk/docutils/test/alltests.py
trunk/docutils/test/functional/tests/footnotes_html5.py
trunk/docutils/test/functional/tests/standalone_rst_docutils_xml.py
trunk/docutils/test/functional/tests/standalone_rst_html4css1.py
trunk/docutils/test/functional/tests/standalone_rst_html5.py
trunk/docutils/test/functional/tests/standalone_rst_latex.py
trunk/docutils/test/functional/tests/standalone_rst_manpage.py
trunk/docutils/test/functional/tests/standalone_rst_pseudoxml.py
trunk/docutils/test/functional/tests/standalone_rst_s5_html_1.py
trunk/docutils/test/functional/tests/standalone_rst_s5_html_2.py
trunk/docutils/test/functional/tests/standalone_rst_xetex.py
trunk/docutils/test/test_CLI.py
trunk/docutils/test/test_functional.py
trunk/docutils/tools/dev/unicode2rstsubs.py
trunk/docutils/tools/test/test_buildhtml.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/HISTORY.txt 2022-06-15 11:31:09 UTC (rev 9072)
@@ -105,6 +105,10 @@
__ https://packaging.python.org/en/latest/specifications/entry-points/
+* test/alltests.py
+
+ - Always encode the log file "alltests.out" using 'utf-8'.
+
* test/DocutilsTestSupport.py
- `exception_data()` now returns None if no exception was raised.
Modified: trunk/docutils/docs/user/slide-shows.txt
===================================================================
--- trunk/docutils/docs/user/slide-shows.txt 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/docs/user/slide-shows.txt 2022-06-15 11:31:09 UTC (rev 9072)
@@ -474,11 +474,6 @@
.. container:: handout
- Themes from the `S5 tutorial`__ can be used. These themes are in
- the public domain and may be redistributed freely.
-
- __ http://meyerweb.com/eric/tools/s5/s5blank.zip
-
Sites with other S5 themes:
* http://meyerweb.com/eric/tools/s5/themes/
@@ -485,8 +480,8 @@
* http://mozilla.wikicities.com/wiki/Firefox_S5:Designs
* http://lachy.id.au/dev/mozilla/firefox/s5/
* http://www.openlight.com/Python-S5-Theme.tar.gz
-
- S5 is becoming more popular every day. Do a web search for "S5
+
+ Do a web search for "S5
theme" and you're bound to find plenty of choices.
* "``--theme``" option.
@@ -659,7 +654,7 @@
2. Copy ``ui/<base-theme>`` to ``ui/<new-theme>``.
-3. Edit the styles.
+3. Edit the styles (save in UTF-8 encoding).
.. class:: handout
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/docutils/statemachine.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -92,7 +92,8 @@
one-line strings. For example, to read text from a file called
'inputfile'::
- input_string = open('inputfile').read()
+ with open('inputfile', encoding='utf-8') as fp:
+ input_string = fp.read()
input_lines = statemachine.string2lines(input_string)
5. Run the state machine on the input text and collect the results, a list::
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -936,7 +936,7 @@
stylespath = self.settings.stylesheet
ext = os.path.splitext(stylespath)[1]
if ext == '.xml':
- with open(stylespath, 'r') as stylesfile:
+ with open(stylespath, 'r', encoding='utf-8') as stylesfile:
s1 = stylesfile.read()
elif ext == extension:
zfile = zipfile.ZipFile(stylespath, 'r')
Modified: trunk/docutils/docutils/writers/s5_html/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/s5_html/__init__.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/docutils/writers/s5_html/__init__.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -216,7 +216,7 @@
base_theme_file = os.path.join(path, self.base_theme_file)
# If it exists, read it and record the theme path:
if os.path.isfile(base_theme_file):
- with open(base_theme_file) as f:
+ with open(base_theme_file, encoding='utf-8') as f:
lines = f.readlines()
for line in lines:
line = line.strip()
Modified: trunk/docutils/test/alltests.py
===================================================================
--- trunk/docutils/test/alltests.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/test/alltests.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -30,7 +30,8 @@
"""Write to a file and a stream (default: stdout) simultaneously."""
def __init__(self, filename, stream=sys.__stdout__):
- self.file = open(filename, 'w', errors='backslashreplace')
+ self.file = open(filename, 'w', encoding='utf-8',
+ errors='backslashreplace')
atexit.register(self.close)
self.stream = stream
self.encoding = getattr(stream, 'encoding', None)
Modified: trunk/docutils/test/functional/tests/footnotes_html5.py
===================================================================
--- trunk/docutils/test/functional/tests/footnotes_html5.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/test/functional/tests/footnotes_html5.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -1,4 +1,5 @@
-with open('functional/tests/_standalone_rst_defaults.py') as _f:
+with open('functional/tests/_standalone_rst_defaults.py',
+ encoding='utf-8') as _f:
exec(_f.read())
# Source and destination file names.
Modified: trunk/docutils/test/functional/tests/standalone_rst_docutils_xml.py
===================================================================
--- trunk/docutils/test/functional/tests/standalone_rst_docutils_xml.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/test/functional/tests/standalone_rst_docutils_xml.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -1,4 +1,5 @@
-with open('functional/tests/_standalone_rst_defaults.py') as _f:
+with open('functional/tests/_standalone_rst_defaults.py',
+ encoding='utf-8') as _f:
exec(_f.read())
# Source and destination file names.
Modified: trunk/docutils/test/functional/tests/standalone_rst_html4css1.py
===================================================================
--- trunk/docutils/test/functional/tests/standalone_rst_html4css1.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/test/functional/tests/standalone_rst_html4css1.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -1,4 +1,5 @@
-with open('functional/tests/_standalone_rst_defaults.py') as _f:
+with open('functional/tests/_standalone_rst_defaults.py',
+ encoding='utf-8') as _f:
exec(_f.read())
# Source and destination file names.
Modified: trunk/docutils/test/functional/tests/standalone_rst_html5.py
===================================================================
--- trunk/docutils/test/functional/tests/standalone_rst_html5.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/test/functional/tests/standalone_rst_html5.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -1,4 +1,5 @@
-with open('functional/tests/_standalone_rst_defaults.py') as _f:
+with open('functional/tests/_standalone_rst_defaults.py',
+ encoding='utf-8') as _f:
exec(_f.read())
# Source and destination file names.
Modified: trunk/docutils/test/functional/tests/standalone_rst_latex.py
===================================================================
--- trunk/docutils/test/functional/tests/standalone_rst_latex.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/test/functional/tests/standalone_rst_latex.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -1,4 +1,5 @@
-with open('functional/tests/_standalone_rst_defaults.py') as _f:
+with open('functional/tests/_standalone_rst_defaults.py',
+ encoding='utf-8') as _f:
exec(_f.read())
# Source and destination file names.
Modified: trunk/docutils/test/functional/tests/standalone_rst_manpage.py
===================================================================
--- trunk/docutils/test/functional/tests/standalone_rst_manpage.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/test/functional/tests/standalone_rst_manpage.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -1,4 +1,5 @@
-with open('functional/tests/_standalone_rst_defaults.py') as _f:
+with open('functional/tests/_standalone_rst_defaults.py',
+ encoding='utf-8') as _f:
exec(_f.read())
# Source and destination file names.
Modified: trunk/docutils/test/functional/tests/standalone_rst_pseudoxml.py
===================================================================
--- trunk/docutils/test/functional/tests/standalone_rst_pseudoxml.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/test/functional/tests/standalone_rst_pseudoxml.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -1,4 +1,5 @@
-with open('functional/tests/_standalone_rst_defaults.py') as _f:
+with open('functional/tests/_standalone_rst_defaults.py',
+ encoding='utf-8') as _f:
exec(_f.read())
# Source and destination file names.
Modified: trunk/docutils/test/functional/tests/standalone_rst_s5_html_1.py
===================================================================
--- trunk/docutils/test/functional/tests/standalone_rst_s5_html_1.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/test/functional/tests/standalone_rst_s5_html_1.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -1,7 +1,8 @@
import filecmp as _filecmp
-with open('functional/tests/_standalone_rst_defaults.py') as _f:
+with open('functional/tests/_standalone_rst_defaults.py',
+ encoding='utf-8') as _f:
exec(_f.read())
# Source and destination file names:
Modified: trunk/docutils/test/functional/tests/standalone_rst_s5_html_2.py
===================================================================
--- trunk/docutils/test/functional/tests/standalone_rst_s5_html_2.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/test/functional/tests/standalone_rst_s5_html_2.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -1,5 +1,6 @@
# initialize with the settings & definitions from test 1:
-with open('functional/tests/standalone_rst_s5_html_1.py') as _f:
+with open('functional/tests/standalone_rst_s5_html_1.py',
+ encoding='utf-8') as _f:
exec(_f.read())
# overrides specific to this test:
Modified: trunk/docutils/test/functional/tests/standalone_rst_xetex.py
===================================================================
--- trunk/docutils/test/functional/tests/standalone_rst_xetex.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/test/functional/tests/standalone_rst_xetex.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -1,4 +1,5 @@
-with open('functional/tests/_standalone_rst_defaults.py') as _f:
+with open('functional/tests/_standalone_rst_defaults.py',
+ encoding='utf-8') as _f:
exec(_f.read())
# Source and destination file names.
Modified: trunk/docutils/test/test_CLI.py
===================================================================
--- trunk/docutils/test/test_CLI.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/test/test_CLI.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -67,7 +67,7 @@
f'{frontend.OptionParser.default_error_encoding}:backslashreplace',
'utf-8:backslashreplace')
# compare to stored version
- with open('data/help/docutils.txt') as samplefile:
+ with open('data/help/docutils.txt', encoding='utf-8') as samplefile:
expected = samplefile.read()
if expected != output:
print_mismatch(expected, output)
Modified: trunk/docutils/test/test_functional.py
===================================================================
--- trunk/docutils/test/test_functional.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/test/test_functional.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -117,10 +117,11 @@
namespace['settings_overrides'] = {'_disable_config': True}
# Read the variables set in the default config file and in
# the current config file into namespace:
- with open(join_path(datadir, 'tests', '_default.py')) as f:
+ with open(join_path(datadir, 'tests', '_default.py'),
+ encoding='utf-8') as f:
defaultpy = f.read()
exec(defaultpy, namespace)
- with open(self.configfile) as f:
+ with open(self.configfile, encoding='utf-8') as f:
exec(f.read(), namespace)
# Check for required settings:
assert 'test_source' in namespace,\
Modified: trunk/docutils/tools/dev/unicode2rstsubs.py
===================================================================
--- trunk/docutils/tools/dev/unicode2rstsubs.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/tools/dev/unicode2rstsubs.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -169,7 +169,7 @@
outname = set_name + '-wide.txt'
else:
outname = set_name + '.txt'
- outfile = open(outname, 'w')
+ outfile = open(outname, 'w', encoding='ascii')
print('writing file "%s"' % outname)
outfile.write(self.header + '\n')
set = self.sets[set_name]
Modified: trunk/docutils/tools/test/test_buildhtml.py
===================================================================
--- trunk/docutils/tools/test/test_buildhtml.py 2022-06-14 16:09:29 UTC (rev 9071)
+++ trunk/docutils/tools/test/test_buildhtml.py 2022-06-15 11:31:09 UTC (rev 9072)
@@ -81,7 +81,7 @@
if "." not in s:
os.mkdir(s)
else:
- fd_s = open(s, "w")
+ fd_s = open(s, "w", encoding='utf-8')
fd_s.write("dummy")
fd_s.close()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-06-15 15:28:38
|
Revision: 9074
http://sourceforge.net/p/docutils/code/9074
Author: milde
Date: 2022-06-15 15:28:35 +0000 (Wed, 15 Jun 2022)
Log Message:
-----------
Ensure locale_encoding is lower case.
Use `locale.getpreferredencoding(False)` since we dropped support
for older Python versions with side-effects.
Modified Paths:
--------------
trunk/docutils/docutils/io.py
trunk/docutils/docutils/utils/error_reporting.py
trunk/docutils/test/test_io.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2022-06-15 15:28:26 UTC (rev 9073)
+++ trunk/docutils/docutils/io.py 2022-06-15 15:28:35 UTC (rev 9074)
@@ -19,16 +19,20 @@
from docutils import TransformSpec
-# Guess the locale's encoding.
+# Guess the locale's preferred encoding.
# If no valid guess can be made, locale_encoding is set to `None`:
+#
+# TODO: check whether this is set correctly with every OS and Python version
+# or whether front-end tools need to call `locale.setlocale()`
+# before importing this module
try:
- locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
+ locale_encoding = locale.getpreferredencoding(do_setlocale=False).lower()
except ValueError as error: # OS X may set UTF-8 without language code
# See https://bugs.python.org/issue18378 fixed in 3.8
# and https://sourceforge.net/p/docutils/bugs/298/.
# Drop the special case after requiring Python >= 3.8
if "unknown locale: UTF-8" in error.args:
- locale_encoding = "UTF-8"
+ locale_encoding = "utf-8"
else:
locale_encoding = None
except: # noqa any other problems determining the locale -> use None
Modified: trunk/docutils/docutils/utils/error_reporting.py
===================================================================
--- trunk/docutils/docutils/utils/error_reporting.py 2022-06-15 15:28:26 UTC (rev 9073)
+++ trunk/docutils/docutils/utils/error_reporting.py 2022-06-15 15:28:35 UTC (rev 9074)
@@ -45,41 +45,17 @@
common exceptions.
"""
-import codecs
import sys
import warnings
+from docutils.io import locale_encoding
+
warnings.warn('The `docutils.utils.error_reporting` module is deprecated '
'and will be removed in Docutils 0.21 or later.\n'
'Details with help("docutils.utils.error_reporting").',
DeprecationWarning, stacklevel=2)
-# Guess the locale's encoding.
-# If no valid guess can be made, locale_encoding is set to `None`:
-try:
- import locale # module missing in Jython
-except ImportError:
- locale_encoding = None
-else:
- try:
- locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
- # locale.getpreferredencoding([do_setlocale=True|False])
- # has side-effects | might return a wrong guess.
- except ValueError as error: # OS X may set UTF-8 without language code
- # see http://bugs.python.org/issue18378
- # and https://sourceforge.net/p/docutils/bugs/298/
- if "unknown locale: UTF-8" in error.args:
- locale_encoding = "UTF-8"
- else:
- locale_encoding = None
- except: # noqa any other problems determining the locale -> use None
- locale_encoding = None
- try:
- codecs.lookup(locale_encoding or '') # None -> ''
- except LookupError:
- locale_encoding = None
-
if sys.version_info >= (3, 0):
unicode = str # noqa
Modified: trunk/docutils/test/test_io.py
===================================================================
--- trunk/docutils/test/test_io.py 2022-06-15 15:28:26 UTC (rev 9073)
+++ trunk/docutils/test/test_io.py 2022-06-15 15:28:35 UTC (rev 9074)
@@ -132,7 +132,7 @@
def test_heuristics_no_utf8(self):
# if no encoding is given and decoding with utf-8 fails,
# use either the locale encoding (if specified) or latin-1:
- if io.locale_encoding.lower() not in ('utf-8', 'utf8'):
+ if io.locale_encoding not in ('utf-8', 'utf8'):
# in Py3k, the locale encoding is used without --input-encoding
# skipping the heuristic unless decoding fails.
return
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py 2022-06-15 15:28:26 UTC (rev 9073)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py 2022-06-15 15:28:35 UTC (rev 9074)
@@ -63,7 +63,7 @@
# some locales return non-ASCII characters for names of days or months
# ensure the directive handles them correctly
-if locale_encoding.lower() in ('utf8', 'utf-8', 'latin-1', 'iso8859-1'):
+if locale_encoding in ('utf-8', 'utf8', 'latin-1', 'iso-8859-1'):
totest['decode date'] = [
["""\
.. |date| date:: täglich
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|