summaryrefslogtreecommitdiff
path: root/docutils
diff options
context:
space:
mode:
authorgoodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2003-09-01 15:09:14 +0000
committergoodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2003-09-01 15:09:14 +0000
commit6bf1f3a52b24ff86ba93343d6a04e766601721de (patch)
tree56c9800a31464d488482d7ef05fda50649c8927c /docutils
parent4cc4108244ead4bfb994750ed1d9cd8675b41430 (diff)
downloaddocutils-6bf1f3a52b24ff86ba93343d6a04e766601721de.tar.gz
updated for setting validators
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1663 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
-rw-r--r--docutils/__init__.py12
-rw-r--r--docutils/parsers/rst/__init__.py7
-rw-r--r--docutils/readers/standalone.py8
-rw-r--r--docutils/writers/docutils_xml.py18
-rw-r--r--docutils/writers/html4css1.py15
-rw-r--r--docutils/writers/latex2e.py21
-rw-r--r--docutils/writers/pep_html.py5
7 files changed, 52 insertions, 34 deletions
diff --git a/docutils/__init__.py b/docutils/__init__.py
index 45ec3b2b0..2d2f012bc 100644
--- a/docutils/__init__.py
+++ b/docutils/__init__.py
@@ -78,10 +78,14 @@ class SettingsSpec:
`docutils.frontend.OptionParser`. This tuple contains one or more sets of
option group title, description, and a list/tuple of tuples: ``('help
text', [list of option strings], {keyword arguments})``. Group title
- and/or description may be `None`; no group title implies no group, just a
- list of single options. Runtime settings names are derived implicitly
- from long option names ("--a-setting" becomes ``settings.a_setting``) or
- explicitly from the "dest" keyword argument."""
+ and/or description may be `None`; a group title of `None` implies no
+ group, just a list of single options. The "keyword arguments" dictionary
+ contains arguments to the OptionParser/OptionGroup ``add_option`` method,
+ with the addition of a "validator" keyword (see the
+ `docutils.frontend.OptionParser.validators` instance attribute). Runtime
+ settings names are derived implicitly from long option names
+ ("--a-setting" becomes ``settings.a_setting``) or explicitly from the
+ "dest" keyword argument."""
settings_defaults = None
"""A dictionary of defaults for internal or inaccessible (by command-line
diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py
index 0b46ad9e8..679539fb9 100644
--- a/docutils/parsers/rst/__init__.py
+++ b/docutils/parsers/rst/__init__.py
@@ -75,6 +75,7 @@ __docformat__ = 'reStructuredText'
import docutils.parsers
import docutils.statemachine
from docutils.parsers.rst import states
+from docutils import frontend
class Parser(docutils.parsers.Parser):
@@ -89,16 +90,16 @@ class Parser(docutils.parsers.Parser):
None,
(('Recognize and link to PEP references (like "PEP 258").',
['--pep-references'],
- {'action': 'store_true'}),
+ {'action': 'store_true', 'validator': frontend.validate_boolean}),
('Recognize and link to RFC references (like "RFC 822").',
['--rfc-references'],
- {'action': 'store_true'}),
+ {'action': 'store_true', 'validator': frontend.validate_boolean}),
('Set number of spaces for tab expansion (default 8).',
['--tab-width'],
{'metavar': '<width>', 'type': 'int', 'default': 8}),
('Remove spaces before footnote references.',
['--trim-footnote-reference-space'],
- {'action': 'store_true'}),))
+ {'action': 'store_true', 'validator': frontend.validate_boolean}),))
config_section = 'restructuredtext parser'
config_section_dependencies = ('parsers',)
diff --git a/docutils/readers/standalone.py b/docutils/readers/standalone.py
index 43ca4c40b..cd69504ac 100644
--- a/docutils/readers/standalone.py
+++ b/docutils/readers/standalone.py
@@ -12,7 +12,7 @@ __docformat__ = 'reStructuredText'
import sys
-from docutils import readers
+from docutils import frontend, readers
from docutils.transforms import frontmatter, references
from docutils.parsers.rst import Parser
@@ -32,11 +32,13 @@ class Reader(readers.Reader):
'document title (and subsequent section title to document '
'subtitle promotion; enabled by default).',
['--no-doc-title'],
- {'dest': 'doctitle_xform', 'action': 'store_false', 'default': 1}),
+ {'dest': 'doctitle_xform', 'action': 'store_false', 'default': 1,
+ 'validator': frontend.validate_boolean}),
('Disable the bibliographic field list transform (enabled by '
'default).',
['--no-doc-info'],
- {'dest': 'docinfo_xform', 'action': 'store_false', 'default': 1}),))
+ {'dest': 'docinfo_xform', 'action': 'store_false', 'default': 1,
+ 'validator': frontend.validate_boolean}),))
config_section = 'standalone reader'
config_section_dependencies = ('readers',)
diff --git a/docutils/writers/docutils_xml.py b/docutils/writers/docutils_xml.py
index 0eaa4ed3c..cc730d873 100644
--- a/docutils/writers/docutils_xml.py
+++ b/docutils/writers/docutils_xml.py
@@ -12,7 +12,7 @@ __docformat__ = 'reStructuredText'
import docutils
-from docutils import writers
+from docutils import frontend, writers
class Writer(writers.Writer):
@@ -25,15 +25,19 @@ class Writer(writers.Writer):
'Warning: the --newlines and --indents options may adversely affect '
'whitespace; use them only for reading convenience.',
(('Generate XML with newlines before and after tags.',
- ['--newlines'], {'action': 'store_true'}),
+ ['--newlines'],
+ {'action': 'store_true', 'validator': frontend.validate_boolean}),
('Generate XML with indents and newlines.',
- ['--indents'], {'action': 'store_true'}),
+ ['--indents'],
+ {'action': 'store_true', 'validator': frontend.validate_boolean}),
('Omit the XML declaration. Use with caution.',
- ['--no-xml-declaration'], {'dest': 'xml_declaration', 'default': 1,
- 'action': 'store_false'}),
+ ['--no-xml-declaration'],
+ {'dest': 'xml_declaration', 'default': 1, 'action': 'store_false',
+ 'validator': frontend.validate_boolean}),
('Omit the DOCTYPE declaration.',
- ['--no-doctype'], {'dest': 'doctype_declaration', 'default': 1,
- 'action': 'store_false'}),))
+ ['--no-doctype'],
+ {'dest': 'doctype_declaration', 'default': 1,
+ 'action': 'store_false', 'validator': frontend.validate_boolean}),))
config_section = 'docutils_xml writer'
config_section_dependencies = ('writers',)
diff --git a/docutils/writers/html4css1.py b/docutils/writers/html4css1.py
index 5bc33d5ea..b50552c03 100644
--- a/docutils/writers/html4css1.py
+++ b/docutils/writers/html4css1.py
@@ -23,7 +23,7 @@ import time
import re
from types import ListType
import docutils
-from docutils import nodes, utils, writers, languages
+from docutils import frontend, nodes, utils, writers, languages
class Writer(writers.Writer):
@@ -46,14 +46,15 @@ class Writer(writers.Writer):
('Link to the stylesheet in the output HTML file. This is the '
'default.',
['--link-stylesheet'],
- {'dest': 'embed_stylesheet', 'action': 'store_false'}),
+ {'dest': 'embed_stylesheet', 'action': 'store_false',
+ 'validator': frontend.validate_boolean}),
('Embed the stylesheet in the output HTML file. The stylesheet '
'file must be accessible during processing (--stylesheet-path is '
'recommended). The stylesheet is embedded inside a comment, so it '
'must not contain the text "--" (two hyphens). Default: link the '
'stylesheet, do not embed it.',
['--embed-stylesheet'],
- {'action': 'store_true'}),
+ {'action': 'store_true', 'validator': frontend.validate_boolean}),
('Format for footnote references: one of "superscript" or '
'"brackets". Default is "superscript".',
['--footnote-references'],
@@ -69,13 +70,15 @@ class Writer(writers.Writer):
'items each contain one paragraph and/or one "simple" sublist '
'only). Default: enabled.',
['--compact-lists'],
- {'default': 1, 'action': 'store_true'}),
+ {'default': 1, 'action': 'store_true',
+ 'validator': frontend.validate_boolean}),
('Disable compact simple bullet and enumerated lists.',
['--no-compact-lists'],
{'dest': 'compact_lists', 'action': 'store_false'}),
('Omit the XML declaration. Use with caution.',
- ['--no-xml-declaration'], {'dest': 'xml_declaration', 'default': 1,
- 'action': 'store_false'}),))
+ ['--no-xml-declaration'],
+ {'dest': 'xml_declaration', 'default': 1, 'action': 'store_false',
+ 'validator': frontend.validate_boolean}),))
relative_path_settings = ('stylesheet_path',)
diff --git a/docutils/writers/latex2e.py b/docutils/writers/latex2e.py
index 26b2bcca8..2f763a56f 100644
--- a/docutils/writers/latex2e.py
+++ b/docutils/writers/latex2e.py
@@ -20,7 +20,7 @@ import time
import re
import string
from types import ListType
-from docutils import writers, nodes, languages
+from docutils import frontend, nodes, languages, writers
class Writer(writers.Writer):
@@ -36,7 +36,8 @@ class Writer(writers.Writer):
('Use LaTeX footnotes. '
'Default: no, uses figures.',
['--use-latex-footnotes'],
- {'default': 0, 'action': 'store_true'}),
+ {'default': 0, 'action': 'store_true',
+ 'validator': frontend.validate_boolean}),
('Format for footnote references: one of "superscript" or '
'"brackets". Default is "brackets".',
['--footnote-references'],
@@ -48,8 +49,8 @@ class Writer(writers.Writer):
{'choices': ['dash', 'parentheses', 'parens', 'none'],
'default': 'dash', 'metavar': '<format>'}),
('Specify a stylesheet file. The file will be "input" by latex in '
- 'the document header. Default is "no stylesheet". If this is set to '
- '"" disables input. Overridden by --stylesheet-path.',
+ 'the document header. Default is no stylesheet (""). '
+ 'Overridden by --stylesheet-path.',
['--stylesheet'],
{'default': '', 'metavar': '<file>'}),
('Specify a stylesheet file, relative to the current working '
@@ -59,16 +60,18 @@ class Writer(writers.Writer):
('Link to the stylesheet in the output LaTeX file. This is the '
'default.',
['--link-stylesheet'],
- {'dest': 'embed_stylesheet', 'action': 'store_false'}),
+ {'dest': 'embed_stylesheet', 'action': 'store_false',
+ 'validator': frontend.validate_boolean}),
('Embed the stylesheet in the output LaTeX file. The stylesheet '
'file must be accessible during processing (--stylesheet-path is '
'recommended).',
- ['--embed-stylesheet'],
- {'action': 'store_true'}),
- ('Table of contents by docutils (default) or latex. Latex(writer) '
+ ['--embed-stylesheet'], {'action': 'store_true'}),
+ ('Table of contents by docutils (default) or latex. Latex (writer) '
'supports only one ToC per document, but docutils does not write '
'pagenumbers.',
- ['--use-latex-toc'], {'default': 0}),
+ ['--use-latex-toc'],
+ {'default': 0, 'action': 'store_true',
+ 'validator': frontend.validate_boolean}),
('Color of any hyperlinks embedded in text '
'(default: "blue", "0" to disable).',
['--hyperlink-color'], {'default': 'blue'}),))
diff --git a/docutils/writers/pep_html.py b/docutils/writers/pep_html.py
index 5fa14309b..96c44cfb0 100644
--- a/docutils/writers/pep_html.py
+++ b/docutils/writers/pep_html.py
@@ -13,7 +13,7 @@ __docformat__ = 'reStructuredText'
import sys
import docutils
-from docutils import nodes, frontend, utils
+from docutils import frontend, nodes, utils
from docutils.writers import html4css1
@@ -35,7 +35,8 @@ class Writer(html4css1.Writer):
# Workaround for SourceForge's broken Python
# (``import random`` causes a segfault).
(frontend.SUPPRESS_HELP,
- ['--no-random'], {'action': 'store_true'}),))
+ ['--no-random'],
+ {'action': 'store_true', 'validator': frontend.validate_boolean}),))
settings_default_overrides = {'footnote_references': 'brackets'}