|
From: <mi...@us...> - 2021-12-23 14:55:04
|
Revision: 8915
http://sourceforge.net/p/docutils/code/8915
Author: milde
Date: 2021-12-23 14:55:01 +0000 (Thu, 23 Dec 2021)
Log Message:
-----------
docutils-cli.py: allow drop-in components for reader and parser.
Now also reader and parser may be 3rd party modules:
specify the import name of the module containing the parser.
Fix help output.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/tools/docutils-cli.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2021-12-23 14:54:51 UTC (rev 8914)
+++ trunk/docutils/HISTORY.txt 2021-12-23 14:55:01 UTC (rev 8915)
@@ -20,8 +20,14 @@
* test/test_parsers/test_rst/test_directives/test_tables.py
- - Change for python 3.11.0a2 csv modules supports null character.
+ - Fix bug #436: Null char valid in CSV since Python 3.11.
+* tools/docutils-cli.py
+
+ - Allow 3rd-party drop-in components for reader and parser, too.
+ - Fix help output.
+
+
Release 0.18.1
==============
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2021-12-23 14:54:51 UTC (rev 8914)
+++ trunk/docutils/docs/user/config.txt 2021-12-23 14:55:01 UTC (rev 8915)
@@ -2144,11 +2144,14 @@
[docutils-cli application]
--------------------------
-New in 0.18.
+New in 0.17. Config file support added in 0.18.
+Support for reader/parser import names added in 0.19.
reader
~~~~~~
-Reader component name. One of "standalone" or "pep".
+Reader component name.
+One of "standalone", "pep",
+or the import name of a drop-in reader module.
Default: "standalone".
Option: ``--reader``
@@ -2156,6 +2159,8 @@
parser
~~~~~~
Parser component name.
+One of "rst", "markdown", "recommonmark",
+or the import name of a drop-in parser module.
Default: "rst".
Option: ``--parser``
@@ -2164,7 +2169,10 @@
writer
~~~~~~
-Writer component name. One of the valid writer names or aliases.
+Writer component name.
+One of "html", "html4", "html5", "latex", "xelatex", "odt", "xml",
+"pseudoxml", "manpage", "pep_html", "s5", an alias,
+or the import name of a drop-in writer module.
Default: "html5".
Option: ``--writer``
Modified: trunk/docutils/tools/docutils-cli.py
===================================================================
--- trunk/docutils/tools/docutils-cli.py 2021-12-23 14:54:51 UTC (rev 8914)
+++ trunk/docutils/tools/docutils-cli.py 2021-12-23 14:55:01 UTC (rev 8915)
@@ -27,7 +27,6 @@
import sys
from docutils.core import publish_cmdline, default_description
-from docutils.utils import SystemMessage
from docutils.frontend import ConfigParser, OptionParser
config_section = 'docutils-cli application'
@@ -56,7 +55,7 @@
description = u'Generate documents from reStructuredText or Markdown sources.'
-epilog = (u'The availability of some options depends on the selected '
+epilog = (u'Further optional arguments are added by the selected '
u'components, the list below adapts to your selection.'
)
@@ -64,21 +63,22 @@
description=description, epilog=epilog,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
-parser.add_argument('--reader', choices=('standalone', 'pep'),
- help=u'reader name',
+parser.add_argument('source', nargs='?')
+parser.add_argument('destination', nargs='?')
+parser.add_argument('--reader', help=u'reader name',
default=default_settings['reader'])
-parser.add_argument('--parser', choices=('markdown', 'recommonmark', 'rst'),
- help=u'parser name',
+parser.add_argument('--parser', help=u'parser name',
default=default_settings['parser'])
-parser.add_argument('--writer',
- # choices=('html', 'html4', 'html5', 'latex', 'xelatex',
- # 'odt', 'xml', 'pseudoxml', 'manpage',
- # 'pep_html', 's5_html'),
- help=u'writer name',
+parser.add_argument('--writer', help=u'writer name',
default=default_settings['writer'])
(args, remainder) = parser.parse_known_args()
+# push back positional arguments
+if args.destination:
+ remainder.insert(0, args.destination)
+if args.source:
+ remainder.insert(0, args.source)
if '-h' in sys.argv or '--help' in sys.argv:
print(parser.format_help())
@@ -92,5 +92,8 @@
description=default_description,
argv=remainder)
except ImportError as error:
- print(parser.format_help())
- print('ImportError:', error)
+ print('%s.' % error)
+ if '--traceback' in remainder:
+ raise
+ else:
+ print('Use "--traceback" to show details.')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|