Initial commit
This commit is contained in:
@@ -0,0 +1,232 @@
|
||||
# $Id: __init__.py 8304 2019-07-30 09:51:07Z grubert $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
This is the Docutils (Python Documentation Utilities) package.
|
||||
|
||||
Package Structure
|
||||
=================
|
||||
|
||||
Modules:
|
||||
|
||||
- __init__.py: Contains component base classes, exception classes, and
|
||||
Docutils version information.
|
||||
|
||||
- core.py: Contains the ``Publisher`` class and ``publish_*()`` convenience
|
||||
functions.
|
||||
|
||||
- frontend.py: Runtime settings (command-line interface, configuration files)
|
||||
processing, for Docutils front-ends.
|
||||
|
||||
- io.py: Provides a uniform API for low-level input and output.
|
||||
|
||||
- nodes.py: Docutils document tree (doctree) node class library.
|
||||
|
||||
- statemachine.py: A finite state machine specialized for
|
||||
regular-expression-based text filters.
|
||||
|
||||
Subpackages:
|
||||
|
||||
- languages: Language-specific mappings of terms.
|
||||
|
||||
- parsers: Syntax-specific input parser modules or packages.
|
||||
|
||||
- readers: Context-specific input handlers which understand the data
|
||||
source and manage a parser.
|
||||
|
||||
- transforms: Modules used by readers and writers to modify DPS
|
||||
doctrees.
|
||||
|
||||
- utils: Contains the ``Reporter`` system warning class and miscellaneous
|
||||
utilities used by readers, writers, and transforms.
|
||||
|
||||
utils/urischemes.py: Contains a complete mapping of known URI addressing
|
||||
scheme names to descriptions.
|
||||
|
||||
- utils/math: Contains functions for conversion of mathematical notation
|
||||
between different formats (LaTeX, MathML, text, ...).
|
||||
|
||||
- writers: Format-specific output translators.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from collections import namedtuple
|
||||
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
__version__ = '0.15.2'
|
||||
"""Docutils version identifier (complies with PEP 440)::
|
||||
|
||||
major.minor[.micro][releaselevel[serial]][.dev]
|
||||
|
||||
For version comparison operations, use `__version_info__` (which see, below)
|
||||
rather than parsing the text of `__version__`.
|
||||
|
||||
See 'Version Numbering' in docs/dev/policies.txt.
|
||||
"""
|
||||
|
||||
VersionInfo = namedtuple(
|
||||
'VersionInfo', 'major minor micro releaselevel serial release')
|
||||
|
||||
__version_info__ = VersionInfo(
|
||||
major=0,
|
||||
minor=15,
|
||||
micro=2,
|
||||
releaselevel='final', # one of 'alpha', 'beta', 'candidate', 'final'
|
||||
# pre-release serial number (0 for final releases and active development):
|
||||
serial=0,
|
||||
release=True # True for official releases and pre-releases
|
||||
)
|
||||
"""Comprehensive version information tuple. See 'Version Numbering' in
|
||||
docs/dev/policies.txt."""
|
||||
|
||||
__version_details__ = 'release'
|
||||
"""Optional extra version details (e.g. 'snapshot 2005-05-29, r3410').
|
||||
(For development and release status see `__version_info__`.)
|
||||
"""
|
||||
|
||||
|
||||
class ApplicationError(Exception): pass
|
||||
class DataError(ApplicationError): pass
|
||||
|
||||
|
||||
class SettingsSpec:
|
||||
|
||||
"""
|
||||
Runtime setting specification base class.
|
||||
|
||||
SettingsSpec subclass objects used by `docutils.frontend.OptionParser`.
|
||||
"""
|
||||
|
||||
settings_spec = ()
|
||||
"""Runtime settings specification. Override in subclasses.
|
||||
|
||||
Defines runtime settings and associated command-line options, as used by
|
||||
`docutils.frontend.OptionParser`. This is a tuple of:
|
||||
|
||||
- Option group title (string or `None` which implies no group, just a list
|
||||
of single options).
|
||||
|
||||
- Description (string or `None`).
|
||||
|
||||
- A sequence of option tuples. Each consists of:
|
||||
|
||||
- Help text (string)
|
||||
|
||||
- List of option strings (e.g. ``['-Q', '--quux']``).
|
||||
|
||||
- Dictionary of keyword arguments sent to the OptionParser/OptionGroup
|
||||
``add_option`` method.
|
||||
|
||||
Runtime setting names are derived implicitly from long option names
|
||||
('--a-setting' becomes ``settings.a_setting``) or explicitly from the
|
||||
'dest' keyword argument.
|
||||
|
||||
Most settings will also have a 'validator' keyword & function. The
|
||||
validator function validates setting values (from configuration files
|
||||
and command-line option arguments) and converts them to appropriate
|
||||
types. For example, the ``docutils.frontend.validate_boolean``
|
||||
function, **required by all boolean settings**, converts true values
|
||||
('1', 'on', 'yes', and 'true') to 1 and false values ('0', 'off',
|
||||
'no', 'false', and '') to 0. Validators need only be set once per
|
||||
setting. See the `docutils.frontend.validate_*` functions.
|
||||
|
||||
See the optparse docs for more details.
|
||||
|
||||
- More triples of group title, description, options, as many times as
|
||||
needed. Thus, `settings_spec` tuples can be simply concatenated.
|
||||
"""
|
||||
|
||||
settings_defaults = None
|
||||
"""A dictionary of defaults for settings not in `settings_spec` (internal
|
||||
settings, intended to be inaccessible by command-line and config file).
|
||||
Override in subclasses."""
|
||||
|
||||
settings_default_overrides = None
|
||||
"""A dictionary of auxiliary defaults, to override defaults for settings
|
||||
defined in other components. Override in subclasses."""
|
||||
|
||||
relative_path_settings = ()
|
||||
"""Settings containing filesystem paths. Override in subclasses.
|
||||
Settings listed here are to be interpreted relative to the current working
|
||||
directory."""
|
||||
|
||||
config_section = None
|
||||
"""The name of the config file section specific to this component
|
||||
(lowercase, no brackets). Override in subclasses."""
|
||||
|
||||
config_section_dependencies = None
|
||||
"""A list of names of config file sections that are to be applied before
|
||||
`config_section`, in order (from general to specific). In other words,
|
||||
the settings in `config_section` are to be overlaid on top of the settings
|
||||
from these sections. The "general" section is assumed implicitly.
|
||||
Override in subclasses."""
|
||||
|
||||
|
||||
class TransformSpec:
|
||||
|
||||
"""
|
||||
Runtime transform specification base class.
|
||||
|
||||
TransformSpec subclass objects used by `docutils.transforms.Transformer`.
|
||||
"""
|
||||
|
||||
def get_transforms(self):
|
||||
"""Transforms required by this class. Override in subclasses."""
|
||||
if self.default_transforms != ():
|
||||
import warnings
|
||||
warnings.warn('default_transforms attribute deprecated.\n'
|
||||
'Use get_transforms() method instead.',
|
||||
DeprecationWarning)
|
||||
return list(self.default_transforms)
|
||||
return []
|
||||
|
||||
# Deprecated; for compatibility.
|
||||
default_transforms = ()
|
||||
|
||||
unknown_reference_resolvers = ()
|
||||
"""List of functions to try to resolve unknown references. Unknown
|
||||
references have a 'refname' attribute which doesn't correspond to any
|
||||
target in the document. Called when the transforms in
|
||||
`docutils.tranforms.references` are unable to find a correct target. The
|
||||
list should contain functions which will try to resolve unknown
|
||||
references, with the following signature::
|
||||
|
||||
def reference_resolver(node):
|
||||
'''Returns boolean: true if resolved, false if not.'''
|
||||
|
||||
If the function is able to resolve the reference, it should also remove
|
||||
the 'refname' attribute and mark the node as resolved::
|
||||
|
||||
del node['refname']
|
||||
node.resolved = 1
|
||||
|
||||
Each function must have a "priority" attribute which will affect the order
|
||||
the unknown_reference_resolvers are run::
|
||||
|
||||
reference_resolver.priority = 100
|
||||
|
||||
Override in subclasses."""
|
||||
|
||||
|
||||
class Component(SettingsSpec, TransformSpec):
|
||||
|
||||
"""Base class for Docutils components."""
|
||||
|
||||
component_type = None
|
||||
"""Name of the component type ('reader', 'parser', 'writer'). Override in
|
||||
subclasses."""
|
||||
|
||||
supported = ()
|
||||
"""Names for this component. Override in subclasses."""
|
||||
|
||||
def supports(self, format):
|
||||
"""
|
||||
Is `format` supported by this component?
|
||||
|
||||
To be used by transforms to ask the dependent component if it supports
|
||||
a certain input context or output format.
|
||||
"""
|
||||
return format in self.supported
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
# $Id: _compat.py 8164 2017-08-14 11:28:48Z milde $
|
||||
# Author: Georg Brandl <georg@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
Python 2/3 compatibility definitions.
|
||||
|
||||
This module currently provides the following helper symbols:
|
||||
|
||||
* u_prefix (unicode repr prefix: 'u' in 2.x, '' in 3.x)
|
||||
(Required in docutils/test/test_publisher.py)
|
||||
* BytesIO (a StringIO class that works with bytestrings)
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
u_prefix = 'u'
|
||||
from io import StringIO as BytesIO
|
||||
else:
|
||||
u_prefix = b''
|
||||
# using this hack since 2to3 "fixes" the relative import
|
||||
# when using ``from io import BytesIO``
|
||||
BytesIO = __import__('io').BytesIO
|
||||
665
parkingkonceptvenv/lib/python3.7/site-packages/docutils/core.py
Normal file
665
parkingkonceptvenv/lib/python3.7/site-packages/docutils/core.py
Normal file
@@ -0,0 +1,665 @@
|
||||
# $Id: core.py 8126 2017-06-23 09:34:28Z milde $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
Calling the ``publish_*`` convenience functions (or instantiating a
|
||||
`Publisher` object) with component names will result in default
|
||||
behavior. For custom behavior (setting component options), create
|
||||
custom component objects first, and pass *them* to
|
||||
``publish_*``/`Publisher`. See `The Docutils Publisher`_.
|
||||
|
||||
.. _The Docutils Publisher: http://docutils.sf.net/docs/api/publisher.html
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
import sys
|
||||
import pprint
|
||||
from docutils import __version__, __version_details__, SettingsSpec
|
||||
from docutils import frontend, io, utils, readers, writers
|
||||
from docutils.frontend import OptionParser
|
||||
from docutils.transforms import Transformer
|
||||
from docutils.utils.error_reporting import ErrorOutput, ErrorString
|
||||
import docutils.readers.doctree
|
||||
|
||||
class Publisher:
|
||||
|
||||
"""
|
||||
A facade encapsulating the high-level logic of a Docutils system.
|
||||
"""
|
||||
|
||||
def __init__(self, reader=None, parser=None, writer=None,
|
||||
source=None, source_class=io.FileInput,
|
||||
destination=None, destination_class=io.FileOutput,
|
||||
settings=None):
|
||||
"""
|
||||
Initial setup. If any of `reader`, `parser`, or `writer` are not
|
||||
specified, the corresponding ``set_...`` method should be called with
|
||||
a component name (`set_reader` sets the parser as well).
|
||||
"""
|
||||
|
||||
self.document = None
|
||||
"""The document tree (`docutils.nodes` objects)."""
|
||||
|
||||
self.reader = reader
|
||||
"""A `docutils.readers.Reader` instance."""
|
||||
|
||||
self.parser = parser
|
||||
"""A `docutils.parsers.Parser` instance."""
|
||||
|
||||
self.writer = writer
|
||||
"""A `docutils.writers.Writer` instance."""
|
||||
|
||||
for component in 'reader', 'parser', 'writer':
|
||||
assert not isinstance(getattr(self, component), str), (
|
||||
'passed string "%s" as "%s" parameter; pass an instance, '
|
||||
'or use the "%s_name" parameter instead (in '
|
||||
'docutils.core.publish_* convenience functions).'
|
||||
% (getattr(self, component), component, component))
|
||||
|
||||
self.source = source
|
||||
"""The source of input data, a `docutils.io.Input` instance."""
|
||||
|
||||
self.source_class = source_class
|
||||
"""The class for dynamically created source objects."""
|
||||
|
||||
self.destination = destination
|
||||
"""The destination for docutils output, a `docutils.io.Output`
|
||||
instance."""
|
||||
|
||||
self.destination_class = destination_class
|
||||
"""The class for dynamically created destination objects."""
|
||||
|
||||
self.settings = settings
|
||||
"""An object containing Docutils settings as instance attributes.
|
||||
Set by `self.process_command_line()` or `self.get_settings()`."""
|
||||
|
||||
self._stderr = ErrorOutput()
|
||||
|
||||
def set_reader(self, reader_name, parser, parser_name):
|
||||
"""Set `self.reader` by name."""
|
||||
reader_class = readers.get_reader_class(reader_name)
|
||||
self.reader = reader_class(parser, parser_name)
|
||||
self.parser = self.reader.parser
|
||||
|
||||
def set_writer(self, writer_name):
|
||||
"""Set `self.writer` by name."""
|
||||
writer_class = writers.get_writer_class(writer_name)
|
||||
self.writer = writer_class()
|
||||
|
||||
def set_components(self, reader_name, parser_name, writer_name):
|
||||
if self.reader is None:
|
||||
self.set_reader(reader_name, self.parser, parser_name)
|
||||
if self.parser is None:
|
||||
if self.reader.parser is None:
|
||||
self.reader.set_parser(parser_name)
|
||||
self.parser = self.reader.parser
|
||||
if self.writer is None:
|
||||
self.set_writer(writer_name)
|
||||
|
||||
def setup_option_parser(self, usage=None, description=None,
|
||||
settings_spec=None, config_section=None,
|
||||
**defaults):
|
||||
if config_section:
|
||||
if not settings_spec:
|
||||
settings_spec = SettingsSpec()
|
||||
settings_spec.config_section = config_section
|
||||
parts = config_section.split()
|
||||
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(
|
||||
components=(self.parser, self.reader, self.writer, settings_spec),
|
||||
defaults=defaults, read_config_files=True,
|
||||
usage=usage, description=description)
|
||||
return option_parser
|
||||
|
||||
def get_settings(self, usage=None, description=None,
|
||||
settings_spec=None, config_section=None, **defaults):
|
||||
"""
|
||||
Set and return default settings (overrides in `defaults` dict).
|
||||
|
||||
Set components first (`self.set_reader` & `self.set_writer`).
|
||||
Explicitly setting `self.settings` disables command line option
|
||||
processing from `self.publish()`.
|
||||
"""
|
||||
option_parser = self.setup_option_parser(
|
||||
usage, description, settings_spec, config_section, **defaults)
|
||||
self.settings = option_parser.get_default_values()
|
||||
return self.settings
|
||||
|
||||
def process_programmatic_settings(self, settings_spec,
|
||||
settings_overrides,
|
||||
config_section):
|
||||
if self.settings is None:
|
||||
defaults = (settings_overrides or {}).copy()
|
||||
# Propagate exceptions by default when used programmatically:
|
||||
defaults.setdefault('traceback', True)
|
||||
self.get_settings(settings_spec=settings_spec,
|
||||
config_section=config_section,
|
||||
**defaults)
|
||||
|
||||
def process_command_line(self, argv=None, usage=None, description=None,
|
||||
settings_spec=None, config_section=None,
|
||||
**defaults):
|
||||
"""
|
||||
Pass an empty list to `argv` to avoid reading `sys.argv` (the
|
||||
default).
|
||||
|
||||
Set components first (`self.set_reader` & `self.set_writer`).
|
||||
"""
|
||||
option_parser = self.setup_option_parser(
|
||||
usage, description, settings_spec, config_section, **defaults)
|
||||
if argv is None:
|
||||
argv = sys.argv[1:]
|
||||
# converting to Unicode (Python 3 does this automatically):
|
||||
if sys.version_info < (3,0):
|
||||
# TODO: make this failsafe and reversible?
|
||||
argv_encoding = (frontend.locale_encoding or 'ascii')
|
||||
argv = [a.decode(argv_encoding) for a in argv]
|
||||
self.settings = option_parser.parse_args(argv)
|
||||
|
||||
def set_io(self, source_path=None, destination_path=None):
|
||||
if self.source is None:
|
||||
self.set_source(source_path=source_path)
|
||||
if self.destination is None:
|
||||
self.set_destination(destination_path=destination_path)
|
||||
|
||||
def set_source(self, source=None, source_path=None):
|
||||
if source_path is None:
|
||||
source_path = self.settings._source
|
||||
else:
|
||||
self.settings._source = source_path
|
||||
# Raise IOError instead of system exit with `tracback == True`
|
||||
# TODO: change io.FileInput's default behaviour and remove this hack
|
||||
try:
|
||||
self.source = self.source_class(
|
||||
source=source, source_path=source_path,
|
||||
encoding=self.settings.input_encoding)
|
||||
except TypeError:
|
||||
self.source = self.source_class(
|
||||
source=source, source_path=source_path,
|
||||
encoding=self.settings.input_encoding)
|
||||
|
||||
def set_destination(self, destination=None, destination_path=None):
|
||||
if destination_path is None:
|
||||
destination_path = self.settings._destination
|
||||
else:
|
||||
self.settings._destination = destination_path
|
||||
self.destination = self.destination_class(
|
||||
destination=destination, destination_path=destination_path,
|
||||
encoding=self.settings.output_encoding,
|
||||
error_handler=self.settings.output_encoding_error_handler)
|
||||
|
||||
def apply_transforms(self):
|
||||
self.document.transformer.populate_from_components(
|
||||
(self.source, self.reader, self.reader.parser, self.writer,
|
||||
self.destination))
|
||||
self.document.transformer.apply_transforms()
|
||||
|
||||
def publish(self, argv=None, usage=None, description=None,
|
||||
settings_spec=None, settings_overrides=None,
|
||||
config_section=None, enable_exit_status=False):
|
||||
"""
|
||||
Process command line options and arguments (if `self.settings` not
|
||||
already set), run `self.reader` and then `self.writer`. Return
|
||||
`self.writer`'s output.
|
||||
"""
|
||||
exit = None
|
||||
try:
|
||||
if self.settings is None:
|
||||
self.process_command_line(
|
||||
argv, usage, description, settings_spec, config_section,
|
||||
**(settings_overrides or {}))
|
||||
self.set_io()
|
||||
self.document = self.reader.read(self.source, self.parser,
|
||||
self.settings)
|
||||
self.apply_transforms()
|
||||
output = self.writer.write(self.document, self.destination)
|
||||
self.writer.assemble_parts()
|
||||
except SystemExit as error:
|
||||
exit = 1
|
||||
exit_status = error.code
|
||||
except Exception as error:
|
||||
if not self.settings: # exception too early to report nicely
|
||||
raise
|
||||
if self.settings.traceback: # Propagate exceptions?
|
||||
self.debugging_dumps()
|
||||
raise
|
||||
self.report_Exception(error)
|
||||
exit = True
|
||||
exit_status = 1
|
||||
self.debugging_dumps()
|
||||
if (enable_exit_status and self.document
|
||||
and (self.document.reporter.max_level
|
||||
>= self.settings.exit_status_level)):
|
||||
sys.exit(self.document.reporter.max_level + 10)
|
||||
elif exit:
|
||||
sys.exit(exit_status)
|
||||
return output
|
||||
|
||||
def debugging_dumps(self):
|
||||
if not self.document:
|
||||
return
|
||||
if self.settings.dump_settings:
|
||||
print('\n::: Runtime settings:', file=self._stderr)
|
||||
print(pprint.pformat(self.settings.__dict__), file=self._stderr)
|
||||
if self.settings.dump_internals:
|
||||
print('\n::: Document internals:', file=self._stderr)
|
||||
print(pprint.pformat(self.document.__dict__), file=self._stderr)
|
||||
if self.settings.dump_transforms:
|
||||
print('\n::: Transforms applied:', file=self._stderr)
|
||||
print((' (priority, transform class, '
|
||||
'pending node details, keyword args)'), file=self._stderr)
|
||||
print(pprint.pformat(
|
||||
[(priority, '%s.%s' % (xclass.__module__, xclass.__name__),
|
||||
pending and pending.details, kwargs)
|
||||
for priority, xclass, pending, kwargs
|
||||
in self.document.transformer.applied]), file=self._stderr)
|
||||
if self.settings.dump_pseudo_xml:
|
||||
print('\n::: Pseudo-XML:', file=self._stderr)
|
||||
print(self.document.pformat().encode(
|
||||
'raw_unicode_escape'), file=self._stderr)
|
||||
|
||||
def report_Exception(self, error):
|
||||
if isinstance(error, utils.SystemMessage):
|
||||
self.report_SystemMessage(error)
|
||||
elif isinstance(error, UnicodeEncodeError):
|
||||
self.report_UnicodeError(error)
|
||||
elif isinstance(error, io.InputError):
|
||||
self._stderr.write('Unable to open source file for reading:\n'
|
||||
' %s\n' % ErrorString(error))
|
||||
elif isinstance(error, io.OutputError):
|
||||
self._stderr.write(
|
||||
'Unable to open destination file for writing:\n'
|
||||
' %s\n' % ErrorString(error))
|
||||
else:
|
||||
print('%s' % ErrorString(error), file=self._stderr)
|
||||
print(("""\
|
||||
Exiting due to error. Use "--traceback" to diagnose.
|
||||
Please report errors to <docutils-users@lists.sf.net>.
|
||||
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 '',
|
||||
sys.version.split()[0])), file=self._stderr)
|
||||
|
||||
def report_SystemMessage(self, error):
|
||||
print(('Exiting due to level-%s (%s) system message.'
|
||||
% (error.level,
|
||||
utils.Reporter.levels[error.level])), file=self._stderr)
|
||||
|
||||
def report_UnicodeError(self, error):
|
||||
data = error.object[error.start:error.end]
|
||||
self._stderr.write(
|
||||
'%s\n'
|
||||
'\n'
|
||||
'The specified output encoding (%s) cannot\n'
|
||||
'handle all of the output.\n'
|
||||
'Try setting "--output-encoding-error-handler" to\n'
|
||||
'\n'
|
||||
'* "xmlcharrefreplace" (for HTML & XML output);\n'
|
||||
' the output will contain "%s" and should be usable.\n'
|
||||
'* "backslashreplace" (for other output formats);\n'
|
||||
' look for "%s" in the output.\n'
|
||||
'* "replace"; look for "?" in the output.\n'
|
||||
'\n'
|
||||
'"--output-encoding-error-handler" is currently set to "%s".\n'
|
||||
'\n'
|
||||
'Exiting due to error. Use "--traceback" to diagnose.\n'
|
||||
'If the advice above doesn\'t eliminate the error,\n'
|
||||
'please report it to <docutils-users@lists.sf.net>.\n'
|
||||
'Include "--traceback" output, Docutils version (%s),\n'
|
||||
'Python version (%s), your OS type & version, and the\n'
|
||||
'command line used.\n'
|
||||
% (ErrorString(error),
|
||||
self.settings.output_encoding,
|
||||
data.encode('ascii', 'xmlcharrefreplace'),
|
||||
data.encode('ascii', 'backslashreplace'),
|
||||
self.settings.output_encoding_error_handler,
|
||||
__version__, sys.version.split()[0]))
|
||||
|
||||
default_usage = '%prog [options] [<source> [<destination>]]'
|
||||
default_description = ('Reads from <source> (default is stdin) and writes to '
|
||||
'<destination> (default is stdout). See '
|
||||
'<http://docutils.sf.net/docs/user/config.html> for '
|
||||
'the full reference.')
|
||||
|
||||
def publish_cmdline(reader=None, reader_name='standalone',
|
||||
parser=None, parser_name='restructuredtext',
|
||||
writer=None, writer_name='pseudoxml',
|
||||
settings=None, settings_spec=None,
|
||||
settings_overrides=None, config_section=None,
|
||||
enable_exit_status=True, argv=None,
|
||||
usage=default_usage, description=default_description):
|
||||
"""
|
||||
Set up & run a `Publisher` for command-line-based file I/O (input and
|
||||
output file paths taken automatically from the command line). Return the
|
||||
encoded string output also.
|
||||
|
||||
Parameters: see `publish_programmatically` for the remainder.
|
||||
|
||||
- `argv`: Command-line argument list to use instead of ``sys.argv[1:]``.
|
||||
- `usage`: Usage string, output if there's a problem parsing the command
|
||||
line.
|
||||
- `description`: Program description, output for the "--help" option
|
||||
(along with command-line option descriptions).
|
||||
"""
|
||||
pub = Publisher(reader, parser, writer, settings=settings)
|
||||
pub.set_components(reader_name, parser_name, writer_name)
|
||||
output = pub.publish(
|
||||
argv, usage, description, settings_spec, settings_overrides,
|
||||
config_section=config_section, enable_exit_status=enable_exit_status)
|
||||
return output
|
||||
|
||||
def publish_file(source=None, source_path=None,
|
||||
destination=None, destination_path=None,
|
||||
reader=None, reader_name='standalone',
|
||||
parser=None, parser_name='restructuredtext',
|
||||
writer=None, writer_name='pseudoxml',
|
||||
settings=None, settings_spec=None, settings_overrides=None,
|
||||
config_section=None, enable_exit_status=False):
|
||||
"""
|
||||
Set up & run a `Publisher` for programmatic use with file-like I/O.
|
||||
Return the encoded string output also.
|
||||
|
||||
Parameters: see `publish_programmatically`.
|
||||
"""
|
||||
output, pub = publish_programmatically(
|
||||
source_class=io.FileInput, source=source, source_path=source_path,
|
||||
destination_class=io.FileOutput,
|
||||
destination=destination, destination_path=destination_path,
|
||||
reader=reader, reader_name=reader_name,
|
||||
parser=parser, parser_name=parser_name,
|
||||
writer=writer, writer_name=writer_name,
|
||||
settings=settings, settings_spec=settings_spec,
|
||||
settings_overrides=settings_overrides,
|
||||
config_section=config_section,
|
||||
enable_exit_status=enable_exit_status)
|
||||
return output
|
||||
|
||||
def publish_string(source, source_path=None, destination_path=None,
|
||||
reader=None, reader_name='standalone',
|
||||
parser=None, parser_name='restructuredtext',
|
||||
writer=None, writer_name='pseudoxml',
|
||||
settings=None, settings_spec=None,
|
||||
settings_overrides=None, config_section=None,
|
||||
enable_exit_status=False):
|
||||
"""
|
||||
Set up & run a `Publisher` for programmatic use with string I/O. Return
|
||||
the encoded string or Unicode string output.
|
||||
|
||||
For encoded string output, be sure to set the 'output_encoding' setting to
|
||||
the desired encoding. Set it to 'unicode' for unencoded Unicode string
|
||||
output. Here's one way::
|
||||
|
||||
publish_string(..., settings_overrides={'output_encoding': 'unicode'})
|
||||
|
||||
Similarly for Unicode string input (`source`)::
|
||||
|
||||
publish_string(..., settings_overrides={'input_encoding': 'unicode'})
|
||||
|
||||
Parameters: see `publish_programmatically`.
|
||||
"""
|
||||
output, pub = publish_programmatically(
|
||||
source_class=io.StringInput, source=source, source_path=source_path,
|
||||
destination_class=io.StringOutput,
|
||||
destination=None, destination_path=destination_path,
|
||||
reader=reader, reader_name=reader_name,
|
||||
parser=parser, parser_name=parser_name,
|
||||
writer=writer, writer_name=writer_name,
|
||||
settings=settings, settings_spec=settings_spec,
|
||||
settings_overrides=settings_overrides,
|
||||
config_section=config_section,
|
||||
enable_exit_status=enable_exit_status)
|
||||
return output
|
||||
|
||||
def publish_parts(source, source_path=None, source_class=io.StringInput,
|
||||
destination_path=None,
|
||||
reader=None, reader_name='standalone',
|
||||
parser=None, parser_name='restructuredtext',
|
||||
writer=None, writer_name='pseudoxml',
|
||||
settings=None, settings_spec=None,
|
||||
settings_overrides=None, config_section=None,
|
||||
enable_exit_status=False):
|
||||
"""
|
||||
Set up & run a `Publisher`, and return a dictionary of document parts.
|
||||
Dictionary keys are the names of parts, and values are Unicode strings;
|
||||
encoding is up to the client. For programmatic use with string I/O.
|
||||
|
||||
For encoded string input, be sure to set the 'input_encoding' setting to
|
||||
the desired encoding. Set it to 'unicode' for unencoded Unicode string
|
||||
input. Here's how::
|
||||
|
||||
publish_parts(..., settings_overrides={'input_encoding': 'unicode'})
|
||||
|
||||
Parameters: see `publish_programmatically`.
|
||||
"""
|
||||
output, pub = publish_programmatically(
|
||||
source=source, source_path=source_path, source_class=source_class,
|
||||
destination_class=io.StringOutput,
|
||||
destination=None, destination_path=destination_path,
|
||||
reader=reader, reader_name=reader_name,
|
||||
parser=parser, parser_name=parser_name,
|
||||
writer=writer, writer_name=writer_name,
|
||||
settings=settings, settings_spec=settings_spec,
|
||||
settings_overrides=settings_overrides,
|
||||
config_section=config_section,
|
||||
enable_exit_status=enable_exit_status)
|
||||
return pub.writer.parts
|
||||
|
||||
def publish_doctree(source, source_path=None,
|
||||
source_class=io.StringInput,
|
||||
reader=None, reader_name='standalone',
|
||||
parser=None, parser_name='restructuredtext',
|
||||
settings=None, settings_spec=None,
|
||||
settings_overrides=None, config_section=None,
|
||||
enable_exit_status=False):
|
||||
"""
|
||||
Set up & run a `Publisher` for programmatic use with string I/O.
|
||||
Return the document tree.
|
||||
|
||||
For encoded string input, be sure to set the 'input_encoding' setting to
|
||||
the desired encoding. Set it to 'unicode' for unencoded Unicode string
|
||||
input. Here's one way::
|
||||
|
||||
publish_doctree(..., settings_overrides={'input_encoding': 'unicode'})
|
||||
|
||||
Parameters: see `publish_programmatically`.
|
||||
"""
|
||||
pub = Publisher(reader=reader, parser=parser, writer=None,
|
||||
settings=settings,
|
||||
source_class=source_class,
|
||||
destination_class=io.NullOutput)
|
||||
pub.set_components(reader_name, parser_name, 'null')
|
||||
pub.process_programmatic_settings(
|
||||
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)
|
||||
return pub.document
|
||||
|
||||
def publish_from_doctree(document, destination_path=None,
|
||||
writer=None, writer_name='pseudoxml',
|
||||
settings=None, settings_spec=None,
|
||||
settings_overrides=None, config_section=None,
|
||||
enable_exit_status=False):
|
||||
"""
|
||||
Set up & run a `Publisher` to render from an existing document
|
||||
tree data structure, for programmatic use with string I/O. Return
|
||||
the encoded string output.
|
||||
|
||||
Note that document.settings is overridden; if you want to use the settings
|
||||
of the original `document`, pass settings=document.settings.
|
||||
|
||||
Also, new document.transformer and document.reporter objects are
|
||||
generated.
|
||||
|
||||
For encoded string output, be sure to set the 'output_encoding' setting to
|
||||
the desired encoding. Set it to 'unicode' for unencoded Unicode string
|
||||
output. Here's one way::
|
||||
|
||||
publish_from_doctree(
|
||||
..., settings_overrides={'output_encoding': 'unicode'})
|
||||
|
||||
Parameters: `document` is a `docutils.nodes.document` object, an existing
|
||||
document tree.
|
||||
|
||||
Other parameters: see `publish_programmatically`.
|
||||
"""
|
||||
reader = docutils.readers.doctree.Reader(parser_name='null')
|
||||
pub = Publisher(reader, None, writer,
|
||||
source=io.DocTreeInput(document),
|
||||
destination_class=io.StringOutput, settings=settings)
|
||||
if not writer and writer_name:
|
||||
pub.set_writer(writer_name)
|
||||
pub.process_programmatic_settings(
|
||||
settings_spec, settings_overrides, config_section)
|
||||
pub.set_destination(None, destination_path)
|
||||
return pub.publish(enable_exit_status=enable_exit_status)
|
||||
|
||||
def publish_cmdline_to_binary(reader=None, reader_name='standalone',
|
||||
parser=None, parser_name='restructuredtext',
|
||||
writer=None, writer_name='pseudoxml',
|
||||
settings=None, settings_spec=None,
|
||||
settings_overrides=None, config_section=None,
|
||||
enable_exit_status=True, argv=None,
|
||||
usage=default_usage, description=default_description,
|
||||
destination=None, destination_class=io.BinaryFileOutput
|
||||
):
|
||||
"""
|
||||
Set up & run a `Publisher` for command-line-based file I/O (input and
|
||||
output file paths taken automatically from the command line). Return the
|
||||
encoded string output also.
|
||||
|
||||
This is just like publish_cmdline, except that it uses
|
||||
io.BinaryFileOutput instead of io.FileOutput.
|
||||
|
||||
Parameters: see `publish_programmatically` for the remainder.
|
||||
|
||||
- `argv`: Command-line argument list to use instead of ``sys.argv[1:]``.
|
||||
- `usage`: Usage string, output if there's a problem parsing the command
|
||||
line.
|
||||
- `description`: Program description, output for the "--help" option
|
||||
(along with command-line option descriptions).
|
||||
"""
|
||||
pub = Publisher(reader, parser, writer, settings=settings,
|
||||
destination_class=destination_class)
|
||||
pub.set_components(reader_name, parser_name, writer_name)
|
||||
output = pub.publish(
|
||||
argv, usage, description, settings_spec, settings_overrides,
|
||||
config_section=config_section, enable_exit_status=enable_exit_status)
|
||||
return output
|
||||
|
||||
def publish_programmatically(source_class, source, source_path,
|
||||
destination_class, destination, destination_path,
|
||||
reader, reader_name,
|
||||
parser, parser_name,
|
||||
writer, writer_name,
|
||||
settings, settings_spec,
|
||||
settings_overrides, config_section,
|
||||
enable_exit_status):
|
||||
"""
|
||||
Set up & run a `Publisher` for custom programmatic use. Return the
|
||||
encoded string output and the Publisher object.
|
||||
|
||||
Applications should not need to call this function directly. If it does
|
||||
seem to be necessary to call this function directly, please write to the
|
||||
Docutils-develop mailing list
|
||||
<http://docutils.sf.net/docs/user/mailing-lists.html#docutils-develop>.
|
||||
|
||||
Parameters:
|
||||
|
||||
* `source_class` **required**: The class for dynamically created source
|
||||
objects. Typically `io.FileInput` or `io.StringInput`.
|
||||
|
||||
* `source`: Type depends on `source_class`:
|
||||
|
||||
- If `source_class` is `io.FileInput`: Either a file-like object
|
||||
(must have 'read' and 'close' methods), or ``None``
|
||||
(`source_path` is opened). If neither `source` nor
|
||||
`source_path` are supplied, `sys.stdin` is used.
|
||||
|
||||
- If `source_class` is `io.StringInput` **required**: The input
|
||||
string, either an encoded 8-bit string (set the
|
||||
'input_encoding' setting to the correct encoding) or a Unicode
|
||||
string (set the 'input_encoding' setting to 'unicode').
|
||||
|
||||
* `source_path`: Type depends on `source_class`:
|
||||
|
||||
- `io.FileInput`: Path to the input file, opened if no `source`
|
||||
supplied.
|
||||
|
||||
- `io.StringInput`: Optional. Path to the file or object that produced
|
||||
`source`. Only used for diagnostic output.
|
||||
|
||||
* `destination_class` **required**: The class for dynamically created
|
||||
destination objects. Typically `io.FileOutput` or `io.StringOutput`.
|
||||
|
||||
* `destination`: Type depends on `destination_class`:
|
||||
|
||||
- `io.FileOutput`: Either a file-like object (must have 'write' and
|
||||
'close' methods), or ``None`` (`destination_path` is opened). If
|
||||
neither `destination` nor `destination_path` are supplied,
|
||||
`sys.stdout` is used.
|
||||
|
||||
- `io.StringOutput`: Not used; pass ``None``.
|
||||
|
||||
* `destination_path`: Type depends on `destination_class`:
|
||||
|
||||
- `io.FileOutput`: Path to the output file. Opened if no `destination`
|
||||
supplied.
|
||||
|
||||
- `io.StringOutput`: Path to the file or object which will receive the
|
||||
output; optional. Used for determining relative paths (stylesheets,
|
||||
source links, etc.).
|
||||
|
||||
* `reader`: A `docutils.readers.Reader` object.
|
||||
|
||||
* `reader_name`: Name or alias of the Reader class to be instantiated if
|
||||
no `reader` supplied.
|
||||
|
||||
* `parser`: A `docutils.parsers.Parser` object.
|
||||
|
||||
* `parser_name`: Name or alias of the Parser class to be instantiated if
|
||||
no `parser` supplied.
|
||||
|
||||
* `writer`: A `docutils.writers.Writer` object.
|
||||
|
||||
* `writer_name`: Name or alias of the Writer class to be instantiated if
|
||||
no `writer` supplied.
|
||||
|
||||
* `settings`: A runtime settings (`docutils.frontend.Values`) object, for
|
||||
dotted-attribute access to runtime settings. It's the end result of the
|
||||
`SettingsSpec`, config file, and option processing. If `settings` is
|
||||
passed, it's assumed to be complete and no further setting/config/option
|
||||
processing is done.
|
||||
|
||||
* `settings_spec`: A `docutils.SettingsSpec` subclass or object. Provides
|
||||
extra application-specific settings definitions independently of
|
||||
components. In other words, the application becomes a component, and
|
||||
its settings data is processed along with that of the other components.
|
||||
Used only if no `settings` specified.
|
||||
|
||||
* `settings_overrides`: A dictionary containing application-specific
|
||||
settings defaults that override the defaults of other components.
|
||||
Used only if no `settings` specified.
|
||||
|
||||
* `config_section`: A string, the name of the configuration file section
|
||||
for this application. Overrides the ``config_section`` attribute
|
||||
defined by `settings_spec`. Used only if no `settings` specified.
|
||||
|
||||
* `enable_exit_status`: Boolean; enable exit status at end of processing?
|
||||
"""
|
||||
pub = Publisher(reader, parser, writer, settings=settings,
|
||||
source_class=source_class,
|
||||
destination_class=destination_class)
|
||||
pub.set_components(reader_name, parser_name, writer_name)
|
||||
pub.process_programmatic_settings(
|
||||
settings_spec, settings_overrides, config_section)
|
||||
pub.set_source(source, source_path)
|
||||
pub.set_destination(destination, destination_path)
|
||||
output = pub.publish(enable_exit_status=enable_exit_status)
|
||||
return output, pub
|
||||
@@ -0,0 +1,97 @@
|
||||
# $Id: examples.py 7320 2012-01-19 22:33:02Z milde $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
This module contains practical examples of Docutils client code.
|
||||
|
||||
Importing this module from client code is not recommended; its contents are
|
||||
subject to change in future Docutils releases. Instead, it is recommended
|
||||
that you copy and paste the parts you need into your own code, modifying as
|
||||
necessary.
|
||||
"""
|
||||
|
||||
from docutils import core, io
|
||||
|
||||
|
||||
def html_parts(input_string, source_path=None, destination_path=None,
|
||||
input_encoding='unicode', doctitle=True,
|
||||
initial_header_level=1):
|
||||
"""
|
||||
Given an input string, returns a dictionary of HTML document parts.
|
||||
|
||||
Dictionary keys are the names of parts, and values are Unicode strings;
|
||||
encoding is up to the client.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `input_string`: A multi-line text string; required.
|
||||
- `source_path`: Path to the source file or object. Optional, but useful
|
||||
for diagnostic output (system messages).
|
||||
- `destination_path`: Path to the file or object which will receive the
|
||||
output; optional. Used for determining relative paths (stylesheets,
|
||||
source links, etc.).
|
||||
- `input_encoding`: The encoding of `input_string`. If it is an encoded
|
||||
8-bit string, provide the correct encoding. If it is a Unicode string,
|
||||
use "unicode", the default.
|
||||
- `doctitle`: Disable the promotion of a lone top-level section title to
|
||||
document title (and subsequent section title to document subtitle
|
||||
promotion); enabled by default.
|
||||
- `initial_header_level`: The initial level for header elements (e.g. 1
|
||||
for "<h1>").
|
||||
"""
|
||||
overrides = {'input_encoding': input_encoding,
|
||||
'doctitle_xform': doctitle,
|
||||
'initial_header_level': initial_header_level}
|
||||
parts = core.publish_parts(
|
||||
source=input_string, source_path=source_path,
|
||||
destination_path=destination_path,
|
||||
writer_name='html', settings_overrides=overrides)
|
||||
return parts
|
||||
|
||||
def html_body(input_string, source_path=None, destination_path=None,
|
||||
input_encoding='unicode', output_encoding='unicode',
|
||||
doctitle=True, initial_header_level=1):
|
||||
"""
|
||||
Given an input string, returns an HTML fragment as a string.
|
||||
|
||||
The return value is the contents of the <body> element.
|
||||
|
||||
Parameters (see `html_parts()` for the remainder):
|
||||
|
||||
- `output_encoding`: The desired encoding of the output. If a Unicode
|
||||
string is desired, use the default value of "unicode" .
|
||||
"""
|
||||
parts = html_parts(
|
||||
input_string=input_string, source_path=source_path,
|
||||
destination_path=destination_path,
|
||||
input_encoding=input_encoding, doctitle=doctitle,
|
||||
initial_header_level=initial_header_level)
|
||||
fragment = parts['html_body']
|
||||
if output_encoding != 'unicode':
|
||||
fragment = fragment.encode(output_encoding)
|
||||
return fragment
|
||||
|
||||
def internals(input_string, source_path=None, destination_path=None,
|
||||
input_encoding='unicode', settings_overrides=None):
|
||||
"""
|
||||
Return the document tree and publisher, for exploring Docutils internals.
|
||||
|
||||
Parameters: see `html_parts()`.
|
||||
"""
|
||||
if settings_overrides:
|
||||
overrides = settings_overrides.copy()
|
||||
else:
|
||||
overrides = {}
|
||||
overrides['input_encoding'] = input_encoding
|
||||
output, pub = core.publish_programmatically(
|
||||
source_class=io.StringInput, source=input_string,
|
||||
source_path=source_path,
|
||||
destination_class=io.NullOutput, destination=None,
|
||||
destination_path=destination_path,
|
||||
reader=None, reader_name='standalone',
|
||||
parser=None, parser_name='restructuredtext',
|
||||
writer=None, writer_name='null',
|
||||
settings=None, settings_spec=None, settings_overrides=overrides,
|
||||
config_section=None, enable_exit_status=None)
|
||||
return pub.writer.document, pub
|
||||
@@ -0,0 +1,854 @@
|
||||
# $Id: frontend.py 8126 2017-06-23 09:34:28Z milde $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
Command-line and common processing for Docutils front-end tools.
|
||||
|
||||
Exports the following classes:
|
||||
|
||||
* `OptionParser`: Standard Docutils command-line processing.
|
||||
* `Option`: Customized version of `optparse.Option`; validation support.
|
||||
* `Values`: Runtime settings; objects are simple structs
|
||||
(``object.attribute``). Supports cumulative list settings (attributes).
|
||||
* `ConfigParser`: Standard Docutils config file processing.
|
||||
|
||||
Also exports the following functions:
|
||||
|
||||
* Option callbacks: `store_multiple`, `read_config_file`.
|
||||
* Setting validators: `validate_encoding`,
|
||||
`validate_encoding_error_handler`,
|
||||
`validate_encoding_and_error_handler`,
|
||||
`validate_boolean`, `validate_ternary`, `validate_threshold`,
|
||||
`validate_colon_separated_string_list`,
|
||||
`validate_comma_separated_string_list`,
|
||||
`validate_dependency_file`.
|
||||
* `make_paths_absolute`.
|
||||
* SettingSpec manipulation: `filter_settings_spec`.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import warnings
|
||||
import configparser as CP
|
||||
import codecs
|
||||
import optparse
|
||||
from optparse import SUPPRESS_HELP
|
||||
import docutils
|
||||
import docutils.utils
|
||||
import docutils.nodes
|
||||
from docutils.utils.error_reporting import (locale_encoding, SafeString,
|
||||
ErrorOutput, ErrorString)
|
||||
|
||||
|
||||
def store_multiple(option, opt, value, parser, *args, **kwargs):
|
||||
"""
|
||||
Store multiple values in `parser.values`. (Option callback.)
|
||||
|
||||
Store `None` for each attribute named in `args`, and store the value for
|
||||
each key (attribute name) in `kwargs`.
|
||||
"""
|
||||
for attribute in args:
|
||||
setattr(parser.values, attribute, None)
|
||||
for key, value in list(kwargs.items()):
|
||||
setattr(parser.values, key, value)
|
||||
|
||||
def read_config_file(option, opt, value, parser):
|
||||
"""
|
||||
Read a configuration file during option processing. (Option callback.)
|
||||
"""
|
||||
try:
|
||||
new_settings = parser.get_config_file_settings(value)
|
||||
except ValueError as error:
|
||||
parser.error(error)
|
||||
parser.values.update(new_settings, parser)
|
||||
|
||||
def validate_encoding(setting, value, option_parser,
|
||||
config_parser=None, config_section=None):
|
||||
try:
|
||||
codecs.lookup(value)
|
||||
except LookupError:
|
||||
raise LookupError('setting "%s": unknown encoding: "%s"'
|
||||
% (setting, value))
|
||||
return value
|
||||
|
||||
def validate_encoding_error_handler(setting, value, option_parser,
|
||||
config_parser=None, config_section=None):
|
||||
try:
|
||||
codecs.lookup_error(value)
|
||||
except LookupError:
|
||||
raise LookupError(
|
||||
'unknown encoding error handler: "%s" (choices: '
|
||||
'"strict", "ignore", "replace", "backslashreplace", '
|
||||
'"xmlcharrefreplace", and possibly others; see documentation for '
|
||||
'the Python ``codecs`` module)' % value)
|
||||
return value
|
||||
|
||||
def validate_encoding_and_error_handler(
|
||||
setting, value, option_parser, config_parser=None, config_section=None):
|
||||
"""
|
||||
Side-effect: if an error handler is included in the value, it is inserted
|
||||
into the appropriate place as if it was a separate setting/option.
|
||||
"""
|
||||
if ':' in value:
|
||||
encoding, handler = value.split(':')
|
||||
validate_encoding_error_handler(
|
||||
setting + '_error_handler', handler, option_parser,
|
||||
config_parser, config_section)
|
||||
if config_parser:
|
||||
config_parser.set(config_section, setting + '_error_handler',
|
||||
handler)
|
||||
else:
|
||||
setattr(option_parser.values, setting + '_error_handler', handler)
|
||||
else:
|
||||
encoding = value
|
||||
validate_encoding(setting, encoding, option_parser,
|
||||
config_parser, config_section)
|
||||
return encoding
|
||||
|
||||
def validate_boolean(setting, value, option_parser,
|
||||
config_parser=None, config_section=None):
|
||||
"""Check/normalize boolean settings:
|
||||
True: '1', 'on', 'yes', 'true'
|
||||
False: '0', 'off', 'no','false', ''
|
||||
"""
|
||||
if isinstance(value, bool):
|
||||
return value
|
||||
try:
|
||||
return option_parser.booleans[value.strip().lower()]
|
||||
except KeyError:
|
||||
raise LookupError('unknown boolean value: "%s"' % value)
|
||||
|
||||
def validate_ternary(setting, value, option_parser,
|
||||
config_parser=None, config_section=None):
|
||||
"""Check/normalize three-value settings:
|
||||
True: '1', 'on', 'yes', 'true'
|
||||
False: '0', 'off', 'no','false', ''
|
||||
any other value: returned as-is.
|
||||
"""
|
||||
if isinstance(value, bool) or value is None:
|
||||
return value
|
||||
try:
|
||||
return option_parser.booleans[value.strip().lower()]
|
||||
except KeyError:
|
||||
return value
|
||||
|
||||
def validate_nonnegative_int(setting, value, option_parser,
|
||||
config_parser=None, config_section=None):
|
||||
value = int(value)
|
||||
if value < 0:
|
||||
raise ValueError('negative value; must be positive or zero')
|
||||
return value
|
||||
|
||||
def validate_threshold(setting, value, option_parser,
|
||||
config_parser=None, config_section=None):
|
||||
try:
|
||||
return int(value)
|
||||
except ValueError:
|
||||
try:
|
||||
return option_parser.thresholds[value.lower()]
|
||||
except (KeyError, AttributeError):
|
||||
raise LookupError('unknown threshold: %r.' % value)
|
||||
|
||||
def validate_colon_separated_string_list(
|
||||
setting, value, option_parser, config_parser=None, config_section=None):
|
||||
if not isinstance(value, list):
|
||||
value = value.split(':')
|
||||
else:
|
||||
last = value.pop()
|
||||
value.extend(last.split(':'))
|
||||
return value
|
||||
|
||||
def validate_comma_separated_list(setting, value, option_parser,
|
||||
config_parser=None, config_section=None):
|
||||
"""Check/normalize list arguments (split at "," and strip whitespace).
|
||||
"""
|
||||
# `value` is already a ``list`` when given as command line option
|
||||
# and "action" is "append" and ``unicode`` or ``str`` else.
|
||||
if not isinstance(value, list):
|
||||
value = [value]
|
||||
# this function is called for every option added to `value`
|
||||
# -> split the last item and append the result:
|
||||
last = value.pop()
|
||||
items = [i.strip(' \t\n') for i in last.split(',') if i.strip(' \t\n')]
|
||||
value.extend(items)
|
||||
return value
|
||||
|
||||
def validate_url_trailing_slash(
|
||||
setting, value, option_parser, config_parser=None, config_section=None):
|
||||
if not value:
|
||||
return './'
|
||||
elif value.endswith('/'):
|
||||
return value
|
||||
else:
|
||||
return value + '/'
|
||||
|
||||
def validate_dependency_file(setting, value, option_parser,
|
||||
config_parser=None, config_section=None):
|
||||
try:
|
||||
return docutils.utils.DependencyList(value)
|
||||
except IOError:
|
||||
return docutils.utils.DependencyList(None)
|
||||
|
||||
def validate_strip_class(setting, value, option_parser,
|
||||
config_parser=None, config_section=None):
|
||||
# value is a comma separated string list:
|
||||
value = validate_comma_separated_list(setting, value, option_parser,
|
||||
config_parser, config_section)
|
||||
# validate list elements:
|
||||
for cls in value:
|
||||
normalized = docutils.nodes.make_id(cls)
|
||||
if cls != normalized:
|
||||
raise ValueError('Invalid class value %r (perhaps %r?)'
|
||||
% (cls, normalized))
|
||||
return value
|
||||
|
||||
def validate_smartquotes_locales(setting, value, option_parser,
|
||||
config_parser=None, config_section=None):
|
||||
"""Check/normalize a comma separated list of smart quote definitions.
|
||||
|
||||
Return a list of (language-tag, quotes) string tuples."""
|
||||
|
||||
# value is a comma separated string list:
|
||||
value = validate_comma_separated_list(setting, value, option_parser,
|
||||
config_parser, config_section)
|
||||
# validate list elements
|
||||
lc_quotes = []
|
||||
for item in value:
|
||||
try:
|
||||
lang, quotes = item.split(':', 1)
|
||||
except AttributeError:
|
||||
# this function is called for every option added to `value`
|
||||
# -> ignore if already a tuple:
|
||||
lc_quotes.append(item)
|
||||
continue
|
||||
except ValueError:
|
||||
raise ValueError('Invalid value "%s".'
|
||||
' Format is "<language>:<quotes>".'
|
||||
% item.encode('ascii', 'backslashreplace'))
|
||||
# parse colon separated string list:
|
||||
quotes = quotes.strip()
|
||||
multichar_quotes = quotes.split(':')
|
||||
if len(multichar_quotes) == 4:
|
||||
quotes = multichar_quotes
|
||||
elif len(quotes) != 4:
|
||||
raise ValueError('Invalid value "%s". Please specify 4 quotes\n'
|
||||
' (primary open/close; secondary open/close).'
|
||||
% item.encode('ascii', 'backslashreplace'))
|
||||
lc_quotes.append((lang,quotes))
|
||||
return lc_quotes
|
||||
|
||||
def make_paths_absolute(pathdict, keys, base_path=None):
|
||||
"""
|
||||
Interpret filesystem path settings relative to the `base_path` given.
|
||||
|
||||
Paths are values in `pathdict` whose keys are in `keys`. Get `keys` from
|
||||
`OptionParser.relative_path_settings`.
|
||||
"""
|
||||
if base_path is None:
|
||||
base_path = os.getcwd() # type(base_path) == unicode
|
||||
# to allow combining non-ASCII cwd with unicode values in `pathdict`
|
||||
for key in keys:
|
||||
if key in pathdict:
|
||||
value = pathdict[key]
|
||||
if isinstance(value, list):
|
||||
value = [make_one_path_absolute(base_path, path)
|
||||
for path in value]
|
||||
elif value:
|
||||
value = make_one_path_absolute(base_path, value)
|
||||
pathdict[key] = value
|
||||
|
||||
def make_one_path_absolute(base_path, path):
|
||||
return os.path.abspath(os.path.join(base_path, path))
|
||||
|
||||
def filter_settings_spec(settings_spec, *exclude, **replace):
|
||||
"""Return a copy of `settings_spec` excluding/replacing some settings.
|
||||
|
||||
`settings_spec` is a tuple of configuration settings with a structure
|
||||
described for docutils.SettingsSpec.settings_spec.
|
||||
|
||||
Optional positional arguments are names of to-be-excluded settings.
|
||||
Keyword arguments are option specification replacements.
|
||||
(See the html4strict writer for an example.)
|
||||
"""
|
||||
settings = list(settings_spec)
|
||||
# every third item is a sequence of option tuples
|
||||
for i in range(2, len(settings), 3):
|
||||
newopts = []
|
||||
for opt_spec in settings[i]:
|
||||
# opt_spec is ("<help>", [<option strings>], {<keyword args>})
|
||||
opt_name = [opt_string[2:].replace('-', '_')
|
||||
for opt_string in opt_spec[1]
|
||||
if opt_string.startswith('--')
|
||||
][0]
|
||||
if opt_name in exclude:
|
||||
continue
|
||||
if opt_name in list(replace.keys()):
|
||||
newopts.append(replace[opt_name])
|
||||
else:
|
||||
newopts.append(opt_spec)
|
||||
settings[i] = tuple(newopts)
|
||||
return tuple(settings)
|
||||
|
||||
|
||||
class Values(optparse.Values):
|
||||
|
||||
"""
|
||||
Updates list attributes by extension rather than by replacement.
|
||||
Works in conjunction with the `OptionParser.lists` instance attribute.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
optparse.Values.__init__(self, *args, **kwargs)
|
||||
if (not hasattr(self, 'record_dependencies')
|
||||
or self.record_dependencies is None):
|
||||
# Set up dependency list, in case it is needed.
|
||||
self.record_dependencies = docutils.utils.DependencyList()
|
||||
|
||||
def update(self, other_dict, option_parser):
|
||||
if isinstance(other_dict, Values):
|
||||
other_dict = other_dict.__dict__
|
||||
other_dict = other_dict.copy()
|
||||
for setting in list(option_parser.lists.keys()):
|
||||
if (hasattr(self, setting) and setting in other_dict):
|
||||
value = getattr(self, setting)
|
||||
if value:
|
||||
value += other_dict[setting]
|
||||
del other_dict[setting]
|
||||
self._update_loose(other_dict)
|
||||
|
||||
def copy(self):
|
||||
"""Return a shallow copy of `self`."""
|
||||
return self.__class__(defaults=self.__dict__)
|
||||
|
||||
|
||||
class Option(optparse.Option):
|
||||
|
||||
ATTRS = optparse.Option.ATTRS + ['validator', 'overrides']
|
||||
|
||||
def process(self, opt, value, values, parser):
|
||||
"""
|
||||
Call the validator function on applicable settings and
|
||||
evaluate the 'overrides' option.
|
||||
Extends `optparse.Option.process`.
|
||||
"""
|
||||
result = optparse.Option.process(self, opt, value, values, parser)
|
||||
setting = self.dest
|
||||
if setting:
|
||||
if self.validator:
|
||||
value = getattr(values, setting)
|
||||
try:
|
||||
new_value = self.validator(setting, value, parser)
|
||||
except Exception as error:
|
||||
raise optparse.OptionValueError(
|
||||
'Error in option "%s":\n %s'
|
||||
% (opt, ErrorString(error)))
|
||||
setattr(values, setting, new_value)
|
||||
if self.overrides:
|
||||
setattr(values, self.overrides, None)
|
||||
return result
|
||||
|
||||
|
||||
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.
|
||||
|
||||
Common settings (defined below) and component-specific settings must not
|
||||
conflict. Short options are reserved for common settings, and components
|
||||
are restrict to using long options.
|
||||
"""
|
||||
|
||||
standard_config_files = [
|
||||
'/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."""
|
||||
|
||||
threshold_choices = 'info 1 warning 2 error 3 severe 4 none 5'.split()
|
||||
"""Possible inputs for for --report and --halt threshold values."""
|
||||
|
||||
thresholds = {'info': 1, 'warning': 2, 'error': 3, 'severe': 4, 'none': 5}
|
||||
"""Lookup table for --report and --halt threshold values."""
|
||||
|
||||
booleans={'1': True, 'on': True, 'yes': True, 'true': True,
|
||||
'0': False, 'off': False, 'no': False, 'false': False, '': False}
|
||||
"""Lookup table for boolean configuration file settings."""
|
||||
|
||||
default_error_encoding = getattr(sys.stderr, 'encoding',
|
||||
None) or locale_encoding or 'ascii'
|
||||
|
||||
default_error_encoding_error_handler = 'backslashreplace'
|
||||
|
||||
settings_spec = (
|
||||
'General Docutils Options',
|
||||
None,
|
||||
(('Specify the document title as metadata.',
|
||||
['--title'], {}),
|
||||
('Include a "Generated by Docutils" credit and link.',
|
||||
['--generator', '-g'], {'action': 'store_true',
|
||||
'validator': validate_boolean}),
|
||||
('Do not include a generator credit.',
|
||||
['--no-generator'], {'action': 'store_false', 'dest': 'generator'}),
|
||||
('Include the date at the end of the document (UTC).',
|
||||
['--date', '-d'], {'action': 'store_const', 'const': '%Y-%m-%d',
|
||||
'dest': 'datestamp'}),
|
||||
('Include the time & date (UTC).',
|
||||
['--time', '-t'], {'action': 'store_const',
|
||||
'const': '%Y-%m-%d %H:%M UTC',
|
||||
'dest': 'datestamp'}),
|
||||
('Do not include a datestamp of any kind.',
|
||||
['--no-datestamp'], {'action': 'store_const', 'const': None,
|
||||
'dest': 'datestamp'}),
|
||||
('Include a "View document source" link.',
|
||||
['--source-link', '-s'], {'action': 'store_true',
|
||||
'validator': validate_boolean}),
|
||||
('Use <URL> for a source link; implies --source-link.',
|
||||
['--source-url'], {'metavar': '<URL>'}),
|
||||
('Do not include a "View document source" link.',
|
||||
['--no-source-link'],
|
||||
{'action': 'callback', 'callback': store_multiple,
|
||||
'callback_args': ('source_link', 'source_url')}),
|
||||
('Link from section headers to TOC entries. (default)',
|
||||
['--toc-entry-backlinks'],
|
||||
{'dest': 'toc_backlinks', 'action': 'store_const', 'const': 'entry',
|
||||
'default': 'entry'}),
|
||||
('Link from section headers to the top of the TOC.',
|
||||
['--toc-top-backlinks'],
|
||||
{'dest': 'toc_backlinks', 'action': 'store_const', 'const': 'top'}),
|
||||
('Disable backlinks to the table of contents.',
|
||||
['--no-toc-backlinks'],
|
||||
{'dest': 'toc_backlinks', 'action': 'store_false'}),
|
||||
('Link from footnotes/citations to references. (default)',
|
||||
['--footnote-backlinks'],
|
||||
{'action': 'store_true', 'default': 1,
|
||||
'validator': validate_boolean}),
|
||||
('Disable backlinks from footnotes and citations.',
|
||||
['--no-footnote-backlinks'],
|
||||
{'dest': 'footnote_backlinks', 'action': 'store_false'}),
|
||||
('Enable section numbering by Docutils. (default)',
|
||||
['--section-numbering'],
|
||||
{'action': 'store_true', 'dest': 'sectnum_xform',
|
||||
'default': 1, 'validator': validate_boolean}),
|
||||
('Disable section numbering by Docutils.',
|
||||
['--no-section-numbering'],
|
||||
{'action': 'store_false', 'dest': 'sectnum_xform'}),
|
||||
('Remove comment elements from the document tree.',
|
||||
['--strip-comments'],
|
||||
{'action': 'store_true', 'validator': validate_boolean}),
|
||||
('Leave comment elements in the document tree. (default)',
|
||||
['--leave-comments'],
|
||||
{'action': 'store_false', 'dest': 'strip_comments'}),
|
||||
('Remove all elements with classes="<class>" from the document tree. '
|
||||
'Warning: potentially dangerous; use with caution. '
|
||||
'(Multiple-use option.)',
|
||||
['--strip-elements-with-class'],
|
||||
{'action': 'append', 'dest': 'strip_elements_with_classes',
|
||||
'metavar': '<class>', 'validator': validate_strip_class}),
|
||||
('Remove all classes="<class>" attributes from elements in the '
|
||||
'document tree. Warning: potentially dangerous; use with caution. '
|
||||
'(Multiple-use option.)',
|
||||
['--strip-class'],
|
||||
{'action': 'append', 'dest': 'strip_classes',
|
||||
'metavar': '<class>', 'validator': validate_strip_class}),
|
||||
('Report system messages at or higher than <level>: "info" or "1", '
|
||||
'"warning"/"2" (default), "error"/"3", "severe"/"4", "none"/"5"',
|
||||
['--report', '-r'], {'choices': threshold_choices, 'default': 2,
|
||||
'dest': 'report_level', 'metavar': '<level>',
|
||||
'validator': validate_threshold}),
|
||||
('Report all system messages. (Same as "--report=1".)',
|
||||
['--verbose', '-v'], {'action': 'store_const', 'const': 1,
|
||||
'dest': 'report_level'}),
|
||||
('Report no system messages. (Same as "--report=5".)',
|
||||
['--quiet', '-q'], {'action': 'store_const', 'const': 5,
|
||||
'dest': 'report_level'}),
|
||||
('Halt execution at system messages at or above <level>. '
|
||||
'Levels as in --report. Default: 4 (severe).',
|
||||
['--halt'], {'choices': threshold_choices, 'dest': 'halt_level',
|
||||
'default': 4, 'metavar': '<level>',
|
||||
'validator': validate_threshold}),
|
||||
('Halt at the slightest problem. Same as "--halt=info".',
|
||||
['--strict'], {'action': 'store_const', 'const': 1,
|
||||
'dest': 'halt_level'}),
|
||||
('Enable a non-zero exit status for non-halting system messages at '
|
||||
'or above <level>. Default: 5 (disabled).',
|
||||
['--exit-status'], {'choices': threshold_choices,
|
||||
'dest': 'exit_status_level',
|
||||
'default': 5, 'metavar': '<level>',
|
||||
'validator': validate_threshold}),
|
||||
('Enable debug-level system messages and diagnostics.',
|
||||
['--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>.',
|
||||
['--warnings'], {'dest': 'warning_stream', 'metavar': '<file>'}),
|
||||
('Enable Python tracebacks when Docutils is halted.',
|
||||
['--traceback'], {'action': 'store_true', 'default': None,
|
||||
'validator': validate_boolean}),
|
||||
('Disable Python tracebacks. (default)',
|
||||
['--no-traceback'], {'dest': 'traceback', 'action': 'store_false'}),
|
||||
('Specify the encoding and optionally the '
|
||||
'error handler of input text. Default: <locale-dependent>:strict.',
|
||||
['--input-encoding', '-i'],
|
||||
{'metavar': '<name[:handler]>',
|
||||
'validator': validate_encoding_and_error_handler}),
|
||||
('Specify the error handler for undecodable characters. '
|
||||
'Choices: "strict" (default), "ignore", and "replace".',
|
||||
['--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-encoding', '-o'],
|
||||
{'metavar': '<name[:handler]>', 'default': 'utf-8',
|
||||
'validator': validate_encoding_and_error_handler}),
|
||||
('Specify error handler for unencodable output characters; '
|
||||
'"strict" (default), "ignore", "replace", '
|
||||
'"xmlcharrefreplace", "backslashreplace".',
|
||||
['--output-encoding-error-handler'],
|
||||
{'default': 'strict', 'validator': validate_encoding_error_handler}),
|
||||
('Specify text encoding and error handler for error output. '
|
||||
'Default: %s:%s.'
|
||||
% (default_error_encoding, default_error_encoding_error_handler),
|
||||
['--error-encoding', '-e'],
|
||||
{'metavar': '<name[:handler]>', 'default': default_error_encoding,
|
||||
'validator': validate_encoding_and_error_handler}),
|
||||
('Specify the error handler for unencodable characters in '
|
||||
'error output. Default: %s.'
|
||||
% default_error_encoding_error_handler,
|
||||
['--error-encoding-error-handler'],
|
||||
{'default': default_error_encoding_error_handler,
|
||||
'validator': validate_encoding_error_handler}),
|
||||
('Specify the language (as BCP 47 language tag). Default: en.',
|
||||
['--language', '-l'], {'dest': 'language_code', 'default': 'en',
|
||||
'metavar': '<name>'}),
|
||||
('Write output file dependencies to <file>.',
|
||||
['--record-dependencies'],
|
||||
{'metavar': '<file>', 'validator': validate_dependency_file,
|
||||
'default': None}), # default set in Values class
|
||||
('Read configuration settings from <file>, if it exists.',
|
||||
['--config'], {'metavar': '<file>', 'type': 'string',
|
||||
'action': 'callback', 'callback': read_config_file}),
|
||||
("Show this program's version number and exit.",
|
||||
['--version', '-V'], {'action': 'version'}),
|
||||
('Show this help message and exit.',
|
||||
['--help', '-h'], {'action': 'help'}),
|
||||
# Typically not useful for non-programmatical use:
|
||||
(SUPPRESS_HELP, ['--id-prefix'], {'default': ''}),
|
||||
(SUPPRESS_HELP, ['--auto-id-prefix'], {'default': 'id'}),
|
||||
# Hidden options, for development use only:
|
||||
(SUPPRESS_HELP, ['--dump-settings'], {'action': 'store_true'}),
|
||||
(SUPPRESS_HELP, ['--dump-internals'], {'action': 'store_true'}),
|
||||
(SUPPRESS_HELP, ['--dump-transforms'], {'action': 'store_true'}),
|
||||
(SUPPRESS_HELP, ['--dump-pseudo-xml'], {'action': 'store_true'}),
|
||||
(SUPPRESS_HELP, ['--expose-internal-attribute'],
|
||||
{'action': 'append', 'dest': 'expose_internals',
|
||||
'validator': validate_colon_separated_string_list}),
|
||||
(SUPPRESS_HELP, ['--strict-visitor'], {'action': 'store_true'}),
|
||||
))
|
||||
"""Runtime settings and command-line options common to all Docutils front
|
||||
ends. Setting specs specific to individual Docutils components are also
|
||||
used (see `populate_from_components()`)."""
|
||||
|
||||
settings_defaults = {'_disable_config': None,
|
||||
'_source': None,
|
||||
'_destination': None,
|
||||
'_config_files': None}
|
||||
"""Defaults for settings that don't have command-line option equivalents."""
|
||||
|
||||
relative_path_settings = ('warning_stream',)
|
||||
|
||||
config_section = 'general'
|
||||
|
||||
version_template = ('%%prog (Docutils %s%s, Python %s, on %s)'
|
||||
% (docutils.__version__,
|
||||
docutils.__version_details__ and
|
||||
' [%s]'%docutils.__version_details__ or '',
|
||||
sys.version.split()[0], sys.platform))
|
||||
"""Default version message."""
|
||||
|
||||
def __init__(self, components=(), defaults=None, read_config_files=None,
|
||||
*args, **kwargs):
|
||||
"""
|
||||
`components` is a list of Docutils components each containing a
|
||||
``.settings_spec`` attribute. `defaults` is a mapping of setting
|
||||
default overrides.
|
||||
"""
|
||||
|
||||
self.lists = {}
|
||||
"""Set of list-type settings."""
|
||||
|
||||
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)
|
||||
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,) + tuple(components)
|
||||
self.populate_from_components(self.components)
|
||||
self.set_defaults_from_dict(defaults or {})
|
||||
if read_config_files and not self.defaults['_disable_config']:
|
||||
try:
|
||||
config_settings = self.get_standard_config_settings()
|
||||
except ValueError as error:
|
||||
self.error(SafeString(error))
|
||||
self.set_defaults_from_dict(config_settings.__dict__)
|
||||
|
||||
def populate_from_components(self, components):
|
||||
"""
|
||||
For each component, first 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.
|
||||
"""
|
||||
for component in components:
|
||||
if component is None:
|
||||
continue
|
||||
settings_spec = component.settings_spec
|
||||
self.relative_path_settings.extend(
|
||||
component.relative_path_settings)
|
||||
for i in range(0, len(settings_spec), 3):
|
||||
title, description, option_spec = settings_spec[i:i+3]
|
||||
if title:
|
||||
group = optparse.OptionGroup(self, title, description)
|
||||
self.add_option_group(group)
|
||||
else:
|
||||
group = self # single options
|
||||
for (help_text, option_strings, kwargs) in option_spec:
|
||||
option = group.add_option(help=help_text, *option_strings,
|
||||
**kwargs)
|
||||
if kwargs.get('action') == 'append':
|
||||
self.lists[option.dest] = 1
|
||||
if component.settings_defaults:
|
||||
self.defaults.update(component.settings_defaults)
|
||||
for component in components:
|
||||
if component and component.settings_default_overrides:
|
||||
self.defaults.update(component.settings_default_overrides)
|
||||
|
||||
def get_standard_config_files(self):
|
||||
"""Return list of config files, from environment or standard."""
|
||||
try:
|
||||
config_files = os.environ['DOCUTILSCONFIG'].split(os.pathsep)
|
||||
except KeyError:
|
||||
config_files = self.standard_config_files
|
||||
|
||||
# If 'HOME' is not set, expandvars() requires the 'pwd' module which is
|
||||
# not available under certain environments, for example, within
|
||||
# mod_python. The publisher ends up in here, and we need to publish
|
||||
# from within mod_python. Therefore we need to avoid expanding when we
|
||||
# are in those environments.
|
||||
expand = os.path.expanduser
|
||||
if 'HOME' not in os.environ:
|
||||
try:
|
||||
import pwd
|
||||
except ImportError:
|
||||
expand = lambda x: x
|
||||
return [expand(f) for f in config_files if f.strip()]
|
||||
|
||||
def get_standard_config_settings(self):
|
||||
settings = Values()
|
||||
for filename in self.get_standard_config_files():
|
||||
settings.update(self.get_config_file_settings(filename), self)
|
||||
return settings
|
||||
|
||||
def get_config_file_settings(self, config_file):
|
||||
"""Returns a dictionary containing appropriate config file settings."""
|
||||
parser = ConfigParser()
|
||||
parser.read(config_file, self)
|
||||
self.config_files.extend(parser._files)
|
||||
base_path = os.path.dirname(config_file)
|
||||
applied = {}
|
||||
settings = Values()
|
||||
for component in self.components:
|
||||
if not component:
|
||||
continue
|
||||
for section in (tuple(component.config_section_dependencies or ())
|
||||
+ (component.config_section,)):
|
||||
if section in applied:
|
||||
continue
|
||||
applied[section] = 1
|
||||
settings.update(parser.get_section(section), self)
|
||||
make_paths_absolute(
|
||||
settings.__dict__, self.relative_path_settings, base_path)
|
||||
return settings.__dict__
|
||||
|
||||
def check_values(self, values, args):
|
||||
"""Store positional arguments as runtime settings."""
|
||||
values._source, values._destination = self.check_args(args)
|
||||
make_paths_absolute(values.__dict__, self.relative_path_settings)
|
||||
values._config_files = self.config_files
|
||||
return values
|
||||
|
||||
def check_args(self, args):
|
||||
source = destination = None
|
||||
if args:
|
||||
source = args.pop(0)
|
||||
if source == '-': # means stdin
|
||||
source = None
|
||||
if args:
|
||||
destination = args.pop(0)
|
||||
if destination == '-': # means stdout
|
||||
destination = None
|
||||
if args:
|
||||
self.error('Maximum 2 arguments allowed.')
|
||||
if source and source == destination:
|
||||
self.error('Do not specify the same file for both source and '
|
||||
'destination. It will clobber the source file.')
|
||||
return source, destination
|
||||
|
||||
def set_defaults_from_dict(self, defaults):
|
||||
self.defaults.update(defaults)
|
||||
|
||||
def get_default_values(self):
|
||||
"""Needed to get custom `Values` instances."""
|
||||
defaults = Values(self.defaults)
|
||||
defaults._config_files = self.config_files
|
||||
return defaults
|
||||
|
||||
def get_option_by_dest(self, dest):
|
||||
"""
|
||||
Get an option by its dest.
|
||||
|
||||
If you're supplying a dest which is shared by several options,
|
||||
it is undefined which option of those is returned.
|
||||
|
||||
A KeyError is raised if there is no option with the supplied
|
||||
dest.
|
||||
"""
|
||||
for group in self.option_groups + [self]:
|
||||
for option in group.option_list:
|
||||
if option.dest == dest:
|
||||
return option
|
||||
raise KeyError('No option with dest == %r.' % dest)
|
||||
|
||||
|
||||
class ConfigParser(CP.RawConfigParser):
|
||||
|
||||
old_settings = {
|
||||
'pep_stylesheet': ('pep_html writer', 'stylesheet'),
|
||||
'pep_stylesheet_path': ('pep_html writer', 'stylesheet_path'),
|
||||
'pep_template': ('pep_html writer', 'template')}
|
||||
"""{old setting: (new section, new setting)} mapping, used by
|
||||
`handle_old_config`, to convert settings from the old [options] section."""
|
||||
|
||||
old_warning = """
|
||||
The "[option]" section is deprecated. Support for old-format configuration
|
||||
files may be removed in a future Docutils release. Please revise your
|
||||
configuration files. See <http://docutils.sf.net/docs/user/config.html>,
|
||||
section "Old-Format Configuration Files".
|
||||
"""
|
||||
|
||||
not_utf8_error = """\
|
||||
Unable to read configuration file "%s": content not encoded as UTF-8.
|
||||
Skipping "%s" configuration file.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
CP.RawConfigParser.__init__(self, *args, **kwargs)
|
||||
|
||||
self._files = []
|
||||
"""List of paths of configuration files read."""
|
||||
|
||||
self._stderr = ErrorOutput()
|
||||
"""Wrapper around sys.stderr catching en-/decoding errors"""
|
||||
|
||||
def read(self, filenames, option_parser):
|
||||
if type(filenames) in (str, str):
|
||||
filenames = [filenames]
|
||||
for filename in filenames:
|
||||
try:
|
||||
# Config files must be UTF-8-encoded:
|
||||
fp = codecs.open(filename, 'r', 'utf-8')
|
||||
except IOError:
|
||||
continue
|
||||
try:
|
||||
if sys.version_info < (3,2):
|
||||
CP.RawConfigParser.readfp(self, fp, filename)
|
||||
else:
|
||||
CP.RawConfigParser.read_file(self, fp, filename)
|
||||
except UnicodeDecodeError:
|
||||
self._stderr.write(self.not_utf8_error % (filename, filename))
|
||||
fp.close()
|
||||
continue
|
||||
fp.close()
|
||||
self._files.append(filename)
|
||||
if self.has_section('options'):
|
||||
self.handle_old_config(filename)
|
||||
self.validate_settings(filename, option_parser)
|
||||
|
||||
def handle_old_config(self, filename):
|
||||
warnings.warn_explicit(self.old_warning, ConfigDeprecationWarning,
|
||||
filename, 0)
|
||||
options = self.get_section('options')
|
||||
if not self.has_section('general'):
|
||||
self.add_section('general')
|
||||
for key, value in list(options.items()):
|
||||
if key in self.old_settings:
|
||||
section, setting = self.old_settings[key]
|
||||
if not self.has_section(section):
|
||||
self.add_section(section)
|
||||
else:
|
||||
section = 'general'
|
||||
setting = key
|
||||
if not self.has_option(section, setting):
|
||||
self.set(section, setting, value)
|
||||
self.remove_section('options')
|
||||
|
||||
def validate_settings(self, filename, option_parser):
|
||||
"""
|
||||
Call the validator function and implement overrides on all applicable
|
||||
settings.
|
||||
"""
|
||||
for section in self.sections():
|
||||
for setting in self.options(section):
|
||||
try:
|
||||
option = option_parser.get_option_by_dest(setting)
|
||||
except KeyError:
|
||||
continue
|
||||
if option.validator:
|
||||
value = self.get(section, setting)
|
||||
try:
|
||||
new_value = option.validator(
|
||||
setting, value, option_parser,
|
||||
config_parser=self, config_section=section)
|
||||
except Exception as error:
|
||||
raise ValueError(
|
||||
'Error in config file "%s", section "[%s]":\n'
|
||||
' %s\n'
|
||||
' %s = %s'
|
||||
% (filename, section, ErrorString(error),
|
||||
setting, value))
|
||||
self.set(section, setting, new_value)
|
||||
if option.overrides:
|
||||
self.set(section, option.overrides, None)
|
||||
|
||||
def optionxform(self, optionstr):
|
||||
"""
|
||||
Transform '-' to '_' so the cmdline form of option names can be used.
|
||||
"""
|
||||
return optionstr.lower().replace('-', '_')
|
||||
|
||||
def get_section(self, section):
|
||||
"""
|
||||
Return a given section as a dictionary (empty if the section
|
||||
doesn't exist).
|
||||
"""
|
||||
section_dict = {}
|
||||
if self.has_section(section):
|
||||
for option in self.options(section):
|
||||
section_dict[option] = self.get(section, option)
|
||||
return section_dict
|
||||
|
||||
|
||||
class ConfigDeprecationWarning(DeprecationWarning):
|
||||
"""Warning for deprecated configuration file features."""
|
||||
488
parkingkonceptvenv/lib/python3.7/site-packages/docutils/io.py
Normal file
488
parkingkonceptvenv/lib/python3.7/site-packages/docutils/io.py
Normal file
@@ -0,0 +1,488 @@
|
||||
# $Id: io.py 8228 2018-09-09 18:57:00Z grubert $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
I/O classes provide a uniform API for low-level input and output. Subclasses
|
||||
exist for a variety of input/output mechanisms.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import codecs
|
||||
from docutils import TransformSpec
|
||||
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
|
||||
|
||||
|
||||
class InputError(IOError): pass
|
||||
class OutputError(IOError): pass
|
||||
|
||||
def check_encoding(stream, encoding):
|
||||
"""Test, whether the encoding of `stream` matches `encoding`.
|
||||
|
||||
Returns
|
||||
|
||||
:None: if `encoding` or `stream.encoding` are not a valid encoding
|
||||
argument (e.g. ``None``) or `stream.encoding is missing.
|
||||
:True: if the encoding argument resolves to the same value as `encoding`,
|
||||
:False: if the encodings differ.
|
||||
"""
|
||||
try:
|
||||
return codecs.lookup(stream.encoding) == codecs.lookup(encoding)
|
||||
except (LookupError, AttributeError, TypeError):
|
||||
return None
|
||||
|
||||
|
||||
class Input(TransformSpec):
|
||||
|
||||
"""
|
||||
Abstract base class for input wrappers.
|
||||
"""
|
||||
|
||||
component_type = 'input'
|
||||
|
||||
default_source_path = None
|
||||
|
||||
def __init__(self, source=None, source_path=None, encoding=None,
|
||||
error_handler='strict'):
|
||||
self.encoding = encoding
|
||||
"""Text encoding for the input source."""
|
||||
|
||||
self.error_handler = error_handler
|
||||
"""Text decoding error handler."""
|
||||
|
||||
self.source = source
|
||||
"""The source of input data."""
|
||||
|
||||
self.source_path = source_path
|
||||
"""A text reference to the source."""
|
||||
|
||||
if not source_path:
|
||||
self.source_path = self.default_source_path
|
||||
|
||||
self.successful_encoding = None
|
||||
"""The encoding that successfully decoded the source data."""
|
||||
|
||||
def __repr__(self):
|
||||
return '%s: source=%r, source_path=%r' % (self.__class__, self.source,
|
||||
self.source_path)
|
||||
|
||||
def read(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def decode(self, data):
|
||||
"""
|
||||
Decode a string, `data`, heuristically.
|
||||
Raise UnicodeError if unsuccessful.
|
||||
|
||||
The client application should call ``locale.setlocale`` at the
|
||||
beginning of processing::
|
||||
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
"""
|
||||
if self.encoding and self.encoding.lower() == 'unicode':
|
||||
assert isinstance(data, str), (
|
||||
'input encoding is "unicode" '
|
||||
'but input is not a unicode object')
|
||||
if isinstance(data, str):
|
||||
# Accept unicode even if self.encoding != 'unicode'.
|
||||
return data
|
||||
if self.encoding:
|
||||
# We believe the user/application when the encoding is
|
||||
# explicitly given.
|
||||
encodings = [self.encoding]
|
||||
else:
|
||||
data_encoding = self.determine_encoding_from_data(data)
|
||||
if data_encoding:
|
||||
# If the data declares its encoding (explicitly or via a BOM),
|
||||
# we believe it.
|
||||
encodings = [data_encoding]
|
||||
else:
|
||||
# Apply heuristics only if no encoding is explicitly given and
|
||||
# no BOM found. Start with UTF-8, because that only matches
|
||||
# data that *IS* UTF-8:
|
||||
encodings = ['utf-8', 'latin-1']
|
||||
if locale_encoding:
|
||||
encodings.insert(1, locale_encoding)
|
||||
for enc in encodings:
|
||||
try:
|
||||
decoded = str(data, enc, self.error_handler)
|
||||
self.successful_encoding = enc
|
||||
# Return decoded, removing BOMs.
|
||||
return decoded.replace('\ufeff', '')
|
||||
except (UnicodeError, LookupError) as err:
|
||||
error = err # in Python 3, the <exception instance> is
|
||||
# local to the except clause
|
||||
raise UnicodeError(
|
||||
'Unable to decode input data. Tried the following encodings: '
|
||||
'%s.\n(%s)' % (', '.join([repr(enc) for enc in encodings]),
|
||||
ErrorString(error)))
|
||||
|
||||
coding_slug = re.compile(br"coding[:=]\s*([-\w.]+)")
|
||||
"""Encoding declaration pattern."""
|
||||
|
||||
byte_order_marks = ((codecs.BOM_UTF8, 'utf-8'),
|
||||
(codecs.BOM_UTF16_BE, 'utf-16-be'),
|
||||
(codecs.BOM_UTF16_LE, 'utf-16-le'),)
|
||||
"""Sequence of (start_bytes, encoding) tuples for encoding detection.
|
||||
The first bytes of input data are checked against the start_bytes strings.
|
||||
A match indicates the given encoding."""
|
||||
|
||||
def determine_encoding_from_data(self, data):
|
||||
"""
|
||||
Try to determine the encoding of `data` by looking *in* `data`.
|
||||
Check for a byte order mark (BOM) or an encoding declaration.
|
||||
"""
|
||||
# check for a byte order mark:
|
||||
for start_bytes, encoding in self.byte_order_marks:
|
||||
if data.startswith(start_bytes):
|
||||
return encoding
|
||||
# check for an encoding declaration pattern in first 2 lines of file:
|
||||
for line in data.splitlines()[:2]:
|
||||
match = self.coding_slug.search(line)
|
||||
if match:
|
||||
return match.group(1).decode('ascii')
|
||||
return None
|
||||
|
||||
|
||||
class Output(TransformSpec):
|
||||
|
||||
"""
|
||||
Abstract base class for output wrappers.
|
||||
"""
|
||||
|
||||
component_type = 'output'
|
||||
|
||||
default_destination_path = None
|
||||
|
||||
def __init__(self, destination=None, destination_path=None,
|
||||
encoding=None, error_handler='strict'):
|
||||
self.encoding = encoding
|
||||
"""Text encoding for the output destination."""
|
||||
|
||||
self.error_handler = error_handler or 'strict'
|
||||
"""Text encoding error handler."""
|
||||
|
||||
self.destination = destination
|
||||
"""The destination for output data."""
|
||||
|
||||
self.destination_path = destination_path
|
||||
"""A text reference to the destination."""
|
||||
|
||||
if not destination_path:
|
||||
self.destination_path = self.default_destination_path
|
||||
|
||||
def __repr__(self):
|
||||
return ('%s: destination=%r, destination_path=%r'
|
||||
% (self.__class__, self.destination, self.destination_path))
|
||||
|
||||
def write(self, data):
|
||||
"""`data` is a Unicode string, to be encoded by `self.encode`."""
|
||||
raise NotImplementedError
|
||||
|
||||
def encode(self, data):
|
||||
if self.encoding and self.encoding.lower() == 'unicode':
|
||||
assert isinstance(data, str), (
|
||||
'the encoding given is "unicode" but the output is not '
|
||||
'a Unicode string')
|
||||
return data
|
||||
if not isinstance(data, str):
|
||||
# Non-unicode (e.g. bytes) output.
|
||||
return data
|
||||
else:
|
||||
return data.encode(self.encoding, self.error_handler)
|
||||
|
||||
|
||||
class FileInput(Input):
|
||||
|
||||
"""
|
||||
Input for single, simple file-like objects.
|
||||
"""
|
||||
def __init__(self, source=None, source_path=None,
|
||||
encoding=None, error_handler='strict',
|
||||
autoclose=True,
|
||||
mode='r' if sys.version_info >= (3, 4) else 'rU', **kwargs):
|
||||
"""
|
||||
:Parameters:
|
||||
- `source`: either a file-like object (which is read directly), or
|
||||
`None` (which implies `sys.stdin` if no `source_path` given).
|
||||
- `source_path`: a path to a file, which is opened and then read.
|
||||
- `encoding`: the expected text encoding of the input file.
|
||||
- `error_handler`: the encoding error handler to use.
|
||||
- `autoclose`: close automatically after read (except when
|
||||
`sys.stdin` is the source).
|
||||
- `mode`: how the file is to be opened (see standard function
|
||||
`open`). The default 'rU' provides universal newline support
|
||||
for text files on Python < 3.4.
|
||||
"""
|
||||
Input.__init__(self, source, source_path, encoding, error_handler)
|
||||
self.autoclose = autoclose
|
||||
self._stderr = ErrorOutput()
|
||||
# deprecation warning
|
||||
for key in kwargs:
|
||||
if key == 'handle_io_errors':
|
||||
sys.stderr.write('deprecation warning: '
|
||||
'io.FileInput() argument `handle_io_errors` '
|
||||
'is ignored since Docutils 0.10 (2012-12-16) '
|
||||
'and will soon be removed.')
|
||||
else:
|
||||
raise TypeError('__init__() got an unexpected keyword '
|
||||
"argument '%s'" % key)
|
||||
|
||||
if source is None:
|
||||
if source_path:
|
||||
# Specify encoding in Python 3
|
||||
if sys.version_info >= (3,0):
|
||||
kwargs = {'encoding': self.encoding,
|
||||
'errors': self.error_handler}
|
||||
else:
|
||||
kwargs = {}
|
||||
|
||||
try:
|
||||
self.source = open(source_path, mode, **kwargs)
|
||||
except IOError as error:
|
||||
raise InputError(error.errno, error.strerror, source_path)
|
||||
else:
|
||||
self.source = sys.stdin
|
||||
elif (sys.version_info >= (3,0) and
|
||||
check_encoding(self.source, self.encoding) is False):
|
||||
# TODO: re-open, warn or raise error?
|
||||
raise UnicodeError('Encoding clash: encoding given is "%s" '
|
||||
'but source is opened with encoding "%s".' %
|
||||
(self.encoding, self.source.encoding))
|
||||
if not source_path:
|
||||
try:
|
||||
self.source_path = self.source.name
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def read(self):
|
||||
"""
|
||||
Read and decode a single file and return the data (Unicode string).
|
||||
"""
|
||||
try:
|
||||
if self.source is sys.stdin and sys.version_info >= (3,0):
|
||||
# read as binary data to circumvent auto-decoding
|
||||
data = self.source.buffer.read()
|
||||
# normalize newlines
|
||||
data = b'\n'.join(data.splitlines()) + b'\n'
|
||||
else:
|
||||
data = self.source.read()
|
||||
except (UnicodeError, LookupError) as err: # (in Py3k read() decodes)
|
||||
if not self.encoding and self.source_path:
|
||||
# re-read in binary mode and decode with heuristics
|
||||
b_source = open(self.source_path, 'rb')
|
||||
data = b_source.read()
|
||||
b_source.close()
|
||||
# normalize newlines
|
||||
data = b'\n'.join(data.splitlines()) + b'\n'
|
||||
else:
|
||||
raise
|
||||
finally:
|
||||
if self.autoclose:
|
||||
self.close()
|
||||
return self.decode(data)
|
||||
|
||||
def readlines(self):
|
||||
"""
|
||||
Return lines of a single file as list of Unicode strings.
|
||||
"""
|
||||
return self.read().splitlines(True)
|
||||
|
||||
def close(self):
|
||||
if self.source is not sys.stdin:
|
||||
self.source.close()
|
||||
|
||||
|
||||
class FileOutput(Output):
|
||||
|
||||
"""
|
||||
Output for single, simple file-like objects.
|
||||
"""
|
||||
|
||||
mode = 'w'
|
||||
"""The mode argument for `open()`."""
|
||||
# 'wb' for binary (e.g. OpenOffice) files (see also `BinaryFileOutput`).
|
||||
# (Do not use binary mode ('wb') for text files, as this prevents the
|
||||
# conversion of newlines to the system specific default.)
|
||||
|
||||
def __init__(self, destination=None, destination_path=None,
|
||||
encoding=None, error_handler='strict', autoclose=True,
|
||||
handle_io_errors=None, mode=None):
|
||||
"""
|
||||
:Parameters:
|
||||
- `destination`: either a file-like object (which is written
|
||||
directly) or `None` (which implies `sys.stdout` if no
|
||||
`destination_path` given).
|
||||
- `destination_path`: a path to a file, which is opened and then
|
||||
written.
|
||||
- `encoding`: the text encoding of the output file.
|
||||
- `error_handler`: the encoding error handler to use.
|
||||
- `autoclose`: close automatically after write (except when
|
||||
`sys.stdout` or `sys.stderr` is the destination).
|
||||
- `handle_io_errors`: ignored, deprecated, will be removed.
|
||||
- `mode`: how the file is to be opened (see standard function
|
||||
`open`). The default is 'w', providing universal newline
|
||||
support for text files.
|
||||
"""
|
||||
Output.__init__(self, destination, destination_path,
|
||||
encoding, error_handler)
|
||||
self.opened = True
|
||||
self.autoclose = autoclose
|
||||
if mode is not None:
|
||||
self.mode = mode
|
||||
self._stderr = ErrorOutput()
|
||||
if destination is None:
|
||||
if destination_path:
|
||||
self.opened = False
|
||||
else:
|
||||
self.destination = sys.stdout
|
||||
elif (# destination is file-type object -> check mode:
|
||||
mode and hasattr(self.destination, 'mode')
|
||||
and mode != self.destination.mode):
|
||||
print(('Warning: Destination mode "%s" '
|
||||
'differs from specified mode "%s"' %
|
||||
(self.destination.mode, mode)), file=self._stderr)
|
||||
if not destination_path:
|
||||
try:
|
||||
self.destination_path = self.destination.name
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def open(self):
|
||||
# Specify encoding in Python 3.
|
||||
if sys.version_info >= (3,0) and 'b' not in self.mode:
|
||||
kwargs = {'encoding': self.encoding,
|
||||
'errors': self.error_handler}
|
||||
else:
|
||||
kwargs = {}
|
||||
try:
|
||||
self.destination = open(self.destination_path, self.mode, **kwargs)
|
||||
except IOError as error:
|
||||
raise OutputError(error.errno, error.strerror,
|
||||
self.destination_path)
|
||||
self.opened = True
|
||||
|
||||
def write(self, data):
|
||||
"""Encode `data`, write it to a single file, and return it.
|
||||
|
||||
With Python 3 or binary output mode, `data` is returned unchanged,
|
||||
except when specified encoding and output encoding differ.
|
||||
"""
|
||||
if not self.opened:
|
||||
self.open()
|
||||
if ('b' not in self.mode and sys.version_info < (3,0)
|
||||
or check_encoding(self.destination, self.encoding) is False
|
||||
):
|
||||
data = self.encode(data)
|
||||
if sys.version_info >= (3,0) and os.linesep != '\n':
|
||||
data = data.replace(b'\n', bytes(os.linesep, 'ascii')) # fix endings
|
||||
|
||||
try:
|
||||
self.destination.write(data)
|
||||
except TypeError as e:
|
||||
if sys.version_info >= (3,0) and isinstance(data, bytes):
|
||||
try:
|
||||
self.destination.buffer.write(data)
|
||||
except AttributeError:
|
||||
if check_encoding(self.destination,
|
||||
self.encoding) is False:
|
||||
raise ValueError('Encoding of %s (%s) differs \n'
|
||||
' from specified encoding (%s)' %
|
||||
(self.destination_path or 'destination',
|
||||
self.destination.encoding, self.encoding))
|
||||
else:
|
||||
raise e
|
||||
except (UnicodeError, LookupError) as err:
|
||||
raise UnicodeError(
|
||||
'Unable to encode output data. output-encoding is: '
|
||||
'%s.\n(%s)' % (self.encoding, ErrorString(err)))
|
||||
finally:
|
||||
if self.autoclose:
|
||||
self.close()
|
||||
return data
|
||||
|
||||
def close(self):
|
||||
if self.destination not in (sys.stdout, sys.stderr):
|
||||
self.destination.close()
|
||||
self.opened = False
|
||||
|
||||
|
||||
class BinaryFileOutput(FileOutput):
|
||||
"""
|
||||
A version of docutils.io.FileOutput which writes to a binary file.
|
||||
"""
|
||||
# Used by core.publish_cmdline_to_binary() which in turn is used by
|
||||
# rst2odt (OpenOffice writer)
|
||||
mode = 'wb'
|
||||
|
||||
|
||||
class StringInput(Input):
|
||||
|
||||
"""
|
||||
Direct string input.
|
||||
"""
|
||||
|
||||
default_source_path = '<string>'
|
||||
|
||||
def read(self):
|
||||
"""Decode and return the source string."""
|
||||
return self.decode(self.source)
|
||||
|
||||
|
||||
class StringOutput(Output):
|
||||
|
||||
"""
|
||||
Direct string output.
|
||||
"""
|
||||
|
||||
default_destination_path = '<string>'
|
||||
|
||||
def write(self, data):
|
||||
"""Encode `data`, store it in `self.destination`, and return it."""
|
||||
self.destination = self.encode(data)
|
||||
return self.destination
|
||||
|
||||
|
||||
class NullInput(Input):
|
||||
|
||||
"""
|
||||
Degenerate input: read nothing.
|
||||
"""
|
||||
|
||||
default_source_path = 'null input'
|
||||
|
||||
def read(self):
|
||||
"""Return a null string."""
|
||||
return ''
|
||||
|
||||
|
||||
class NullOutput(Output):
|
||||
|
||||
"""
|
||||
Degenerate output: write nothing.
|
||||
"""
|
||||
|
||||
default_destination_path = 'null output'
|
||||
|
||||
def write(self, data):
|
||||
"""Do nothing ([don't even] send data to the bit bucket)."""
|
||||
pass
|
||||
|
||||
|
||||
class DocTreeInput(Input):
|
||||
|
||||
"""
|
||||
Adapter for document tree input.
|
||||
|
||||
The document tree must be passed in the ``source`` parameter.
|
||||
"""
|
||||
|
||||
default_source_path = 'doctree input'
|
||||
|
||||
def read(self):
|
||||
"""Return the document tree."""
|
||||
return self.source
|
||||
@@ -0,0 +1,47 @@
|
||||
# $Id: __init__.py 8239 2018-11-21 21:46:00Z milde $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# Internationalization details are documented in
|
||||
# <http://docutils.sf.net/docs/howto/i18n.html>.
|
||||
|
||||
"""
|
||||
This package contains modules for language-dependent features of Docutils.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
import sys
|
||||
|
||||
from docutils.utils import normalize_language_tag
|
||||
|
||||
|
||||
_languages = {}
|
||||
|
||||
def get_language(language_code, reporter=None):
|
||||
"""Return module with language localizations.
|
||||
|
||||
`language_code` is a "BCP 47" language tag.
|
||||
If there is no matching module, warn and fall back to English.
|
||||
"""
|
||||
# TODO: use a dummy module returning emtpy strings?, configurable?
|
||||
for tag in normalize_language_tag(language_code):
|
||||
tag = tag.replace('-','_') # '-' not valid in module names
|
||||
if tag in _languages:
|
||||
return _languages[tag]
|
||||
try:
|
||||
module = __import__(tag, globals(), locals(), level=1)
|
||||
except ImportError:
|
||||
try:
|
||||
module = __import__(tag, globals(), locals(), level=0)
|
||||
except ImportError:
|
||||
continue
|
||||
_languages[tag] = module
|
||||
return module
|
||||
if reporter is not None:
|
||||
reporter.warning(
|
||||
'language "%s" not supported: ' % language_code +
|
||||
'Docutils-generated text will be in English.')
|
||||
module = __import__('en', globals(), locals(), level=1)
|
||||
_languages[tag] = module # warn only one time!
|
||||
return module
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,58 @@
|
||||
# $Id: af.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Jannie Hofmeyr <jhsh@sun.ac.za>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
'author': 'Auteur',
|
||||
'authors': 'Auteurs',
|
||||
'organization': 'Organisasie',
|
||||
'address': 'Adres',
|
||||
'contact': 'Kontak',
|
||||
'version': 'Weergawe',
|
||||
'revision': 'Revisie',
|
||||
'status': 'Status',
|
||||
'date': 'Datum',
|
||||
'copyright': 'Kopiereg',
|
||||
'dedication': 'Opdrag',
|
||||
'abstract': 'Opsomming',
|
||||
'attention': 'Aandag!',
|
||||
'caution': 'Wees versigtig!',
|
||||
'danger': '!GEVAAR!',
|
||||
'error': 'Fout',
|
||||
'hint': 'Wenk',
|
||||
'important': 'Belangrik',
|
||||
'note': 'Nota',
|
||||
'tip': 'Tip', # hint and tip both have the same translation: wenk
|
||||
'warning': 'Waarskuwing',
|
||||
'contents': 'Inhoud'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
'auteur': 'author',
|
||||
'auteurs': 'authors',
|
||||
'organisasie': 'organization',
|
||||
'adres': 'address',
|
||||
'kontak': 'contact',
|
||||
'weergawe': 'version',
|
||||
'revisie': 'revision',
|
||||
'status': 'status',
|
||||
'datum': 'date',
|
||||
'kopiereg': 'copyright',
|
||||
'opdrag': 'dedication',
|
||||
'opsomming': 'abstract'}
|
||||
"""Afrikaans (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,60 @@
|
||||
# $Id: ca.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Ivan Vilata i Balaguer <ivan@selidor.net>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': 'Autor',
|
||||
'authors': 'Autors',
|
||||
'organization': 'Organitzaci\u00F3',
|
||||
'address': 'Adre\u00E7a',
|
||||
'contact': 'Contacte',
|
||||
'version': 'Versi\u00F3',
|
||||
'revision': 'Revisi\u00F3',
|
||||
'status': 'Estat',
|
||||
'date': 'Data',
|
||||
'copyright': 'Copyright',
|
||||
'dedication': 'Dedicat\u00F2ria',
|
||||
'abstract': 'Resum',
|
||||
'attention': 'Atenci\u00F3!',
|
||||
'caution': 'Compte!',
|
||||
'danger': 'PERILL!',
|
||||
'error': 'Error',
|
||||
'hint': 'Suggeriment',
|
||||
'important': 'Important',
|
||||
'note': 'Nota',
|
||||
'tip': 'Consell',
|
||||
'warning': 'Av\u00EDs',
|
||||
'contents': 'Contingut'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'autor': 'author',
|
||||
'autors': 'authors',
|
||||
'organitzaci\u00F3': 'organization',
|
||||
'adre\u00E7a': 'address',
|
||||
'contacte': 'contact',
|
||||
'versi\u00F3': 'version',
|
||||
'revisi\u00F3': 'revision',
|
||||
'estat': 'status',
|
||||
'data': 'date',
|
||||
'copyright': 'copyright',
|
||||
'dedicat\u00F2ria': 'dedication',
|
||||
'resum': 'abstract'}
|
||||
"""Catalan (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,60 @@
|
||||
# $Id: cs.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Marek Blaha <mb@dat.cz>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': 'Autor',
|
||||
'authors': 'Auto\u0159i',
|
||||
'organization': 'Organizace',
|
||||
'address': 'Adresa',
|
||||
'contact': 'Kontakt',
|
||||
'version': 'Verze',
|
||||
'revision': 'Revize',
|
||||
'status': 'Stav',
|
||||
'date': 'Datum',
|
||||
'copyright': 'Copyright',
|
||||
'dedication': 'V\u011Bnov\u00E1n\u00ED',
|
||||
'abstract': 'Abstrakt',
|
||||
'attention': 'Pozor!',
|
||||
'caution': 'Opatrn\u011B!',
|
||||
'danger': '!NEBEZPE\u010C\u00CD!',
|
||||
'error': 'Chyba',
|
||||
'hint': 'Rada',
|
||||
'important': 'D\u016Fle\u017Eit\u00E9',
|
||||
'note': 'Pozn\u00E1mka',
|
||||
'tip': 'Tip',
|
||||
'warning': 'Varov\u00E1n\u00ED',
|
||||
'contents': 'Obsah'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'autor': 'author',
|
||||
'auto\u0159i': 'authors',
|
||||
'organizace': 'organization',
|
||||
'adresa': 'address',
|
||||
'kontakt': 'contact',
|
||||
'verze': 'version',
|
||||
'revize': 'revision',
|
||||
'stav': 'status',
|
||||
'datum': 'date',
|
||||
'copyright': 'copyright',
|
||||
'v\u011Bnov\u00E1n\u00ED': 'dedication',
|
||||
'abstrakt': 'abstract'}
|
||||
"""Czech (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,62 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# $Id: da.py 7678 2013-07-03 09:57:36Z milde $
|
||||
# Author: E D
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': 'Forfatter',
|
||||
'authors': 'Forfattere',
|
||||
'organization': 'Organisation',
|
||||
'address': 'Adresse',
|
||||
'contact': 'Kontakt',
|
||||
'version': 'Version',
|
||||
'revision': 'Revision',
|
||||
'status': 'Status',
|
||||
'date': 'Dato',
|
||||
'copyright': 'Copyright',
|
||||
'dedication': 'Dedikation',
|
||||
'abstract': 'Resumé',
|
||||
'attention': 'Giv agt!',
|
||||
'caution': 'Pas på!',
|
||||
'danger': '!FARE!',
|
||||
'error': 'Fejl',
|
||||
'hint': 'Vink',
|
||||
'important': 'Vigtigt',
|
||||
'note': 'Bemærk',
|
||||
'tip': 'Tips',
|
||||
'warning': 'Advarsel',
|
||||
'contents': 'Indhold'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'forfatter': 'author',
|
||||
'forfattere': 'authors',
|
||||
'organisation': 'organization',
|
||||
'adresse': 'address',
|
||||
'kontakt': 'contact',
|
||||
'version': 'version',
|
||||
'revision': 'revision',
|
||||
'status': 'status',
|
||||
'dato': 'date',
|
||||
'copyright': 'copyright',
|
||||
'dedikation': 'dedication',
|
||||
'resume': 'abstract',
|
||||
'resumé': 'abstract'}
|
||||
"""Danish (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,58 @@
|
||||
# $Id: de.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Gunnar Schwant <g.schwant@gmx.de>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
'author': 'Autor',
|
||||
'authors': 'Autoren',
|
||||
'organization': 'Organisation',
|
||||
'address': 'Adresse',
|
||||
'contact': 'Kontakt',
|
||||
'version': 'Version',
|
||||
'revision': 'Revision',
|
||||
'status': 'Status',
|
||||
'date': 'Datum',
|
||||
'dedication': 'Widmung',
|
||||
'copyright': 'Copyright',
|
||||
'abstract': 'Zusammenfassung',
|
||||
'attention': 'Achtung!',
|
||||
'caution': 'Vorsicht!',
|
||||
'danger': '!GEFAHR!',
|
||||
'error': 'Fehler',
|
||||
'hint': 'Hinweis',
|
||||
'important': 'Wichtig',
|
||||
'note': 'Bemerkung',
|
||||
'tip': 'Tipp',
|
||||
'warning': 'Warnung',
|
||||
'contents': 'Inhalt'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
'autor': 'author',
|
||||
'autoren': 'authors',
|
||||
'organisation': 'organization',
|
||||
'adresse': 'address',
|
||||
'kontakt': 'contact',
|
||||
'version': 'version',
|
||||
'revision': 'revision',
|
||||
'status': 'status',
|
||||
'datum': 'date',
|
||||
'copyright': 'copyright',
|
||||
'widmung': 'dedication',
|
||||
'zusammenfassung': 'abstract'}
|
||||
"""German (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,60 @@
|
||||
# $Id: en.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': 'Author',
|
||||
'authors': 'Authors',
|
||||
'organization': 'Organization',
|
||||
'address': 'Address',
|
||||
'contact': 'Contact',
|
||||
'version': 'Version',
|
||||
'revision': 'Revision',
|
||||
'status': 'Status',
|
||||
'date': 'Date',
|
||||
'copyright': 'Copyright',
|
||||
'dedication': 'Dedication',
|
||||
'abstract': 'Abstract',
|
||||
'attention': 'Attention!',
|
||||
'caution': 'Caution!',
|
||||
'danger': '!DANGER!',
|
||||
'error': 'Error',
|
||||
'hint': 'Hint',
|
||||
'important': 'Important',
|
||||
'note': 'Note',
|
||||
'tip': 'Tip',
|
||||
'warning': 'Warning',
|
||||
'contents': 'Contents'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'author': 'author',
|
||||
'authors': 'authors',
|
||||
'organization': 'organization',
|
||||
'address': 'address',
|
||||
'contact': 'contact',
|
||||
'version': 'version',
|
||||
'revision': 'revision',
|
||||
'status': 'status',
|
||||
'date': 'date',
|
||||
'copyright': 'copyright',
|
||||
'dedication': 'dedication',
|
||||
'abstract': 'abstract'}
|
||||
"""English (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,61 @@
|
||||
# $Id: eo.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Marcelo Huerta San Martin <richieadler@users.sourceforge.net>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': 'A\u016dtoro',
|
||||
'authors': 'A\u016dtoroj',
|
||||
'organization': 'Organizo',
|
||||
'address': 'Adreso',
|
||||
'contact': 'Kontakto',
|
||||
'version': 'Versio',
|
||||
'revision': 'Revido',
|
||||
'status': 'Stato',
|
||||
'date': 'Dato',
|
||||
# 'copyright': u'Kopirajto',
|
||||
'copyright': 'A\u016dtorrajto',
|
||||
'dedication': 'Dedi\u0109o',
|
||||
'abstract': 'Resumo',
|
||||
'attention': 'Atentu!',
|
||||
'caution': 'Zorgu!',
|
||||
'danger': 'DAN\u011cERO!',
|
||||
'error': 'Eraro',
|
||||
'hint': 'Spuro',
|
||||
'important': 'Grava',
|
||||
'note': 'Noto',
|
||||
'tip': 'Helpeto',
|
||||
'warning': 'Averto',
|
||||
'contents': 'Enhavo'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'a\\u016dtoro': 'author',
|
||||
'a\\u016dtoroj': 'authors',
|
||||
'organizo': 'organization',
|
||||
'adreso': 'address',
|
||||
'kontakto': 'contact',
|
||||
'versio': 'version',
|
||||
'revido': 'revision',
|
||||
'stato': 'status',
|
||||
'dato': 'date',
|
||||
'a\\u016dtorrajto': 'copyright',
|
||||
'dedi\\u0109o': 'dedication',
|
||||
'resumo': 'abstract'}
|
||||
"""Esperanto (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,59 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# $Id: es.py 4572 2006-05-25 20:48:37Z richieadler $
|
||||
# Author: Marcelo Huerta San Martín <richieadler@users.sourceforge.net>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
'author': 'Autor',
|
||||
'authors': 'Autores',
|
||||
'organization': 'Organizaci\u00f3n',
|
||||
'address': 'Direcci\u00f3n',
|
||||
'contact': 'Contacto',
|
||||
'version': 'Versi\u00f3n',
|
||||
'revision': 'Revisi\u00f3n',
|
||||
'status': 'Estado',
|
||||
'date': 'Fecha',
|
||||
'copyright': 'Copyright',
|
||||
'dedication': 'Dedicatoria',
|
||||
'abstract': 'Resumen',
|
||||
'attention': '\u00a1Atenci\u00f3n!',
|
||||
'caution': '\u00a1Precauci\u00f3n!',
|
||||
'danger': '\u00a1PELIGRO!',
|
||||
'error': 'Error',
|
||||
'hint': 'Sugerencia',
|
||||
'important': 'Importante',
|
||||
'note': 'Nota',
|
||||
'tip': 'Consejo',
|
||||
'warning': 'Advertencia',
|
||||
'contents': 'Contenido'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
'autor': 'author',
|
||||
'autores': 'authors',
|
||||
'organizaci\u00f3n': 'organization',
|
||||
'direcci\u00f3n': 'address',
|
||||
'contacto': 'contact',
|
||||
'versi\u00f3n': 'version',
|
||||
'revisi\u00f3n': 'revision',
|
||||
'estado': 'status',
|
||||
'fecha': 'date',
|
||||
'copyright': 'copyright',
|
||||
'dedicatoria': 'dedication',
|
||||
'resumen': 'abstract'}
|
||||
"""Spanish (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,61 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# $Id: fa.py 4564 2016-08-10 11:48:42Z
|
||||
# Author: Shahin <me@5hah.in>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': 'نویسنده',
|
||||
'authors': 'نویسندگان',
|
||||
'organization': 'سازمان',
|
||||
'address': 'آدرس',
|
||||
'contact': 'تماس',
|
||||
'version': 'نسخه',
|
||||
'revision': 'بازبینی',
|
||||
'status': 'وضعیت',
|
||||
'date': 'تاریخ',
|
||||
'copyright': 'کپیرایت',
|
||||
'dedication': 'تخصیص',
|
||||
'abstract': 'چکیده',
|
||||
'attention': 'توجه!',
|
||||
'caution': 'احتیاط!',
|
||||
'danger': 'خطر!',
|
||||
'error': 'خطا',
|
||||
'hint': 'راهنما',
|
||||
'important': 'مهم',
|
||||
'note': 'یادداشت',
|
||||
'tip': 'نکته',
|
||||
'warning': 'اخطار',
|
||||
'contents': 'محتوا'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'نویسنده': 'author',
|
||||
'نویسندگان': 'authors',
|
||||
'سازمان': 'organization',
|
||||
'آدرس': 'address',
|
||||
'تماس': 'contact',
|
||||
'نسخه': 'version',
|
||||
'بازبینی': 'revision',
|
||||
'وضعیت': 'status',
|
||||
'تاریخ': 'date',
|
||||
'کپیرایت': 'copyright',
|
||||
'تخصیص': 'dedication',
|
||||
'چکیده': 'abstract'}
|
||||
"""Persian (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = ['؛', '،']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,60 @@
|
||||
# $Id: fi.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Asko Soukka <asko.soukka@iki.fi>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': 'Tekij\u00e4',
|
||||
'authors': 'Tekij\u00e4t',
|
||||
'organization': 'Yhteis\u00f6',
|
||||
'address': 'Osoite',
|
||||
'contact': 'Yhteystiedot',
|
||||
'version': 'Versio',
|
||||
'revision': 'Vedos',
|
||||
'status': 'Tila',
|
||||
'date': 'P\u00e4iv\u00e4ys',
|
||||
'copyright': 'Tekij\u00e4noikeudet',
|
||||
'dedication': 'Omistuskirjoitus',
|
||||
'abstract': 'Tiivistelm\u00e4',
|
||||
'attention': 'Huomio!',
|
||||
'caution': 'Varo!',
|
||||
'danger': '!VAARA!',
|
||||
'error': 'Virhe',
|
||||
'hint': 'Vihje',
|
||||
'important': 'T\u00e4rke\u00e4\u00e4',
|
||||
'note': 'Huomautus',
|
||||
'tip': 'Neuvo',
|
||||
'warning': 'Varoitus',
|
||||
'contents': 'Sis\u00e4llys'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'tekij\u00e4': 'author',
|
||||
'tekij\u00e4t': 'authors',
|
||||
'yhteis\u00f6': 'organization',
|
||||
'osoite': 'address',
|
||||
'yhteystiedot': 'contact',
|
||||
'versio': 'version',
|
||||
'vedos': 'revision',
|
||||
'tila': 'status',
|
||||
'p\u00e4iv\u00e4ys': 'date',
|
||||
'tekij\u00e4noikeudet': 'copyright',
|
||||
'omistuskirjoitus': 'dedication',
|
||||
'tiivistelm\u00e4': 'abstract'}
|
||||
"""Finnish (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,58 @@
|
||||
# $Id: fr.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Stefane Fermigier <sf@fermigier.com>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
'author': 'Auteur',
|
||||
'authors': 'Auteurs',
|
||||
'organization': 'Organisation',
|
||||
'address': 'Adresse',
|
||||
'contact': 'Contact',
|
||||
'version': 'Version',
|
||||
'revision': 'R\u00e9vision',
|
||||
'status': 'Statut',
|
||||
'date': 'Date',
|
||||
'copyright': 'Copyright',
|
||||
'dedication': 'D\u00e9dicace',
|
||||
'abstract': 'R\u00e9sum\u00e9',
|
||||
'attention': 'Attention!',
|
||||
'caution': 'Avertissement!',
|
||||
'danger': '!DANGER!',
|
||||
'error': 'Erreur',
|
||||
'hint': 'Indication',
|
||||
'important': 'Important',
|
||||
'note': 'Note',
|
||||
'tip': 'Astuce',
|
||||
'warning': 'Avis',
|
||||
'contents': 'Sommaire'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
'auteur': 'author',
|
||||
'auteurs': 'authors',
|
||||
'organisation': 'organization',
|
||||
'adresse': 'address',
|
||||
'contact': 'contact',
|
||||
'version': 'version',
|
||||
'r\u00e9vision': 'revision',
|
||||
'statut': 'status',
|
||||
'date': 'date',
|
||||
'copyright': 'copyright',
|
||||
'd\u00e9dicace': 'dedication',
|
||||
'r\u00e9sum\u00e9': 'abstract'}
|
||||
"""French (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,63 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Author: David Goodger
|
||||
# Contact: goodger@users.sourceforge.net
|
||||
# Revision: $Revision: 2224 $
|
||||
# Date: $Date: 2004-06-05 21:40:46 +0200 (Sat, 05 Jun 2004) $
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': 'Autor',
|
||||
'authors': 'Autores',
|
||||
'organization': 'Organizaci\u00f3n',
|
||||
'address': 'Enderezo',
|
||||
'contact': 'Contacto',
|
||||
'version': 'Versi\u00f3n',
|
||||
'revision': 'Revisi\u00f3n',
|
||||
'status': 'Estado',
|
||||
'date': 'Data',
|
||||
'copyright': 'Dereitos de copia',
|
||||
'dedication': 'Dedicatoria',
|
||||
'abstract': 'Abstract',
|
||||
'attention': 'Atenci\u00f3n!',
|
||||
'caution': 'Advertencia!',
|
||||
'danger': 'PERIGO!',
|
||||
'error': 'Erro',
|
||||
'hint': 'Consello',
|
||||
'important': 'Importante',
|
||||
'note': 'Nota',
|
||||
'tip': 'Suxesti\u00f3n',
|
||||
'warning': 'Aviso',
|
||||
'contents': 'Contido'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'autor': 'author',
|
||||
'autores': 'authors',
|
||||
'organizaci\u00f3n': 'organization',
|
||||
'enderezo': 'address',
|
||||
'contacto': 'contact',
|
||||
'versi\u00f3n': 'version',
|
||||
'revisi\u00f3n': 'revision',
|
||||
'estado': 'status',
|
||||
'data': 'date',
|
||||
'dereitos de copia': 'copyright',
|
||||
'dedicatoria': 'dedication',
|
||||
'abstract': 'abstract'}
|
||||
"""Galician (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,60 @@
|
||||
# Author: Meir Kriheli
|
||||
# Id: $Id: he.py 4837 2006-12-26 09:59:41Z sfcben $
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': '\u05de\u05d7\u05d1\u05e8',
|
||||
'authors': '\u05de\u05d7\u05d1\u05e8\u05d9',
|
||||
'organization': '\u05d0\u05e8\u05d2\u05d5\u05df',
|
||||
'address': '\u05db\u05ea\u05d5\u05d1\u05ea',
|
||||
'contact': '\u05d0\u05d9\u05e9 \u05e7\u05e9\u05e8',
|
||||
'version': '\u05d2\u05e8\u05e1\u05d4',
|
||||
'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',
|
||||
'dedication': '\u05d4\u05e7\u05d3\u05e9\u05d4',
|
||||
'abstract': '\u05ea\u05e7\u05e6\u05d9\u05e8',
|
||||
'attention': '\u05ea\u05e9\u05d5\u05de\u05ea \u05dc\u05d1',
|
||||
'caution': '\u05d6\u05d4\u05d9\u05e8\u05d5\u05ea',
|
||||
'danger': '\u05e1\u05db\u05e0\u05d4',
|
||||
'error': '\u05e9\u05d2\u05d9\u05d0\u05d4' ,
|
||||
'hint': '\u05e8\u05de\u05d6',
|
||||
'important': '\u05d7\u05e9\u05d5\u05d1',
|
||||
'note': '\u05d4\u05e2\u05e8\u05d4',
|
||||
'tip': '\u05d8\u05d9\u05e4',
|
||||
'warning': '\u05d0\u05d6\u05d4\u05e8\u05d4',
|
||||
'contents': '\u05ea\u05d5\u05db\u05df'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'\u05de\u05d7\u05d1\u05e8': 'author',
|
||||
'\u05de\u05d7\u05d1\u05e8\u05d9': 'authors',
|
||||
'\u05d0\u05e8\u05d2\u05d5\u05df': 'organization',
|
||||
'\u05db\u05ea\u05d5\u05d1\u05ea': 'address',
|
||||
'\u05d0\u05d9\u05e9 \u05e7\u05e9\u05e8': 'contact',
|
||||
'\u05d2\u05e8\u05e1\u05d4': 'version',
|
||||
'\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',
|
||||
'\u05d4\u05e7\u05d3\u05e9\u05d4': 'dedication',
|
||||
'\u05ea\u05e7\u05e6\u05d9\u05e8': 'abstract'}
|
||||
"""Hebrew to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,58 @@
|
||||
# $Id: it.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Nicola Larosa <docutils@tekNico.net>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
'author': 'Autore',
|
||||
'authors': 'Autori',
|
||||
'organization': 'Organizzazione',
|
||||
'address': 'Indirizzo',
|
||||
'contact': 'Contatti',
|
||||
'version': 'Versione',
|
||||
'revision': 'Revisione',
|
||||
'status': 'Status',
|
||||
'date': 'Data',
|
||||
'copyright': 'Copyright',
|
||||
'dedication': 'Dedica',
|
||||
'abstract': 'Riassunto',
|
||||
'attention': 'Attenzione!',
|
||||
'caution': 'Cautela!',
|
||||
'danger': '!PERICOLO!',
|
||||
'error': 'Errore',
|
||||
'hint': 'Suggerimento',
|
||||
'important': 'Importante',
|
||||
'note': 'Nota',
|
||||
'tip': 'Consiglio',
|
||||
'warning': 'Avvertenza',
|
||||
'contents': 'Indice'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
'autore': 'author',
|
||||
'autori': 'authors',
|
||||
'organizzazione': 'organization',
|
||||
'indirizzo': 'address',
|
||||
'contatto': 'contact',
|
||||
'versione': 'version',
|
||||
'revisione': 'revision',
|
||||
'status': 'status',
|
||||
'data': 'date',
|
||||
'copyright': 'copyright',
|
||||
'dedica': 'dedication',
|
||||
'riassunto': 'abstract'}
|
||||
"""Italian (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,61 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# $Id: ja.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Hisashi Morita <hisashim@kt.rim.or.jp>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': '著者',
|
||||
'authors': '著者',
|
||||
'organization': '組織',
|
||||
'address': '住所',
|
||||
'contact': '連絡先',
|
||||
'version': 'バージョン',
|
||||
'revision': 'リビジョン',
|
||||
'status': 'ステータス',
|
||||
'date': '日付',
|
||||
'copyright': '著作権',
|
||||
'dedication': '献辞',
|
||||
'abstract': '概要',
|
||||
'attention': '注目!',
|
||||
'caution': '注意!',
|
||||
'danger': '!危険!',
|
||||
'error': 'エラー',
|
||||
'hint': 'ヒント',
|
||||
'important': '重要',
|
||||
'note': '備考',
|
||||
'tip': '通報',
|
||||
'warning': '警告',
|
||||
'contents': '目次'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'著者': 'author',
|
||||
' n/a': 'authors',
|
||||
'組織': 'organization',
|
||||
'住所': 'address',
|
||||
'連絡先': 'contact',
|
||||
'バージョン': 'version',
|
||||
'リビジョン': 'revision',
|
||||
'ステータス': 'status',
|
||||
'日付': 'date',
|
||||
'著作権': 'copyright',
|
||||
'献辞': 'dedication',
|
||||
'概要': 'abstract'}
|
||||
"""Japanese (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,61 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# $Id: ko.py 8253 2019-04-15 10:01:10Z milde $
|
||||
# Author: Thomas SJ Kang <thomas.kangsj@ujuc.kr>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': '저자',
|
||||
'authors': '저자들',
|
||||
'organization': '조직',
|
||||
'address': '주소',
|
||||
'contact': '연락처',
|
||||
'version': 'Version',
|
||||
'revision': 'Revision',
|
||||
'status': '상태',
|
||||
'date': '날짜',
|
||||
'copyright': '저작권',
|
||||
'dedication': '헌정',
|
||||
'abstract': '요약',
|
||||
'attention': '집중!',
|
||||
'caution': '주의!',
|
||||
'danger': '!위험!',
|
||||
'error': '오류',
|
||||
'hint': '실마리',
|
||||
'important': '중요한',
|
||||
'note': '비고',
|
||||
'tip': '팁',
|
||||
'warning': '경고',
|
||||
'contents': '목차'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'저자': 'author',
|
||||
'저자들': 'authors',
|
||||
'조직': 'organization',
|
||||
'주소': 'address',
|
||||
'연락처': 'contact',
|
||||
'version': 'version',
|
||||
'revision': 'revision',
|
||||
'상태': 'status',
|
||||
'날짜': 'date',
|
||||
'저작권': 'copyright',
|
||||
'헌정': 'dedication',
|
||||
'요약': 'abstract'}
|
||||
"""Korean to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,61 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# $Id: lt.py 7911 2015-08-31 08:23:06Z milde $
|
||||
# Author: Dalius Dobravolskas <dalius.do...@gmail.com>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': 'Autorius',
|
||||
'authors': 'Autoriai',
|
||||
'organization': 'Organizacija',
|
||||
'address': 'Adresas',
|
||||
'contact': 'Kontaktas',
|
||||
'version': 'Versija',
|
||||
'revision': 'Revizija',
|
||||
'status': 'Būsena',
|
||||
'date': 'Data',
|
||||
'copyright': 'Autoriaus teisės',
|
||||
'dedication': 'Dedikacija',
|
||||
'abstract': 'Santrauka',
|
||||
'attention': 'Dėmesio!',
|
||||
'caution': 'Atsargiai!',
|
||||
'danger': '!PAVOJINGA!',
|
||||
'error': 'Klaida',
|
||||
'hint': 'Užuomina',
|
||||
'important': 'Svarbu',
|
||||
'note': 'Pastaba',
|
||||
'tip': 'Patarimas',
|
||||
'warning': 'Įspėjimas',
|
||||
'contents': 'Turinys'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'autorius': 'author',
|
||||
'autoriai': 'authors',
|
||||
'organizacija': 'organization',
|
||||
'adresas': 'address',
|
||||
'kontaktas': 'contact',
|
||||
'versija': 'version',
|
||||
'revizija': 'revision',
|
||||
'būsena': 'status',
|
||||
'data': 'date',
|
||||
'autoriaus teisės': 'copyright',
|
||||
'dedikacija': 'dedication',
|
||||
'santrauka': 'abstract'}
|
||||
"""Lithuanian (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,60 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# $Id: lv.py 7975 2016-10-20 20:00:19Z milde $
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': 'Autors',
|
||||
'authors': 'Autori',
|
||||
'organization': 'Organizācija',
|
||||
'address': 'Adrese',
|
||||
'contact': 'Kontakti',
|
||||
'version': 'Versija',
|
||||
'revision': 'Revīzija',
|
||||
'status': 'Statuss',
|
||||
'date': 'Datums',
|
||||
'copyright': 'Copyright',
|
||||
'dedication': 'Veltījums',
|
||||
'abstract': 'Atreferējums',
|
||||
'attention': 'Uzmanību!',
|
||||
'caution': 'Piesardzību!',
|
||||
'danger': '!BĪSTAMI!',
|
||||
'error': 'Kļūda',
|
||||
'hint': 'Ieteikums',
|
||||
'important': 'Svarīgi',
|
||||
'note': 'Piezīme',
|
||||
'tip': 'Padoms',
|
||||
'warning': 'Brīdinājums',
|
||||
'contents': 'Saturs'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'autors': 'author',
|
||||
'autori': 'authors',
|
||||
'organizācija': 'organization',
|
||||
'adrese': 'address',
|
||||
'kontakti': 'contact',
|
||||
'versija': 'version',
|
||||
'revīzija': 'revision',
|
||||
'statuss': 'status',
|
||||
'datums': 'date',
|
||||
'copyright': 'copyright',
|
||||
'veltījums': 'dedication',
|
||||
'atreferējums': 'abstract'}
|
||||
"""English (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,60 @@
|
||||
# $Id: nl.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Martijn Pieters <mjpieters@users.sourceforge.net>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': 'Auteur',
|
||||
'authors': 'Auteurs',
|
||||
'organization': 'Organisatie',
|
||||
'address': 'Adres',
|
||||
'contact': 'Contact',
|
||||
'version': 'Versie',
|
||||
'revision': 'Revisie',
|
||||
'status': 'Status',
|
||||
'date': 'Datum',
|
||||
'copyright': 'Copyright',
|
||||
'dedication': 'Toewijding',
|
||||
'abstract': 'Samenvatting',
|
||||
'attention': 'Attentie!',
|
||||
'caution': 'Let op!',
|
||||
'danger': '!GEVAAR!',
|
||||
'error': 'Fout',
|
||||
'hint': 'Hint',
|
||||
'important': 'Belangrijk',
|
||||
'note': 'Opmerking',
|
||||
'tip': 'Tip',
|
||||
'warning': 'Waarschuwing',
|
||||
'contents': 'Inhoud'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'auteur': 'author',
|
||||
'auteurs': 'authors',
|
||||
'organisatie': 'organization',
|
||||
'adres': 'address',
|
||||
'contact': 'contact',
|
||||
'versie': 'version',
|
||||
'revisie': 'revision',
|
||||
'status': 'status',
|
||||
'datum': 'date',
|
||||
'copyright': 'copyright',
|
||||
'toewijding': 'dedication',
|
||||
'samenvatting': 'abstract'}
|
||||
"""Dutch (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,62 @@
|
||||
# $Id$
|
||||
# Author: Robert Wojciechowicz <rw@smsnet.pl>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': 'Autor',
|
||||
'authors': 'Autorzy',
|
||||
'organization': 'Organizacja',
|
||||
'address': 'Adres',
|
||||
'contact': 'Kontakt',
|
||||
'version': 'Wersja',
|
||||
'revision': 'Korekta',
|
||||
'status': 'Status',
|
||||
'date': 'Data',
|
||||
'copyright': 'Copyright',
|
||||
'dedication': 'Dedykacja',
|
||||
'abstract': 'Streszczenie',
|
||||
'attention': 'Uwaga!',
|
||||
'caution': 'Ostro\u017cnie!',
|
||||
'danger': '!Niebezpiecze\u0144stwo!',
|
||||
'error': 'B\u0142\u0105d',
|
||||
'hint': 'Wskaz\u00f3wka',
|
||||
'important': 'Wa\u017cne',
|
||||
'note': 'Przypis',
|
||||
'tip': 'Rada',
|
||||
'warning': 'Ostrze\u017cenie',
|
||||
'contents': 'Tre\u015b\u0107'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'autor': 'author',
|
||||
'autorzy': 'authors',
|
||||
'organizacja': 'organization',
|
||||
'adres': 'address',
|
||||
'kontakt': 'contact',
|
||||
'wersja': 'version',
|
||||
'korekta': 'revision',
|
||||
'status': 'status',
|
||||
'data': 'date',
|
||||
'copyright': 'copyright',
|
||||
'dedykacja': 'dedication',
|
||||
'streszczenie': 'abstract'}
|
||||
"""Polish (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
# $Id: pt_br.py 5567 2008-06-03 01:11:03Z goodger $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/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.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': 'Autor',
|
||||
'authors': 'Autores',
|
||||
'organization': 'Organiza\u00E7\u00E3o',
|
||||
'address': 'Endere\u00E7o',
|
||||
'contact': 'Contato',
|
||||
'version': 'Vers\u00E3o',
|
||||
'revision': 'Revis\u00E3o',
|
||||
'status': 'Estado',
|
||||
'date': 'Data',
|
||||
'copyright': 'Copyright',
|
||||
'dedication': 'Dedicat\u00F3ria',
|
||||
'abstract': 'Resumo',
|
||||
'attention': 'Aten\u00E7\u00E3o!',
|
||||
'caution': 'Cuidado!',
|
||||
'danger': 'PERIGO!',
|
||||
'error': 'Erro',
|
||||
'hint': 'Sugest\u00E3o',
|
||||
'important': 'Importante',
|
||||
'note': 'Nota',
|
||||
'tip': 'Dica',
|
||||
'warning': 'Aviso',
|
||||
'contents': 'Sum\u00E1rio'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'autor': 'author',
|
||||
'autores': 'authors',
|
||||
'organiza\u00E7\u00E3o': 'organization',
|
||||
'endere\u00E7o': 'address',
|
||||
'contato': 'contact',
|
||||
'vers\u00E3o': 'version',
|
||||
'revis\u00E3o': 'revision',
|
||||
'estado': 'status',
|
||||
'data': 'date',
|
||||
'copyright': 'copyright',
|
||||
'dedicat\u00F3ria': 'dedication',
|
||||
'resumo': 'abstract'}
|
||||
"""Brazilian Portuguese (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,59 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# $Id: ru.py 7125 2011-09-16 18:36:18Z milde $
|
||||
# Author: Roman Suzi <rnd@onego.ru>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
|
||||
# translated for each language: one in docutils/languages, the other in
|
||||
# docutils/parsers/rst/languages.
|
||||
|
||||
"""
|
||||
Russian-language mappings for language-dependent features of Docutils.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
'abstract': 'Аннотация',
|
||||
'address': 'Адрес',
|
||||
'attention': 'Внимание!',
|
||||
'author': 'Автор',
|
||||
'authors': 'Авторы',
|
||||
'caution': 'Осторожно!',
|
||||
'contact': 'Контакт',
|
||||
'contents': 'Содержание',
|
||||
'copyright': 'Права копирования',
|
||||
'danger': 'ОПАСНО!',
|
||||
'date': 'Дата',
|
||||
'dedication': 'Посвящение',
|
||||
'error': 'Ошибка',
|
||||
'hint': 'Совет',
|
||||
'important': 'Важно',
|
||||
'note': 'Примечание',
|
||||
'organization': 'Организация',
|
||||
'revision': 'Редакция',
|
||||
'status': 'Статус',
|
||||
'tip': 'Подсказка',
|
||||
'version': 'Версия',
|
||||
'warning': 'Предупреждение'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
'аннотация': 'abstract',
|
||||
'адрес': 'address',
|
||||
'автор': 'author',
|
||||
'авторы': 'authors',
|
||||
'контакт': 'contact',
|
||||
'права копирования': 'copyright',
|
||||
'дата': 'date',
|
||||
'посвящение': 'dedication',
|
||||
'организация': 'organization',
|
||||
'редакция': 'revision',
|
||||
'статус': 'status',
|
||||
'версия': 'version'}
|
||||
"""Russian (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,58 @@
|
||||
# $Id: sk.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Miroslav Vasko <zemiak@zoznam.sk>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
|
||||
# translated for each language: one in docutils/languages, the other in
|
||||
# docutils/parsers/rst/languages.
|
||||
|
||||
"""
|
||||
Slovak-language mappings for language-dependent features of Docutils.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
'author': 'Autor',
|
||||
'authors': 'Autori',
|
||||
'organization': 'Organiz\u00E1cia',
|
||||
'address': 'Adresa',
|
||||
'contact': 'Kontakt',
|
||||
'version': 'Verzia',
|
||||
'revision': 'Rev\u00EDzia',
|
||||
'status': 'Stav',
|
||||
'date': 'D\u00E1tum',
|
||||
'copyright': 'Copyright',
|
||||
'dedication': 'Venovanie',
|
||||
'abstract': 'Abstraktne',
|
||||
'attention': 'Pozor!',
|
||||
'caution': 'Opatrne!',
|
||||
'danger': '!NEBEZPE\u010cENSTVO!',
|
||||
'error': 'Chyba',
|
||||
'hint': 'Rada',
|
||||
'important': 'D\u00F4le\u017Eit\u00E9',
|
||||
'note': 'Pozn\u00E1mka',
|
||||
'tip': 'Tip',
|
||||
'warning': 'Varovanie',
|
||||
'contents': 'Obsah'}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
'autor': 'author',
|
||||
'autori': 'authors',
|
||||
'organiz\u00E1cia': 'organization',
|
||||
'adresa': 'address',
|
||||
'kontakt': 'contact',
|
||||
'verzia': 'version',
|
||||
'rev\u00EDzia': 'revision',
|
||||
'stav': 'status',
|
||||
'd\u00E1tum': 'date',
|
||||
'copyright': 'copyright',
|
||||
'venovanie': 'dedication',
|
||||
'abstraktne': 'abstract'}
|
||||
"""Slovak (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,60 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# $Id: sv.py 8006 2016-12-22 23:02:44Z milde $
|
||||
# Author: Adam Chodorowski <chodorowski@users.sourceforge.net>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
|
||||
# translated for each language: one in docutils/languages, the other in
|
||||
# docutils/parsers/rst/languages.
|
||||
|
||||
"""
|
||||
Swedish language mappings for language-dependent features of Docutils.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
'author': 'Författare',
|
||||
'authors': 'Författare',
|
||||
'organization': 'Organisation',
|
||||
'address': 'Adress',
|
||||
'contact': 'Kontakt',
|
||||
'version': 'Version',
|
||||
'revision': 'Revision',
|
||||
'status': 'Status',
|
||||
'date': 'Datum',
|
||||
'copyright': 'Copyright',
|
||||
'dedication': 'Dedikation',
|
||||
'abstract': 'Sammanfattning',
|
||||
'attention': 'Observera!',
|
||||
'caution': 'Akta!', # 'Varning' already used for 'warning'
|
||||
'danger': 'FARA!',
|
||||
'error': 'Fel',
|
||||
'hint': 'Vink',
|
||||
'important': 'Viktigt',
|
||||
'note': 'Notera',
|
||||
'tip': 'Tips',
|
||||
'warning': 'Varning',
|
||||
'contents': 'Innehåll' }
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# 'Author' and 'Authors' identical in Swedish; assume the plural:
|
||||
'författare': 'authors',
|
||||
' n/a': 'author',
|
||||
'organisation': 'organization',
|
||||
'adress': 'address',
|
||||
'kontakt': 'contact',
|
||||
'version': 'version',
|
||||
'revision': 'revision',
|
||||
'status': 'status',
|
||||
'datum': 'date',
|
||||
'copyright': 'copyright',
|
||||
'dedikation': 'dedication',
|
||||
'sammanfattning': 'abstract' }
|
||||
"""Swedish (lowcased) to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',']
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,67 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# $Id: zh_cn.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Pan Junyong <panjy@zopechina.com>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
|
||||
# translated for each language: one in docutils/languages, the other in
|
||||
# docutils/parsers/rst/languages.
|
||||
|
||||
"""
|
||||
Simplified Chinese language mappings for language-dependent features
|
||||
of Docutils.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': '作者',
|
||||
'authors': '作者群',
|
||||
'organization': '组织',
|
||||
'address': '地址',
|
||||
'contact': '联系',
|
||||
'version': '版本',
|
||||
'revision': '修订',
|
||||
'status': '状态',
|
||||
'date': '日期',
|
||||
'copyright': '版权',
|
||||
'dedication': '献辞',
|
||||
'abstract': '摘要',
|
||||
'attention': '注意',
|
||||
'caution': '小心',
|
||||
'danger': '危险',
|
||||
'error': '错误',
|
||||
'hint': '提示',
|
||||
'important': '重要',
|
||||
'note': '注解',
|
||||
'tip': '技巧',
|
||||
'warning': '警告',
|
||||
'contents': '目录',
|
||||
}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'作者': 'author',
|
||||
'作者群': 'authors',
|
||||
'组织': 'organization',
|
||||
'地址': 'address',
|
||||
'联系': 'contact',
|
||||
'版本': 'version',
|
||||
'修订': 'revision',
|
||||
'状态': 'status',
|
||||
'时间': 'date',
|
||||
'版权': 'copyright',
|
||||
'献辞': 'dedication',
|
||||
'摘要': 'abstract'}
|
||||
"""Simplified Chinese to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',',
|
||||
'\uff1b', # ';'
|
||||
'\uff0c', # ','
|
||||
'\u3001', # '、'
|
||||
]
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
@@ -0,0 +1,66 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# $Id: zh_tw.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Joe YS Jaw <joeysj@users.sourceforge.net>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
# New language mappings are welcome. Before doing a new translation, please
|
||||
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
|
||||
# translated for each language: one in docutils/languages, the other in
|
||||
# docutils/parsers/rst/languages.
|
||||
|
||||
"""
|
||||
Traditional Chinese language mappings for language-dependent features of Docutils.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
labels = {
|
||||
# fixed: language-dependent
|
||||
'author': '\u4f5c\u8005', # '作者' <-- Chinese word
|
||||
'authors': '\u4f5c\u8005\u7fa4', # '作者群',
|
||||
'organization': '\u7d44\u7e54', # '組織',
|
||||
'address': '\u5730\u5740', # '地址',
|
||||
'contact': '\u9023\u7d61', # '連絡',
|
||||
'version': '\u7248\u672c', # '版本',
|
||||
'revision': '\u4fee\u8a02', # '修訂',
|
||||
'status': '\u72c0\u614b', # '狀態',
|
||||
'date': '\u65e5\u671f', # '日期',
|
||||
'copyright': '\u7248\u6b0a', # '版權',
|
||||
'dedication': '\u984c\u737b', # '題獻',
|
||||
'abstract': '\u6458\u8981', # '摘要',
|
||||
'attention': '\u6ce8\u610f\uff01', # '注意!',
|
||||
'caution': '\u5c0f\u5fc3\uff01', # '小心!',
|
||||
'danger': '\uff01\u5371\u96aa\uff01', # '!危險!',
|
||||
'error': '\u932f\u8aa4', # '錯誤',
|
||||
'hint': '\u63d0\u793a', # '提示',
|
||||
'important': '\u91cd\u8981', # '注意!',
|
||||
'note': '\u8a3b\u91cb', # '註釋',
|
||||
'tip': '\u79d8\u8a23', # '秘訣',
|
||||
'warning': '\u8b66\u544a', # '警告',
|
||||
'contents': '\u76ee\u9304' # '目錄'
|
||||
}
|
||||
"""Mapping of node class name to label text."""
|
||||
|
||||
bibliographic_fields = {
|
||||
# language-dependent: fixed
|
||||
'author (translation required)': 'author',
|
||||
'authors (translation required)': 'authors',
|
||||
'organization (translation required)': 'organization',
|
||||
'address (translation required)': 'address',
|
||||
'contact (translation required)': 'contact',
|
||||
'version (translation required)': 'version',
|
||||
'revision (translation required)': 'revision',
|
||||
'status (translation required)': 'status',
|
||||
'date (translation required)': 'date',
|
||||
'copyright (translation required)': 'copyright',
|
||||
'dedication (translation required)': 'dedication',
|
||||
'abstract (translation required)': 'abstract'}
|
||||
"""Traditional Chinese to canonical name mapping for bibliographic fields."""
|
||||
|
||||
author_separators = [';', ',',
|
||||
'\uff1b', # ';'
|
||||
'\uff0c', # ','
|
||||
'\u3001', # '、'
|
||||
]
|
||||
"""List of separator strings for the 'Authors' bibliographic field. Tried in
|
||||
order."""
|
||||
2234
parkingkonceptvenv/lib/python3.7/site-packages/docutils/nodes.py
Normal file
2234
parkingkonceptvenv/lib/python3.7/site-packages/docutils/nodes.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,51 @@
|
||||
# $Id: __init__.py 8239 2018-11-21 21:46:00Z milde $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
This package contains Docutils parser modules.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
import sys
|
||||
from docutils import Component
|
||||
|
||||
|
||||
class Parser(Component):
|
||||
|
||||
component_type = 'parser'
|
||||
config_section = 'parsers'
|
||||
|
||||
def parse(self, inputstring, document):
|
||||
"""Override to parse `inputstring` into document tree `document`."""
|
||||
raise NotImplementedError('subclass must override this method')
|
||||
|
||||
def setup_parse(self, inputstring, document):
|
||||
"""Initial parse setup. Call at start of `self.parse()`."""
|
||||
self.inputstring = inputstring
|
||||
self.document = document
|
||||
document.reporter.attach_observer(document.note_parse_message)
|
||||
|
||||
def finish_parse(self):
|
||||
"""Finalize parse details. Call at end of `self.parse()`."""
|
||||
self.document.reporter.detach_observer(
|
||||
self.document.note_parse_message)
|
||||
|
||||
|
||||
_parser_aliases = {
|
||||
'restructuredtext': 'rst',
|
||||
'rest': 'rst',
|
||||
'restx': 'rst',
|
||||
'rtxt': 'rst',}
|
||||
|
||||
def get_parser_class(parser_name):
|
||||
"""Return the Parser class from the `parser_name` module."""
|
||||
parser_name = parser_name.lower()
|
||||
if parser_name in _parser_aliases:
|
||||
parser_name = _parser_aliases[parser_name]
|
||||
try:
|
||||
module = __import__(parser_name, globals(), locals(), level=1)
|
||||
except ImportError:
|
||||
module = __import__(parser_name, globals(), locals(), level=0)
|
||||
return module.Parser
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
# $Id: null.py 4564 2006-05-21 20:44:42Z wiemann $
|
||||
# Author: Martin Blais <blais@furius.ca>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""A do-nothing parser."""
|
||||
|
||||
from docutils import parsers
|
||||
|
||||
|
||||
class Parser(parsers.Parser):
|
||||
|
||||
"""A do-nothing parser."""
|
||||
|
||||
supported = ('null',)
|
||||
|
||||
config_section = 'null parser'
|
||||
config_section_dependencies = ('parsers',)
|
||||
|
||||
def parse(self, inputstring, document):
|
||||
pass
|
||||
@@ -0,0 +1,416 @@
|
||||
# $Id: __init__.py 8258 2019-06-25 18:15:26Z milde $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
This is ``docutils.parsers.rst`` package. It exports a single class, `Parser`,
|
||||
the reStructuredText parser.
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
1. Create a parser::
|
||||
|
||||
parser = docutils.parsers.rst.Parser()
|
||||
|
||||
Several optional arguments may be passed to modify the parser's behavior.
|
||||
Please see `Customizing the Parser`_ below for details.
|
||||
|
||||
2. Gather input (a multi-line string), by reading a file or the standard
|
||||
input::
|
||||
|
||||
input = sys.stdin.read()
|
||||
|
||||
3. Create a new empty `docutils.nodes.document` tree::
|
||||
|
||||
document = docutils.utils.new_document(source, settings)
|
||||
|
||||
See `docutils.utils.new_document()` for parameter details.
|
||||
|
||||
4. Run the parser, populating the document tree::
|
||||
|
||||
parser.parse(input, document)
|
||||
|
||||
|
||||
Parser Overview
|
||||
===============
|
||||
|
||||
The reStructuredText parser is implemented as a state machine, examining its
|
||||
input one line at a time. To understand how the parser works, please first
|
||||
become familiar with the `docutils.statemachine` module, then see the
|
||||
`states` module.
|
||||
|
||||
|
||||
Customizing the Parser
|
||||
----------------------
|
||||
|
||||
Anything that isn't already customizable is that way simply because that type
|
||||
of customizability hasn't been implemented yet. Patches welcome!
|
||||
|
||||
When instantiating an object of the `Parser` class, two parameters may be
|
||||
passed: ``rfc2822`` and ``inliner``. Pass ``rfc2822=True`` to enable an
|
||||
initial RFC-2822 style header block, parsed as a "field_list" element (with
|
||||
"class" attribute set to "rfc2822"). Currently this is the only body-level
|
||||
element which is customizable without subclassing. (Tip: subclass `Parser`
|
||||
and change its "state_classes" and "initial_state" attributes to refer to new
|
||||
classes. Contact the author if you need more details.)
|
||||
|
||||
The ``inliner`` parameter takes an instance of `states.Inliner` or a subclass.
|
||||
It handles inline markup recognition. A common extension is the addition of
|
||||
further implicit hyperlinks, like "RFC 2822". This can be done by subclassing
|
||||
`states.Inliner`, adding a new method for the implicit markup, and adding a
|
||||
``(pattern, method)`` pair to the "implicit_dispatch" attribute of the
|
||||
subclass. See `states.Inliner.implicit_inline()` for details. Explicit
|
||||
inline markup can be customized in a `states.Inliner` subclass via the
|
||||
``patterns.initial`` and ``dispatch`` attributes (and new methods as
|
||||
appropriate).
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
|
||||
import docutils.parsers
|
||||
import docutils.statemachine
|
||||
from docutils.parsers.rst import states
|
||||
from docutils import frontend, nodes, Component
|
||||
from docutils.transforms import universal
|
||||
|
||||
|
||||
class Parser(docutils.parsers.Parser):
|
||||
|
||||
"""The reStructuredText parser."""
|
||||
|
||||
supported = ('restructuredtext', 'rst', 'rest', 'restx', 'rtxt', 'rstx')
|
||||
"""Aliases this parser supports."""
|
||||
|
||||
settings_spec = (
|
||||
'reStructuredText Parser Options',
|
||||
None,
|
||||
(('Recognize and link to standalone PEP references (like "PEP 258").',
|
||||
['--pep-references'],
|
||||
{'action': 'store_true', 'validator': frontend.validate_boolean}),
|
||||
('Base URL for PEP references '
|
||||
'(default "http://www.python.org/dev/peps/").',
|
||||
['--pep-base-url'],
|
||||
{'metavar': '<URL>', 'default': 'http://www.python.org/dev/peps/',
|
||||
'validator': frontend.validate_url_trailing_slash}),
|
||||
('Template for PEP file part of URL. (default "pep-%04d")',
|
||||
['--pep-file-url-template'],
|
||||
{'metavar': '<URL>', 'default': 'pep-%04d'}),
|
||||
('Recognize and link to standalone RFC references (like "RFC 822").',
|
||||
['--rfc-references'],
|
||||
{'action': 'store_true', 'validator': frontend.validate_boolean}),
|
||||
('Base URL for RFC references (default "http://tools.ietf.org/html/").',
|
||||
['--rfc-base-url'],
|
||||
{'metavar': '<URL>', 'default': 'http://tools.ietf.org/html/',
|
||||
'validator': frontend.validate_url_trailing_slash}),
|
||||
('Set number of spaces for tab expansion (default 8).',
|
||||
['--tab-width'],
|
||||
{'metavar': '<width>', 'type': 'int', 'default': 8,
|
||||
'validator': frontend.validate_nonnegative_int}),
|
||||
('Remove spaces before footnote references.',
|
||||
['--trim-footnote-reference-space'],
|
||||
{'action': 'store_true', 'validator': frontend.validate_boolean}),
|
||||
('Leave spaces before footnote references.',
|
||||
['--leave-footnote-reference-space'],
|
||||
{'action': 'store_false', 'dest': 'trim_footnote_reference_space'}),
|
||||
('Disable directives that insert the contents of external file '
|
||||
'("include" & "raw"); replaced with a "warning" system message.',
|
||||
['--no-file-insertion'],
|
||||
{'action': 'store_false', 'default': 1,
|
||||
'dest': 'file_insertion_enabled',
|
||||
'validator': frontend.validate_boolean}),
|
||||
('Enable directives that insert the contents of external file '
|
||||
'("include" & "raw"). Enabled by default.',
|
||||
['--file-insertion-enabled'],
|
||||
{'action': 'store_true'}),
|
||||
('Disable the "raw" directives; replaced with a "warning" '
|
||||
'system message.',
|
||||
['--no-raw'],
|
||||
{'action': 'store_false', 'default': 1, 'dest': 'raw_enabled',
|
||||
'validator': frontend.validate_boolean}),
|
||||
('Enable the "raw" directive. Enabled by default.',
|
||||
['--raw-enabled'],
|
||||
{'action': 'store_true'}),
|
||||
('Token name set for parsing code with Pygments: one of '
|
||||
'"long", "short", or "none (no parsing)". Default is "long".',
|
||||
['--syntax-highlight'],
|
||||
{'choices': ['long', 'short', 'none'],
|
||||
'default': 'long', 'metavar': '<format>'}),
|
||||
('Change straight quotation marks to typographic form: '
|
||||
'one of "yes", "no", "alt[ernative]" (default "no").',
|
||||
['--smart-quotes'],
|
||||
{'default': False, 'metavar': '<yes/no/alt>',
|
||||
'validator': frontend.validate_ternary}),
|
||||
('Characters to use as "smart quotes" for <language>. ',
|
||||
['--smartquotes-locales'],
|
||||
{'metavar': '<language:quotes[,language:quotes,...]>',
|
||||
'action': 'append',
|
||||
'validator': frontend.validate_smartquotes_locales}),
|
||||
('Inline markup recognized at word boundaries only '
|
||||
'(adjacent to punctuation or whitespace). '
|
||||
'Force character-level inline markup recognition with '
|
||||
'"\\ " (backslash + space). Default.',
|
||||
['--word-level-inline-markup'],
|
||||
{'action': 'store_false', 'dest': '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.',
|
||||
['--character-level-inline-markup'],
|
||||
{'action': 'store_true', 'default': False,
|
||||
'dest': 'character_level_inline_markup'}),
|
||||
))
|
||||
|
||||
config_section = 'restructuredtext parser'
|
||||
config_section_dependencies = ('parsers',)
|
||||
|
||||
def __init__(self, rfc2822=False, inliner=None):
|
||||
if rfc2822:
|
||||
self.initial_state = 'RFC2822Body'
|
||||
else:
|
||||
self.initial_state = 'Body'
|
||||
self.state_classes = states.state_classes
|
||||
self.inliner = inliner
|
||||
|
||||
def get_transforms(self):
|
||||
return Component.get_transforms(self) + [
|
||||
universal.SmartQuotes]
|
||||
|
||||
def parse(self, inputstring, document):
|
||||
"""Parse `inputstring` and populate `document`, a document tree."""
|
||||
self.setup_parse(inputstring, document)
|
||||
self.statemachine = states.RSTStateMachine(
|
||||
state_classes=self.state_classes,
|
||||
initial_state=self.initial_state,
|
||||
debug=document.reporter.debug_flag)
|
||||
inputlines = docutils.statemachine.string2lines(
|
||||
inputstring, tab_width=document.settings.tab_width,
|
||||
convert_whitespace=True)
|
||||
self.statemachine.run(inputlines, document, inliner=self.inliner)
|
||||
# restore the "default" default role after parsing a document
|
||||
if '' in roles._roles:
|
||||
del roles._roles['']
|
||||
self.finish_parse()
|
||||
|
||||
|
||||
class DirectiveError(Exception):
|
||||
|
||||
"""
|
||||
Store a message and a system message level.
|
||||
|
||||
To be thrown from inside directive code.
|
||||
|
||||
Do not instantiate directly -- use `Directive.directive_error()`
|
||||
instead!
|
||||
"""
|
||||
|
||||
def __init__(self, level, message):
|
||||
"""Set error `message` and `level`"""
|
||||
Exception.__init__(self)
|
||||
self.level = level
|
||||
self.msg = message
|
||||
|
||||
|
||||
class Directive(object):
|
||||
|
||||
"""
|
||||
Base class for reStructuredText directives.
|
||||
|
||||
The following attributes may be set by subclasses. They are
|
||||
interpreted by the directive parser (which runs the directive
|
||||
class):
|
||||
|
||||
- `required_arguments`: The number of required arguments (default:
|
||||
0).
|
||||
|
||||
- `optional_arguments`: The number of optional arguments (default:
|
||||
0).
|
||||
|
||||
- `final_argument_whitespace`: A boolean, indicating if the final
|
||||
argument may contain whitespace (default: False).
|
||||
|
||||
- `option_spec`: A dictionary, mapping known option names to
|
||||
conversion functions such as `int` or `float` (default: {}, no
|
||||
options). Several conversion functions are defined in the
|
||||
directives/__init__.py module.
|
||||
|
||||
Option conversion functions take a single parameter, the option
|
||||
argument (a string or ``None``), validate it and/or convert it
|
||||
to the appropriate form. Conversion functions may raise
|
||||
`ValueError` and `TypeError` exceptions.
|
||||
|
||||
- `has_content`: A boolean; True if content is allowed. Client
|
||||
code must handle the case where content is required but not
|
||||
supplied (an empty content list will be supplied).
|
||||
|
||||
Arguments are normally single whitespace-separated words. The
|
||||
final argument may contain whitespace and/or newlines if
|
||||
`final_argument_whitespace` is True.
|
||||
|
||||
If the form of the arguments is more complex, specify only one
|
||||
argument (either required or optional) and set
|
||||
`final_argument_whitespace` to True; the client code must do any
|
||||
context-sensitive parsing.
|
||||
|
||||
When a directive implementation is being run, the directive class
|
||||
is instantiated, and the `run()` method is executed. During
|
||||
instantiation, the following instance variables are set:
|
||||
|
||||
- ``name`` is the directive type or name (string).
|
||||
|
||||
- ``arguments`` is the list of positional arguments (strings).
|
||||
|
||||
- ``options`` is a dictionary mapping option names (strings) to
|
||||
values (type depends on option conversion functions; see
|
||||
`option_spec` above).
|
||||
|
||||
- ``content`` is a list of strings, the directive content line by line.
|
||||
|
||||
- ``lineno`` is the absolute line number of the first line
|
||||
of the directive.
|
||||
|
||||
- ``content_offset`` is the line offset of the first line of the content from
|
||||
the beginning of the current input. Used when initiating a nested parse.
|
||||
|
||||
- ``block_text`` is a string containing the entire directive.
|
||||
|
||||
- ``state`` is the state which called the directive function.
|
||||
|
||||
- ``state_machine`` is the state machine which controls the state which called
|
||||
the directive function.
|
||||
|
||||
Directive functions return a list of nodes which will be inserted
|
||||
into the document tree at the point where the directive was
|
||||
encountered. This can be an empty list if there is nothing to
|
||||
insert.
|
||||
|
||||
For ordinary directives, the list must contain body elements or
|
||||
structural elements. Some directives are intended specifically
|
||||
for substitution definitions, and must return a list of `Text`
|
||||
nodes and/or inline elements (suitable for inline insertion, in
|
||||
place of the substitution reference). Such directives must verify
|
||||
substitution definition context, typically using code like this::
|
||||
|
||||
if not isinstance(state, states.SubstitutionDef):
|
||||
error = state_machine.reporter.error(
|
||||
'Invalid context: the "%s" directive can only be used '
|
||||
'within a substitution definition.' % (name),
|
||||
nodes.literal_block(block_text, block_text), line=lineno)
|
||||
return [error]
|
||||
"""
|
||||
|
||||
# There is a "Creating reStructuredText Directives" how-to at
|
||||
# <http://docutils.sf.net/docs/howto/rst-directives.html>. If you
|
||||
# update this docstring, please update the how-to as well.
|
||||
|
||||
required_arguments = 0
|
||||
"""Number of required directive arguments."""
|
||||
|
||||
optional_arguments = 0
|
||||
"""Number of optional arguments after the required arguments."""
|
||||
|
||||
final_argument_whitespace = False
|
||||
"""May the final argument contain whitespace?"""
|
||||
|
||||
option_spec = None
|
||||
"""Mapping of option names to validator functions."""
|
||||
|
||||
has_content = False
|
||||
"""May the directive have content?"""
|
||||
|
||||
def __init__(self, name, arguments, options, content, lineno,
|
||||
content_offset, block_text, state, state_machine):
|
||||
self.name = name
|
||||
self.arguments = arguments
|
||||
self.options = options
|
||||
self.content = content
|
||||
self.lineno = lineno
|
||||
self.content_offset = content_offset
|
||||
self.block_text = block_text
|
||||
self.state = state
|
||||
self.state_machine = state_machine
|
||||
|
||||
def run(self):
|
||||
raise NotImplementedError('Must override run() is subclass.')
|
||||
|
||||
# Directive errors:
|
||||
|
||||
def directive_error(self, level, message):
|
||||
"""
|
||||
Return a DirectiveError suitable for being thrown as an exception.
|
||||
|
||||
Call "raise self.directive_error(level, message)" from within
|
||||
a directive implementation to return one single system message
|
||||
at level `level`, which automatically gets the directive block
|
||||
and the line number added.
|
||||
|
||||
Preferably use the `debug`, `info`, `warning`, `error`, or `severe`
|
||||
wrapper methods, e.g. ``self.error(message)`` to generate an
|
||||
ERROR-level directive error.
|
||||
"""
|
||||
return DirectiveError(level, message)
|
||||
|
||||
def debug(self, message):
|
||||
return self.directive_error(0, message)
|
||||
|
||||
def info(self, message):
|
||||
return self.directive_error(1, message)
|
||||
|
||||
def warning(self, message):
|
||||
return self.directive_error(2, message)
|
||||
|
||||
def error(self, message):
|
||||
return self.directive_error(3, message)
|
||||
|
||||
def severe(self, message):
|
||||
return self.directive_error(4, message)
|
||||
|
||||
# Convenience methods:
|
||||
|
||||
def assert_has_content(self):
|
||||
"""
|
||||
Throw an ERROR-level DirectiveError if the directive doesn't
|
||||
have contents.
|
||||
"""
|
||||
if not self.content:
|
||||
raise self.error('Content block expected for the "%s" directive; '
|
||||
'none found.' % self.name)
|
||||
|
||||
def add_name(self, node):
|
||||
"""Append self.options['name'] to node['names'] if it exists.
|
||||
|
||||
Also normalize the name string and register it as explicit target.
|
||||
"""
|
||||
if 'name' in self.options:
|
||||
name = nodes.fully_normalize_name(self.options.pop('name'))
|
||||
if 'name' in node:
|
||||
del(node['name'])
|
||||
node['names'].append(name)
|
||||
self.state.document.note_explicit_target(node, node)
|
||||
|
||||
|
||||
def convert_directive_function(directive_fn):
|
||||
"""
|
||||
Define & return a directive class generated from `directive_fn`.
|
||||
|
||||
`directive_fn` uses the old-style, functional interface.
|
||||
"""
|
||||
|
||||
class FunctionalDirective(Directive):
|
||||
|
||||
option_spec = getattr(directive_fn, 'options', None)
|
||||
has_content = getattr(directive_fn, 'content', False)
|
||||
_argument_spec = getattr(directive_fn, 'arguments', (0, 0, False))
|
||||
required_arguments, optional_arguments, final_argument_whitespace \
|
||||
= _argument_spec
|
||||
|
||||
def run(self):
|
||||
return directive_fn(
|
||||
self.name, self.arguments, self.options, self.content,
|
||||
self.lineno, self.content_offset, self.block_text,
|
||||
self.state, self.state_machine)
|
||||
|
||||
# Return new-style directive.
|
||||
return FunctionalDirective
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,416 @@
|
||||
# $Id: __init__.py 8239 2018-11-21 21:46:00Z milde $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
This package contains directive implementation modules.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
import re
|
||||
import codecs
|
||||
import sys
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.utils import split_escaped_whitespace, escape2null, unescape
|
||||
from docutils.parsers.rst.languages import en as _fallback_language_module
|
||||
|
||||
|
||||
_directive_registry = {
|
||||
'attention': ('admonitions', 'Attention'),
|
||||
'caution': ('admonitions', 'Caution'),
|
||||
'code': ('body', 'CodeBlock'),
|
||||
'danger': ('admonitions', 'Danger'),
|
||||
'error': ('admonitions', 'Error'),
|
||||
'important': ('admonitions', 'Important'),
|
||||
'note': ('admonitions', 'Note'),
|
||||
'tip': ('admonitions', 'Tip'),
|
||||
'hint': ('admonitions', 'Hint'),
|
||||
'warning': ('admonitions', 'Warning'),
|
||||
'admonition': ('admonitions', 'Admonition'),
|
||||
'sidebar': ('body', 'Sidebar'),
|
||||
'topic': ('body', 'Topic'),
|
||||
'line-block': ('body', 'LineBlock'),
|
||||
'parsed-literal': ('body', 'ParsedLiteral'),
|
||||
'math': ('body', 'MathBlock'),
|
||||
'rubric': ('body', 'Rubric'),
|
||||
'epigraph': ('body', 'Epigraph'),
|
||||
'highlights': ('body', 'Highlights'),
|
||||
'pull-quote': ('body', 'PullQuote'),
|
||||
'compound': ('body', 'Compound'),
|
||||
'container': ('body', 'Container'),
|
||||
#'questions': ('body', 'question_list'),
|
||||
'table': ('tables', 'RSTTable'),
|
||||
'csv-table': ('tables', 'CSVTable'),
|
||||
'list-table': ('tables', 'ListTable'),
|
||||
'image': ('images', 'Image'),
|
||||
'figure': ('images', 'Figure'),
|
||||
'contents': ('parts', 'Contents'),
|
||||
'sectnum': ('parts', 'Sectnum'),
|
||||
'header': ('parts', 'Header'),
|
||||
'footer': ('parts', 'Footer'),
|
||||
#'footnotes': ('parts', 'footnotes'),
|
||||
#'citations': ('parts', 'citations'),
|
||||
'target-notes': ('references', 'TargetNotes'),
|
||||
'meta': ('html', 'Meta'),
|
||||
#'imagemap': ('html', 'imagemap'),
|
||||
'raw': ('misc', 'Raw'),
|
||||
'include': ('misc', 'Include'),
|
||||
'replace': ('misc', 'Replace'),
|
||||
'unicode': ('misc', 'Unicode'),
|
||||
'class': ('misc', 'Class'),
|
||||
'role': ('misc', 'Role'),
|
||||
'default-role': ('misc', 'DefaultRole'),
|
||||
'title': ('misc', 'Title'),
|
||||
'date': ('misc', 'Date'),
|
||||
'restructuredtext-test-directive': ('misc', 'TestDirective'),}
|
||||
"""Mapping of directive name to (module name, class name). The
|
||||
directive name is canonical & must be lowercase. Language-dependent
|
||||
names are defined in the ``language`` subpackage."""
|
||||
|
||||
_directives = {}
|
||||
"""Cache of imported directives."""
|
||||
|
||||
def directive(directive_name, language_module, document):
|
||||
"""
|
||||
Locate and return a directive function from its language-dependent name.
|
||||
If not found in the current language, check English. Return None if the
|
||||
named directive cannot be found.
|
||||
"""
|
||||
normname = directive_name.lower()
|
||||
messages = []
|
||||
msg_text = []
|
||||
if normname in _directives:
|
||||
return _directives[normname], messages
|
||||
canonicalname = None
|
||||
try:
|
||||
canonicalname = language_module.directives[normname]
|
||||
except AttributeError as error:
|
||||
msg_text.append('Problem retrieving directive entry from language '
|
||||
'module %r: %s.' % (language_module, error))
|
||||
except KeyError:
|
||||
msg_text.append('No directive entry for "%s" in module "%s".'
|
||||
% (directive_name, language_module.__name__))
|
||||
if not canonicalname:
|
||||
try:
|
||||
canonicalname = _fallback_language_module.directives[normname]
|
||||
msg_text.append('Using English fallback for directive "%s".'
|
||||
% directive_name)
|
||||
except KeyError:
|
||||
msg_text.append('Trying "%s" as canonical directive name.'
|
||||
% directive_name)
|
||||
# The canonical name should be an English name, but just in case:
|
||||
canonicalname = normname
|
||||
if msg_text:
|
||||
message = document.reporter.info(
|
||||
'\n'.join(msg_text), line=document.current_line)
|
||||
messages.append(message)
|
||||
try:
|
||||
modulename, classname = _directive_registry[canonicalname]
|
||||
except KeyError:
|
||||
# Error handling done by caller.
|
||||
return None, messages
|
||||
try:
|
||||
module = __import__(modulename, globals(), locals(), level=1)
|
||||
except ImportError as detail:
|
||||
messages.append(document.reporter.error(
|
||||
'Error importing directive module "%s" (directive "%s"):\n%s'
|
||||
% (modulename, directive_name, detail),
|
||||
line=document.current_line))
|
||||
return None, messages
|
||||
try:
|
||||
directive = getattr(module, classname)
|
||||
_directives[normname] = directive
|
||||
except AttributeError:
|
||||
messages.append(document.reporter.error(
|
||||
'No directive class "%s" in module "%s" (directive "%s").'
|
||||
% (classname, modulename, directive_name),
|
||||
line=document.current_line))
|
||||
return None, messages
|
||||
return directive, messages
|
||||
|
||||
def register_directive(name, directive):
|
||||
"""
|
||||
Register a nonstandard application-defined directive function.
|
||||
Language lookups are not needed for such functions.
|
||||
"""
|
||||
_directives[name] = directive
|
||||
|
||||
def flag(argument):
|
||||
"""
|
||||
Check for a valid flag option (no argument) and return ``None``.
|
||||
(Directive option conversion function.)
|
||||
|
||||
Raise ``ValueError`` if an argument is found.
|
||||
"""
|
||||
if argument and argument.strip():
|
||||
raise ValueError('no argument is allowed; "%s" supplied' % argument)
|
||||
else:
|
||||
return None
|
||||
|
||||
def unchanged_required(argument):
|
||||
"""
|
||||
Return the argument text, unchanged.
|
||||
(Directive option conversion function.)
|
||||
|
||||
Raise ``ValueError`` if no argument is found.
|
||||
"""
|
||||
if argument is None:
|
||||
raise ValueError('argument required but none supplied')
|
||||
else:
|
||||
return argument # unchanged!
|
||||
|
||||
def unchanged(argument):
|
||||
"""
|
||||
Return the argument text, unchanged.
|
||||
(Directive option conversion function.)
|
||||
|
||||
No argument implies empty string ("").
|
||||
"""
|
||||
if argument is None:
|
||||
return ''
|
||||
else:
|
||||
return argument # unchanged!
|
||||
|
||||
def path(argument):
|
||||
"""
|
||||
Return the path argument unwrapped (with newlines removed).
|
||||
(Directive option conversion function.)
|
||||
|
||||
Raise ``ValueError`` if no argument is found.
|
||||
"""
|
||||
if argument is None:
|
||||
raise ValueError('argument required but none supplied')
|
||||
else:
|
||||
path = ''.join([s.strip() for s in argument.splitlines()])
|
||||
return path
|
||||
|
||||
def uri(argument):
|
||||
"""
|
||||
Return the URI argument with unescaped whitespace removed.
|
||||
(Directive option conversion function.)
|
||||
|
||||
Raise ``ValueError`` if no argument is found.
|
||||
"""
|
||||
if argument is None:
|
||||
raise ValueError('argument required but none supplied')
|
||||
else:
|
||||
parts = split_escaped_whitespace(escape2null(argument))
|
||||
uri = ' '.join(''.join(unescape(part).split()) for part in parts)
|
||||
return uri
|
||||
|
||||
def nonnegative_int(argument):
|
||||
"""
|
||||
Check for a nonnegative integer argument; raise ``ValueError`` if not.
|
||||
(Directive option conversion function.)
|
||||
"""
|
||||
value = int(argument)
|
||||
if value < 0:
|
||||
raise ValueError('negative value; must be positive or zero')
|
||||
return value
|
||||
|
||||
def percentage(argument):
|
||||
"""
|
||||
Check for an integer percentage value with optional percent sign.
|
||||
"""
|
||||
try:
|
||||
argument = argument.rstrip(' %')
|
||||
except AttributeError:
|
||||
pass
|
||||
return nonnegative_int(argument)
|
||||
|
||||
length_units = ['em', 'ex', 'px', 'in', 'cm', 'mm', 'pt', 'pc']
|
||||
|
||||
def get_measure(argument, units):
|
||||
"""
|
||||
Check for a positive argument of one of the units and return a
|
||||
normalized string of the form "<value><unit>" (without space in
|
||||
between).
|
||||
|
||||
To be called from directive option conversion functions.
|
||||
"""
|
||||
match = re.match(r'^([0-9.]+) *(%s)$' % '|'.join(units), argument)
|
||||
try:
|
||||
float(match.group(1))
|
||||
except (AttributeError, ValueError):
|
||||
raise ValueError(
|
||||
'not a positive measure of one of the following units:\n%s'
|
||||
% ' '.join(['"%s"' % i for i in units]))
|
||||
return match.group(1) + match.group(2)
|
||||
|
||||
def length_or_unitless(argument):
|
||||
return get_measure(argument, length_units + [''])
|
||||
|
||||
def length_or_percentage_or_unitless(argument, default=''):
|
||||
"""
|
||||
Return normalized string of a length or percentage unit.
|
||||
|
||||
Add <default> if there is no unit. Raise ValueError if the argument is not
|
||||
a positive measure of one of the valid CSS units (or without unit).
|
||||
|
||||
>>> length_or_percentage_or_unitless('3 pt')
|
||||
'3pt'
|
||||
>>> length_or_percentage_or_unitless('3%', 'em')
|
||||
'3%'
|
||||
>>> length_or_percentage_or_unitless('3')
|
||||
'3'
|
||||
>>> length_or_percentage_or_unitless('3', 'px')
|
||||
'3px'
|
||||
"""
|
||||
try:
|
||||
return get_measure(argument, length_units + ['%'])
|
||||
except ValueError:
|
||||
try:
|
||||
return get_measure(argument, ['']) + default
|
||||
except ValueError:
|
||||
# raise ValueError with list of valid units:
|
||||
return get_measure(argument, length_units + ['%'])
|
||||
|
||||
def class_option(argument):
|
||||
"""
|
||||
Convert the argument into a list of ID-compatible strings and return it.
|
||||
(Directive option conversion function.)
|
||||
|
||||
Raise ``ValueError`` if no argument is found.
|
||||
"""
|
||||
if argument is None:
|
||||
raise ValueError('argument required but none supplied')
|
||||
names = argument.split()
|
||||
class_names = []
|
||||
for name in names:
|
||||
class_name = nodes.make_id(name)
|
||||
if not class_name:
|
||||
raise ValueError('cannot make "%s" into a class name' % name)
|
||||
class_names.append(class_name)
|
||||
return class_names
|
||||
|
||||
unicode_pattern = re.compile(
|
||||
r'(?:0x|x|\\x|U\+?|\\u)([0-9a-f]+)$|&#x([0-9a-f]+);$', re.IGNORECASE)
|
||||
|
||||
def unicode_code(code):
|
||||
r"""
|
||||
Convert a Unicode character code to a Unicode character.
|
||||
(Directive option conversion function.)
|
||||
|
||||
Codes may be decimal numbers, hexadecimal numbers (prefixed by ``0x``,
|
||||
``x``, ``\x``, ``U+``, ``u``, or ``\u``; e.g. ``U+262E``), or XML-style
|
||||
numeric character entities (e.g. ``☮``). Other text remains as-is.
|
||||
|
||||
Raise ValueError for illegal Unicode code values.
|
||||
"""
|
||||
try:
|
||||
if code.isdigit(): # decimal number
|
||||
return chr(int(code))
|
||||
else:
|
||||
match = unicode_pattern.match(code)
|
||||
if match: # hex number
|
||||
value = match.group(1) or match.group(2)
|
||||
return chr(int(value, 16))
|
||||
else: # other text
|
||||
return code
|
||||
except OverflowError as detail:
|
||||
raise ValueError('code too large (%s)' % detail)
|
||||
|
||||
def single_char_or_unicode(argument):
|
||||
"""
|
||||
A single character is returned as-is. Unicode characters codes are
|
||||
converted as in `unicode_code`. (Directive option conversion function.)
|
||||
"""
|
||||
char = unicode_code(argument)
|
||||
if len(char) > 1:
|
||||
raise ValueError('%r invalid; must be a single character or '
|
||||
'a Unicode code' % char)
|
||||
return char
|
||||
|
||||
def single_char_or_whitespace_or_unicode(argument):
|
||||
"""
|
||||
As with `single_char_or_unicode`, but "tab" and "space" are also supported.
|
||||
(Directive option conversion function.)
|
||||
"""
|
||||
if argument == 'tab':
|
||||
char = '\t'
|
||||
elif argument == 'space':
|
||||
char = ' '
|
||||
else:
|
||||
char = single_char_or_unicode(argument)
|
||||
return char
|
||||
|
||||
def positive_int(argument):
|
||||
"""
|
||||
Converts the argument into an integer. Raises ValueError for negative,
|
||||
zero, or non-integer values. (Directive option conversion function.)
|
||||
"""
|
||||
value = int(argument)
|
||||
if value < 1:
|
||||
raise ValueError('negative or zero value; must be positive')
|
||||
return value
|
||||
|
||||
def positive_int_list(argument):
|
||||
"""
|
||||
Converts a space- or comma-separated list of values into a Python list
|
||||
of integers.
|
||||
(Directive option conversion function.)
|
||||
|
||||
Raises ValueError for non-positive-integer values.
|
||||
"""
|
||||
if ',' in argument:
|
||||
entries = argument.split(',')
|
||||
else:
|
||||
entries = argument.split()
|
||||
return [positive_int(entry) for entry in entries]
|
||||
|
||||
def encoding(argument):
|
||||
"""
|
||||
Verfies the encoding argument by lookup.
|
||||
(Directive option conversion function.)
|
||||
|
||||
Raises ValueError for unknown encodings.
|
||||
"""
|
||||
try:
|
||||
codecs.lookup(argument)
|
||||
except LookupError:
|
||||
raise ValueError('unknown encoding: "%s"' % argument)
|
||||
return argument
|
||||
|
||||
def choice(argument, values):
|
||||
"""
|
||||
Directive option utility function, supplied to enable options whose
|
||||
argument must be a member of a finite set of possible values (must be
|
||||
lower case). A custom conversion function must be written to use it. For
|
||||
example::
|
||||
|
||||
from docutils.parsers.rst import directives
|
||||
|
||||
def yesno(argument):
|
||||
return directives.choice(argument, ('yes', 'no'))
|
||||
|
||||
Raise ``ValueError`` if no argument is found or if the argument's value is
|
||||
not valid (not an entry in the supplied list).
|
||||
"""
|
||||
try:
|
||||
value = argument.lower().strip()
|
||||
except AttributeError:
|
||||
raise ValueError('must supply an argument; choose from %s'
|
||||
% format_values(values))
|
||||
if value in values:
|
||||
return value
|
||||
else:
|
||||
raise ValueError('"%s" unknown; choose from %s'
|
||||
% (argument, format_values(values)))
|
||||
|
||||
def format_values(values):
|
||||
return '%s, or "%s"' % (', '.join(['"%s"' % s for s in values[:-1]]),
|
||||
values[-1])
|
||||
|
||||
def value_or(values, other):
|
||||
"""
|
||||
The argument can be any of `values` or `argument_type`.
|
||||
"""
|
||||
def auto_or_other(argument):
|
||||
if argument in values:
|
||||
return argument
|
||||
else:
|
||||
return other(argument)
|
||||
return auto_or_other
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,99 @@
|
||||
# $Id: admonitions.py 7681 2013-07-12 07:52:27Z milde $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
Admonition directives.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
|
||||
from docutils.parsers.rst import Directive
|
||||
from docutils.parsers.rst import states, directives
|
||||
from docutils.parsers.rst.roles import set_classes
|
||||
from docutils import nodes
|
||||
|
||||
|
||||
class BaseAdmonition(Directive):
|
||||
|
||||
final_argument_whitespace = True
|
||||
option_spec = {'class': directives.class_option,
|
||||
'name': directives.unchanged}
|
||||
has_content = True
|
||||
|
||||
node_class = None
|
||||
"""Subclasses must set this to the appropriate admonition node class."""
|
||||
|
||||
def run(self):
|
||||
set_classes(self.options)
|
||||
self.assert_has_content()
|
||||
text = '\n'.join(self.content)
|
||||
admonition_node = self.node_class(text, **self.options)
|
||||
self.add_name(admonition_node)
|
||||
if self.node_class is nodes.admonition:
|
||||
title_text = self.arguments[0]
|
||||
textnodes, messages = self.state.inline_text(title_text,
|
||||
self.lineno)
|
||||
title = nodes.title(title_text, '', *textnodes)
|
||||
title.source, title.line = (
|
||||
self.state_machine.get_source_and_line(self.lineno))
|
||||
admonition_node += title
|
||||
admonition_node += messages
|
||||
if not 'classes' in self.options:
|
||||
admonition_node['classes'] += ['admonition-' +
|
||||
nodes.make_id(title_text)]
|
||||
self.state.nested_parse(self.content, self.content_offset,
|
||||
admonition_node)
|
||||
return [admonition_node]
|
||||
|
||||
|
||||
class Admonition(BaseAdmonition):
|
||||
|
||||
required_arguments = 1
|
||||
node_class = nodes.admonition
|
||||
|
||||
|
||||
class Attention(BaseAdmonition):
|
||||
|
||||
node_class = nodes.attention
|
||||
|
||||
|
||||
class Caution(BaseAdmonition):
|
||||
|
||||
node_class = nodes.caution
|
||||
|
||||
|
||||
class Danger(BaseAdmonition):
|
||||
|
||||
node_class = nodes.danger
|
||||
|
||||
|
||||
class Error(BaseAdmonition):
|
||||
|
||||
node_class = nodes.error
|
||||
|
||||
|
||||
class Hint(BaseAdmonition):
|
||||
|
||||
node_class = nodes.hint
|
||||
|
||||
|
||||
class Important(BaseAdmonition):
|
||||
|
||||
node_class = nodes.important
|
||||
|
||||
|
||||
class Note(BaseAdmonition):
|
||||
|
||||
node_class = nodes.note
|
||||
|
||||
|
||||
class Tip(BaseAdmonition):
|
||||
|
||||
node_class = nodes.tip
|
||||
|
||||
|
||||
class Warning(BaseAdmonition):
|
||||
|
||||
node_class = nodes.warning
|
||||
@@ -0,0 +1,289 @@
|
||||
# $Id: body.py 7267 2011-12-20 14:14:21Z milde $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
Directives for additional body elements.
|
||||
|
||||
See `docutils.parsers.rst.directives` for API details.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
|
||||
import sys
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import Directive
|
||||
from docutils.parsers.rst import directives
|
||||
from docutils.parsers.rst.roles import set_classes
|
||||
from docutils.utils.code_analyzer import Lexer, LexerError, NumberLines
|
||||
|
||||
class BasePseudoSection(Directive):
|
||||
|
||||
required_arguments = 1
|
||||
optional_arguments = 0
|
||||
final_argument_whitespace = True
|
||||
option_spec = {'class': directives.class_option,
|
||||
'name': directives.unchanged}
|
||||
has_content = True
|
||||
|
||||
node_class = None
|
||||
"""Node class to be used (must be set in subclasses)."""
|
||||
|
||||
def run(self):
|
||||
if not (self.state_machine.match_titles
|
||||
or isinstance(self.state_machine.node, nodes.sidebar)):
|
||||
raise self.error('The "%s" directive may not be used within '
|
||||
'topics or body elements.' % self.name)
|
||||
self.assert_has_content()
|
||||
title_text = self.arguments[0]
|
||||
textnodes, messages = self.state.inline_text(title_text, self.lineno)
|
||||
titles = [nodes.title(title_text, '', *textnodes)]
|
||||
# Sidebar uses this code.
|
||||
if 'subtitle' in self.options:
|
||||
textnodes, more_messages = self.state.inline_text(
|
||||
self.options['subtitle'], self.lineno)
|
||||
titles.append(nodes.subtitle(self.options['subtitle'], '',
|
||||
*textnodes))
|
||||
messages.extend(more_messages)
|
||||
text = '\n'.join(self.content)
|
||||
node = self.node_class(text, *(titles + messages))
|
||||
node['classes'] += self.options.get('class', [])
|
||||
self.add_name(node)
|
||||
if text:
|
||||
self.state.nested_parse(self.content, self.content_offset, node)
|
||||
return [node]
|
||||
|
||||
|
||||
class Topic(BasePseudoSection):
|
||||
|
||||
node_class = nodes.topic
|
||||
|
||||
|
||||
class Sidebar(BasePseudoSection):
|
||||
|
||||
node_class = nodes.sidebar
|
||||
|
||||
option_spec = BasePseudoSection.option_spec.copy()
|
||||
option_spec['subtitle'] = directives.unchanged_required
|
||||
|
||||
def run(self):
|
||||
if isinstance(self.state_machine.node, nodes.sidebar):
|
||||
raise self.error('The "%s" directive may not be used within a '
|
||||
'sidebar element.' % self.name)
|
||||
return BasePseudoSection.run(self)
|
||||
|
||||
|
||||
class LineBlock(Directive):
|
||||
|
||||
option_spec = {'class': directives.class_option,
|
||||
'name': directives.unchanged}
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
self.assert_has_content()
|
||||
block = nodes.line_block(classes=self.options.get('class', []))
|
||||
self.add_name(block)
|
||||
node_list = [block]
|
||||
for line_text in self.content:
|
||||
text_nodes, messages = self.state.inline_text(
|
||||
line_text.strip(), self.lineno + self.content_offset)
|
||||
line = nodes.line(line_text, '', *text_nodes)
|
||||
if line_text.strip():
|
||||
line.indent = len(line_text) - len(line_text.lstrip())
|
||||
block += line
|
||||
node_list.extend(messages)
|
||||
self.content_offset += 1
|
||||
self.state.nest_line_block_lines(block)
|
||||
return node_list
|
||||
|
||||
|
||||
class ParsedLiteral(Directive):
|
||||
|
||||
option_spec = {'class': directives.class_option,
|
||||
'name': directives.unchanged}
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
set_classes(self.options)
|
||||
self.assert_has_content()
|
||||
text = '\n'.join(self.content)
|
||||
text_nodes, messages = self.state.inline_text(text, self.lineno)
|
||||
node = nodes.literal_block(text, '', *text_nodes, **self.options)
|
||||
node.line = self.content_offset + 1
|
||||
self.add_name(node)
|
||||
return [node] + messages
|
||||
|
||||
|
||||
class CodeBlock(Directive):
|
||||
"""Parse and mark up content of a code block.
|
||||
|
||||
Configuration setting: syntax_highlight
|
||||
Highlight Code content with Pygments?
|
||||
Possible values: ('long', 'short', 'none')
|
||||
|
||||
"""
|
||||
optional_arguments = 1
|
||||
option_spec = {'class': directives.class_option,
|
||||
'name': directives.unchanged,
|
||||
'number-lines': directives.unchanged # integer or None
|
||||
}
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
self.assert_has_content()
|
||||
if self.arguments:
|
||||
language = self.arguments[0]
|
||||
else:
|
||||
language = ''
|
||||
set_classes(self.options)
|
||||
classes = ['code']
|
||||
if language:
|
||||
classes.append(language)
|
||||
if 'classes' in self.options:
|
||||
classes.extend(self.options['classes'])
|
||||
|
||||
# set up lexical analyzer
|
||||
try:
|
||||
tokens = Lexer('\n'.join(self.content), language,
|
||||
self.state.document.settings.syntax_highlight)
|
||||
except LexerError as error:
|
||||
raise self.warning(error)
|
||||
|
||||
if 'number-lines' in self.options:
|
||||
# optional argument `startline`, defaults to 1
|
||||
try:
|
||||
startline = int(self.options['number-lines'] or 1)
|
||||
except ValueError:
|
||||
raise self.error(':number-lines: with non-integer start value')
|
||||
endline = startline + len(self.content)
|
||||
# add linenumber filter:
|
||||
tokens = NumberLines(tokens, startline, endline)
|
||||
|
||||
node = nodes.literal_block('\n'.join(self.content), classes=classes)
|
||||
self.add_name(node)
|
||||
# if called from "include", set the source
|
||||
if 'source' in self.options:
|
||||
node.attributes['source'] = self.options['source']
|
||||
# analyze content and add nodes for every token
|
||||
for classes, value in tokens:
|
||||
# print (classes, value)
|
||||
if classes:
|
||||
node += nodes.inline(value, value, classes=classes)
|
||||
else:
|
||||
# insert as Text to decrease the verbosity of the output
|
||||
node += nodes.Text(value, value)
|
||||
|
||||
return [node]
|
||||
|
||||
|
||||
class MathBlock(Directive):
|
||||
|
||||
option_spec = {'class': directives.class_option,
|
||||
'name': directives.unchanged}
|
||||
## TODO: Add Sphinx' ``mathbase.py`` option 'nowrap'?
|
||||
# 'nowrap': directives.flag,
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
set_classes(self.options)
|
||||
self.assert_has_content()
|
||||
# join lines, separate blocks
|
||||
content = '\n'.join(self.content).split('\n\n')
|
||||
_nodes = []
|
||||
for block in content:
|
||||
if not block:
|
||||
continue
|
||||
node = nodes.math_block(self.block_text, block, **self.options)
|
||||
node.line = self.content_offset + 1
|
||||
self.add_name(node)
|
||||
_nodes.append(node)
|
||||
return _nodes
|
||||
|
||||
|
||||
class Rubric(Directive):
|
||||
|
||||
required_arguments = 1
|
||||
optional_arguments = 0
|
||||
final_argument_whitespace = True
|
||||
option_spec = {'class': directives.class_option,
|
||||
'name': directives.unchanged}
|
||||
|
||||
def run(self):
|
||||
set_classes(self.options)
|
||||
rubric_text = self.arguments[0]
|
||||
textnodes, messages = self.state.inline_text(rubric_text, self.lineno)
|
||||
rubric = nodes.rubric(rubric_text, '', *textnodes, **self.options)
|
||||
self.add_name(rubric)
|
||||
return [rubric] + messages
|
||||
|
||||
|
||||
class BlockQuote(Directive):
|
||||
|
||||
has_content = True
|
||||
classes = []
|
||||
|
||||
def run(self):
|
||||
self.assert_has_content()
|
||||
elements = self.state.block_quote(self.content, self.content_offset)
|
||||
for element in elements:
|
||||
if isinstance(element, nodes.block_quote):
|
||||
element['classes'] += self.classes
|
||||
return elements
|
||||
|
||||
|
||||
class Epigraph(BlockQuote):
|
||||
|
||||
classes = ['epigraph']
|
||||
|
||||
|
||||
class Highlights(BlockQuote):
|
||||
|
||||
classes = ['highlights']
|
||||
|
||||
|
||||
class PullQuote(BlockQuote):
|
||||
|
||||
classes = ['pull-quote']
|
||||
|
||||
|
||||
class Compound(Directive):
|
||||
|
||||
option_spec = {'class': directives.class_option,
|
||||
'name': directives.unchanged}
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
self.assert_has_content()
|
||||
text = '\n'.join(self.content)
|
||||
node = nodes.compound(text)
|
||||
node['classes'] += self.options.get('class', [])
|
||||
self.add_name(node)
|
||||
self.state.nested_parse(self.content, self.content_offset, node)
|
||||
return [node]
|
||||
|
||||
|
||||
class Container(Directive):
|
||||
|
||||
optional_arguments = 1
|
||||
final_argument_whitespace = True
|
||||
option_spec = {'name': directives.unchanged}
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
self.assert_has_content()
|
||||
text = '\n'.join(self.content)
|
||||
try:
|
||||
if self.arguments:
|
||||
classes = directives.class_option(self.arguments[0])
|
||||
else:
|
||||
classes = []
|
||||
except ValueError:
|
||||
raise self.error(
|
||||
'Invalid class attribute value for "%s" directive: "%s".'
|
||||
% (self.name, self.arguments[0]))
|
||||
node = nodes.container(text)
|
||||
node['classes'].extend(classes)
|
||||
self.add_name(node)
|
||||
self.state.nested_parse(self.content, self.content_offset, node)
|
||||
return [node]
|
||||
@@ -0,0 +1,88 @@
|
||||
# $Id: html.py 8171 2017-08-17 15:58:23Z milde $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
Directives for typically HTML-specific constructs.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
import sys
|
||||
from docutils import nodes, utils
|
||||
from docutils.parsers.rst import Directive
|
||||
from docutils.parsers.rst import states
|
||||
from docutils.transforms import components
|
||||
|
||||
|
||||
class MetaBody(states.SpecializedBody):
|
||||
|
||||
class meta(nodes.Special, nodes.PreBibliographic, nodes.Element):
|
||||
"""HTML-specific "meta" element."""
|
||||
pass
|
||||
|
||||
def field_marker(self, match, context, next_state):
|
||||
"""Meta element."""
|
||||
node, blank_finish = self.parsemeta(match)
|
||||
self.parent += node
|
||||
return [], next_state, []
|
||||
|
||||
def parsemeta(self, match):
|
||||
name = self.parse_field_marker(match)
|
||||
name = utils.unescape(utils.escape2null(name))
|
||||
indented, indent, line_offset, blank_finish = \
|
||||
self.state_machine.get_first_known_indented(match.end())
|
||||
node = self.meta()
|
||||
pending = nodes.pending(components.Filter,
|
||||
{'component': 'writer',
|
||||
'format': 'html',
|
||||
'nodes': [node]})
|
||||
node['content'] = utils.unescape(utils.escape2null(
|
||||
' '.join(indented)))
|
||||
if not indented:
|
||||
line = self.state_machine.line
|
||||
msg = self.reporter.info(
|
||||
'No content for meta tag "%s".' % name,
|
||||
nodes.literal_block(line, line))
|
||||
return msg, blank_finish
|
||||
tokens = name.split()
|
||||
try:
|
||||
attname, val = utils.extract_name_value(tokens[0])[0]
|
||||
node[attname.lower()] = val
|
||||
except utils.NameValueError:
|
||||
node['name'] = tokens[0]
|
||||
for token in tokens[1:]:
|
||||
try:
|
||||
attname, val = utils.extract_name_value(token)[0]
|
||||
node[attname.lower()] = val
|
||||
except utils.NameValueError as detail:
|
||||
line = self.state_machine.line
|
||||
msg = self.reporter.error(
|
||||
'Error parsing meta tag attribute "%s": %s.'
|
||||
% (token, detail), nodes.literal_block(line, line))
|
||||
return msg, blank_finish
|
||||
self.document.note_pending(pending)
|
||||
return pending, blank_finish
|
||||
|
||||
|
||||
class Meta(Directive):
|
||||
|
||||
has_content = True
|
||||
|
||||
SMkwargs = {'state_classes': (MetaBody,)}
|
||||
|
||||
def run(self):
|
||||
self.assert_has_content()
|
||||
node = nodes.Element()
|
||||
new_line_offset, blank_finish = self.state.nested_list_parse(
|
||||
self.content, self.content_offset, node,
|
||||
initial_state='MetaBody', blank_finish=True,
|
||||
state_machine_kwargs=self.SMkwargs)
|
||||
if (new_line_offset - self.content_offset) != len(self.content):
|
||||
# incomplete parse of block?
|
||||
error = self.state_machine.reporter.error(
|
||||
'Invalid meta directive.',
|
||||
nodes.literal_block(self.block_text, self.block_text),
|
||||
line=self.lineno)
|
||||
node += error
|
||||
return node.children
|
||||
@@ -0,0 +1,164 @@
|
||||
# $Id: images.py 7753 2014-06-24 14:52:59Z milde $
|
||||
# Author: David Goodger <goodger@python.org>
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
Directives for figures and simple images.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
|
||||
import sys
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
from docutils import nodes, utils
|
||||
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
|
||||
try: # check for the Python Imaging Library
|
||||
import PIL.Image
|
||||
except ImportError:
|
||||
try: # sometimes PIL modules are put in PYTHONPATH's root
|
||||
import Image
|
||||
class PIL(object): pass # dummy wrapper
|
||||
PIL.Image = Image
|
||||
except ImportError:
|
||||
PIL = None
|
||||
|
||||
class Image(Directive):
|
||||
|
||||
align_h_values = ('left', 'center', 'right')
|
||||
align_v_values = ('top', 'middle', 'bottom')
|
||||
align_values = align_v_values + align_h_values
|
||||
|
||||
def align(argument):
|
||||
# This is not callable as self.align. We cannot make it a
|
||||
# staticmethod because we're saving an unbound method in
|
||||
# option_spec below.
|
||||
return directives.choice(argument, Image.align_values)
|
||||
|
||||
required_arguments = 1
|
||||
optional_arguments = 0
|
||||
final_argument_whitespace = True
|
||||
option_spec = {'alt': directives.unchanged,
|
||||
'height': directives.length_or_unitless,
|
||||
'width': directives.length_or_percentage_or_unitless,
|
||||
'scale': directives.percentage,
|
||||
'align': align,
|
||||
'name': directives.unchanged,
|
||||
'target': directives.unchanged_required,
|
||||
'class': directives.class_option}
|
||||
|
||||
def run(self):
|
||||
if 'align' in self.options:
|
||||
if isinstance(self.state, states.SubstitutionDef):
|
||||
# Check for align_v_values.
|
||||
if self.options['align'] not in self.align_v_values:
|
||||
raise self.error(
|
||||
'Error in "%s" directive: "%s" is not a valid value '
|
||||
'for the "align" option within a substitution '
|
||||
'definition. Valid values for "align" are: "%s".'
|
||||
% (self.name, self.options['align'],
|
||||
'", "'.join(self.align_v_values)))
|
||||
elif self.options['align'] not in self.align_h_values:
|
||||
raise self.error(
|
||||
'Error in "%s" directive: "%s" is not a valid value for '
|
||||
'the "align" option. Valid values for "align" are: "%s".'
|
||||
% (self.name, self.options['align'],
|
||||
'", "'.join(self.align_h_values)))
|
||||
messages = []
|
||||
reference = directives.uri(self.arguments[0])
|
||||
self.options['uri'] = reference
|
||||
reference_node = None
|
||||
if 'target' in self.options:
|
||||
block = states.escape2null(
|
||||
self.options['target']).splitlines()
|
||||
block = [line for line in block]
|
||||
target_type, data = self.state.parse_target(
|
||||
block, self.block_text, self.lineno)
|
||||
if target_type == 'refuri':
|
||||
reference_node = nodes.reference(refuri=data)
|
||||
elif target_type == 'refname':
|
||||
reference_node = nodes.reference(
|
||||
refname=fully_normalize_name(data),
|
||||
name=whitespace_normalize_name(data))
|
||||
reference_node.indirect_reference_name = data
|
||||
self.state.document.note_refname(reference_node)
|
||||
else: # malformed target
|
||||
messages.append(data) # data is a system message
|
||||
del self.options['target']
|
||||
set_classes(self.options)
|
||||
image_node = nodes.image(self.block_text, **self.options)
|
||||
self.add_name(image_node)
|
||||
if reference_node:
|
||||
reference_node += image_node
|
||||
return messages + [reference_node]
|
||||
else:
|
||||
return messages + [image_node]
|
||||
|
||||
|
||||
class Figure(Image):
|
||||
|
||||
def align(argument):
|
||||
return directives.choice(argument, Figure.align_h_values)
|
||||
|
||||
def figwidth_value(argument):
|
||||
if argument.lower() == 'image':
|
||||
return 'image'
|
||||
else:
|
||||
return directives.length_or_percentage_or_unitless(argument, 'px')
|
||||
|
||||
option_spec = Image.option_spec.copy()
|
||||
option_spec['figwidth'] = figwidth_value
|
||||
option_spec['figclass'] = directives.class_option
|
||||
option_spec['align'] = align
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
figwidth = self.options.pop('figwidth', None)
|
||||
figclasses = self.options.pop('figclass', None)
|
||||
align = self.options.pop('align', None)
|
||||
(image_node,) = Image.run(self)
|
||||
if isinstance(image_node, nodes.system_message):
|
||||
return [image_node]
|
||||
figure_node = nodes.figure('', image_node)
|
||||
if figwidth == 'image':
|
||||
if PIL and self.state.document.settings.file_insertion_enabled:
|
||||
imagepath = urllib.request.url2pathname(image_node['uri'])
|
||||
try:
|
||||
img = PIL.Image.open(
|
||||
imagepath.encode(sys.getfilesystemencoding()))
|
||||
except (IOError, UnicodeEncodeError):
|
||||
pass # TODO: warn?
|
||||
else:
|
||||
self.state.document.settings.record_dependencies.add(
|
||||
imagepath.replace('\\', '/'))
|
||||
figure_node['width'] = '%dpx' % img.size[0]
|
||||
del img
|
||||
elif figwidth is not None:
|
||||
figure_node['width'] = figwidth
|
||||
if figclasses:
|
||||
figure_node['classes'] += figclasses
|
||||
if align:
|
||||
figure_node['align'] = align
|
||||
if self.content:
|
||||
node = nodes.Element() # anonymous container for parsing
|
||||
self.state.nested_parse(self.content, self.content_offset, node)
|
||||
first_node = node[0]
|
||||
if isinstance(first_node, nodes.paragraph):
|
||||
caption = nodes.caption(first_node.rawsource, '',
|
||||
*first_node.children)
|
||||
caption.source = first_node.source
|
||||
caption.line = first_node.line
|
||||
figure_node += caption
|
||||
elif not (isinstance(first_node, nodes.comment)
|
||||
and len(first_node) == 0):
|
||||
error = self.state_machine.reporter.error(
|
||||
'Figure caption must be a paragraph or empty comment.',
|
||||
nodes.literal_block(self.block_text, self.block_text),
|
||||
line=self.lineno)
|
||||
return [figure_node, error]
|
||||
if len(node) > 1:
|
||||
figure_node += nodes.legend('', *node[1:])
|
||||
return [figure_node]
|
||||
@@ -0,0 +1,554 @@
|
||||
# $Id: misc.py 8257 2019-06-24 17:11:29Z milde $
|
||||
# Authors: David Goodger <goodger@python.org>; Dethe Elza
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""Miscellaneous directives."""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
import re
|
||||
import time
|
||||
from docutils import io, nodes, statemachine, utils
|
||||
from docutils.utils.error_reporting import SafeString, ErrorString
|
||||
from docutils.utils.error_reporting import locale_encoding
|
||||
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
|
||||
|
||||
class Include(Directive):
|
||||
|
||||
"""
|
||||
Include content read from a separate source file.
|
||||
|
||||
Content may be parsed by the parser, or included as a literal
|
||||
block. The encoding of the included file can be specified. Only
|
||||
a part of the given file argument may be included by specifying
|
||||
start and end line or text to match before and/or after the text
|
||||
to be used.
|
||||
"""
|
||||
|
||||
required_arguments = 1
|
||||
optional_arguments = 0
|
||||
final_argument_whitespace = True
|
||||
option_spec = {'literal': directives.flag,
|
||||
'code': directives.unchanged,
|
||||
'encoding': directives.encoding,
|
||||
'tab-width': int,
|
||||
'start-line': int,
|
||||
'end-line': int,
|
||||
'start-after': directives.unchanged_required,
|
||||
'end-before': directives.unchanged_required,
|
||||
# ignored except for 'literal' or 'code':
|
||||
'number-lines': directives.unchanged, # integer or None
|
||||
'class': directives.class_option,
|
||||
'name': directives.unchanged}
|
||||
|
||||
standard_include_path = os.path.join(os.path.dirname(states.__file__),
|
||||
'include')
|
||||
|
||||
def run(self):
|
||||
"""Include a file as part of the content of this reST file."""
|
||||
if not self.state.document.settings.file_insertion_enabled:
|
||||
raise self.warning('"%s" directive disabled.' % self.name)
|
||||
source = self.state_machine.input_lines.source(
|
||||
self.lineno - self.state_machine.input_offset - 1)
|
||||
source_dir = os.path.dirname(os.path.abspath(source))
|
||||
path = directives.path(self.arguments[0])
|
||||
if path.startswith('<') and path.endswith('>'):
|
||||
path = os.path.join(self.standard_include_path, path[1:-1])
|
||||
path = os.path.normpath(os.path.join(source_dir, path))
|
||||
path = utils.relative_path(None, path)
|
||||
path = nodes.reprunicode(path)
|
||||
encoding = self.options.get(
|
||||
'encoding', self.state.document.settings.input_encoding)
|
||||
e_handler=self.state.document.settings.input_encoding_error_handler
|
||||
tab_width = self.options.get(
|
||||
'tab-width', self.state.document.settings.tab_width)
|
||||
try:
|
||||
self.state.document.settings.record_dependencies.add(path)
|
||||
include_file = io.FileInput(source_path=path,
|
||||
encoding=encoding,
|
||||
error_handler=e_handler)
|
||||
except UnicodeEncodeError as error:
|
||||
raise self.severe('Problems with "%s" directive path:\n'
|
||||
'Cannot encode input file path "%s" '
|
||||
'(wrong locale?).' %
|
||||
(self.name, SafeString(path)))
|
||||
except IOError as error:
|
||||
raise self.severe('Problems with "%s" directive path:\n%s.' %
|
||||
(self.name, ErrorString(error)))
|
||||
startline = self.options.get('start-line', None)
|
||||
endline = self.options.get('end-line', None)
|
||||
try:
|
||||
if startline or (endline is not None):
|
||||
lines = include_file.readlines()
|
||||
rawtext = ''.join(lines[startline:endline])
|
||||
else:
|
||||
rawtext = include_file.read()
|
||||
except UnicodeError as error:
|
||||
raise self.severe('Problem with "%s" directive:\n%s' %
|
||||
(self.name, ErrorString(error)))
|
||||
# start-after/end-before: no restrictions on newlines in match-text,
|
||||
# and no restrictions on matching inside lines vs. line boundaries
|
||||
after_text = self.options.get('start-after', None)
|
||||
if after_text:
|
||||
# skip content in rawtext before *and incl.* a matching text
|
||||
after_index = rawtext.find(after_text)
|
||||
if after_index < 0:
|
||||
raise self.severe('Problem with "start-after" option of "%s" '
|
||||
'directive:\nText not found.' % self.name)
|
||||
rawtext = rawtext[after_index + len(after_text):]
|
||||
before_text = self.options.get('end-before', None)
|
||||
if before_text:
|
||||
# skip content in rawtext after *and incl.* a matching text
|
||||
before_index = rawtext.find(before_text)
|
||||
if before_index < 0:
|
||||
raise self.severe('Problem with "end-before" option of "%s" '
|
||||
'directive:\nText not found.' % self.name)
|
||||
rawtext = rawtext[:before_index]
|
||||
|
||||
include_lines = statemachine.string2lines(rawtext, tab_width,
|
||||
convert_whitespace=True)
|
||||
if 'literal' in self.options:
|
||||
# Don't convert tabs to spaces, if `tab_width` is positive.
|
||||
if tab_width >= 0:
|
||||
text = rawtext.expandtabs(tab_width)
|
||||
else:
|
||||
text = rawtext
|
||||
literal_block = nodes.literal_block(rawtext, source=path,
|
||||
classes=self.options.get('class', []))
|
||||
literal_block.line = 1
|
||||
self.add_name(literal_block)
|
||||
if 'number-lines' in self.options:
|
||||
try:
|
||||
startline = int(self.options['number-lines'] or 1)
|
||||
except ValueError:
|
||||
raise self.error(':number-lines: with non-integer '
|
||||
'start value')
|
||||
endline = startline + len(include_lines)
|
||||
if text.endswith('\n'):
|
||||
text = text[:-1]
|
||||
tokens = NumberLines([([], text)], startline, endline)
|
||||
for classes, value in tokens:
|
||||
if classes:
|
||||
literal_block += nodes.inline(value, value,
|
||||
classes=classes)
|
||||
else:
|
||||
literal_block += nodes.Text(value, value)
|
||||
else:
|
||||
literal_block += nodes.Text(text, text)
|
||||
return [literal_block]
|
||||
if 'code' in self.options:
|
||||
self.options['source'] = path
|
||||
# Don't convert tabs to spaces, if `tab_width` is negative:
|
||||
if tab_width < 0:
|
||||
include_lines = rawtext.splitlines()
|
||||
codeblock = CodeBlock(self.name,
|
||||
[self.options.pop('code')], # arguments
|
||||
self.options,
|
||||
include_lines, # content
|
||||
self.lineno,
|
||||
self.content_offset,
|
||||
self.block_text,
|
||||
self.state,
|
||||
self.state_machine)
|
||||
return codeblock.run()
|
||||
self.state_machine.insert_input(include_lines, path)
|
||||
return []
|
||||
|
||||
|
||||
class Raw(Directive):
|
||||
|
||||
"""
|
||||
Pass through content unchanged
|
||||
|
||||
Content is included in output based on type argument
|
||||
|
||||
Content may be included inline (content section of directive) or
|
||||
imported from a file or url.
|
||||
"""
|
||||
|
||||
required_arguments = 1
|
||||
optional_arguments = 0
|
||||
final_argument_whitespace = True
|
||||
option_spec = {'file': directives.path,
|
||||
'url': directives.uri,
|
||||
'encoding': directives.encoding}
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
if (not self.state.document.settings.raw_enabled
|
||||
or (not self.state.document.settings.file_insertion_enabled
|
||||
and ('file' in self.options
|
||||
or 'url' in self.options))):
|
||||
raise self.warning('"%s" directive disabled.' % self.name)
|
||||
attributes = {'format': ' '.join(self.arguments[0].lower().split())}
|
||||
encoding = self.options.get(
|
||||
'encoding', self.state.document.settings.input_encoding)
|
||||
e_handler=self.state.document.settings.input_encoding_error_handler
|
||||
if self.content:
|
||||
if 'file' in self.options or 'url' in self.options:
|
||||
raise self.error(
|
||||
'"%s" directive may not both specify an external file '
|
||||
'and have content.' % self.name)
|
||||
text = '\n'.join(self.content)
|
||||
elif 'file' in self.options:
|
||||
if 'url' in self.options:
|
||||
raise self.error(
|
||||
'The "file" and "url" options may not be simultaneously '
|
||||
'specified for the "%s" directive.' % self.name)
|
||||
source_dir = os.path.dirname(
|
||||
os.path.abspath(self.state.document.current_source))
|
||||
path = os.path.normpath(os.path.join(source_dir,
|
||||
self.options['file']))
|
||||
path = utils.relative_path(None, path)
|
||||
try:
|
||||
raw_file = io.FileInput(source_path=path,
|
||||
encoding=encoding,
|
||||
error_handler=e_handler)
|
||||
# TODO: currently, raw input files are recorded as
|
||||
# dependencies even if not used for the chosen output format.
|
||||
self.state.document.settings.record_dependencies.add(path)
|
||||
except IOError as error:
|
||||
raise self.severe('Problems with "%s" directive path:\n%s.'
|
||||
% (self.name, ErrorString(error)))
|
||||
try:
|
||||
text = raw_file.read()
|
||||
except UnicodeError as error:
|
||||
raise self.severe('Problem with "%s" directive:\n%s'
|
||||
% (self.name, ErrorString(error)))
|
||||
attributes['source'] = path
|
||||
elif 'url' in self.options:
|
||||
source = self.options['url']
|
||||
# Do not import urllib2 at the top of the module because
|
||||
# it may fail due to broken SSL dependencies, and it takes
|
||||
# about 0.15 seconds to load.
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
try:
|
||||
raw_text = urllib.request.urlopen(source).read()
|
||||
except (urllib.error.URLError, IOError, OSError) as error:
|
||||
raise self.severe('Problems with "%s" directive URL "%s":\n%s.'
|
||||
% (self.name, self.options['url'], ErrorString(error)))
|
||||
raw_file = io.StringInput(source=raw_text, source_path=source,
|
||||
encoding=encoding,
|
||||
error_handler=e_handler)
|
||||
try:
|
||||
text = raw_file.read()
|
||||
except UnicodeError as error:
|
||||
raise self.severe('Problem with "%s" directive:\n%s'
|
||||
% (self.name, ErrorString(error)))
|
||||
attributes['source'] = source
|
||||
else:
|
||||
# This will always fail because there is no content.
|
||||
self.assert_has_content()
|
||||
raw_node = nodes.raw('', text, **attributes)
|
||||
(raw_node.source,
|
||||
raw_node.line) = self.state_machine.get_source_and_line(self.lineno)
|
||||
return [raw_node]
|
||||
|
||||
|
||||
class Replace(Directive):
|
||||
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
if not isinstance(self.state, states.SubstitutionDef):
|
||||
raise self.error(
|
||||
'Invalid context: the "%s" directive can only be used within '
|
||||
'a substitution definition.' % self.name)
|
||||
self.assert_has_content()
|
||||
text = '\n'.join(self.content)
|
||||
element = nodes.Element(text)
|
||||
self.state.nested_parse(self.content, self.content_offset,
|
||||
element)
|
||||
# element might contain [paragraph] + system_message(s)
|
||||
node = None
|
||||
messages = []
|
||||
for elem in element:
|
||||
if not node and isinstance(elem, nodes.paragraph):
|
||||
node = elem
|
||||
elif isinstance(elem, nodes.system_message):
|
||||
elem['backrefs'] = []
|
||||
messages.append(elem)
|
||||
else:
|
||||
return [
|
||||
self.state_machine.reporter.error(
|
||||
'Error in "%s" directive: may contain a single paragraph '
|
||||
'only.' % (self.name), line=self.lineno) ]
|
||||
if node:
|
||||
return messages + node.children
|
||||
return messages
|
||||
|
||||
class Unicode(Directive):
|
||||
|
||||
r"""
|
||||
Convert Unicode character codes (numbers) to characters. Codes may be
|
||||
decimal numbers, hexadecimal numbers (prefixed by ``0x``, ``x``, ``\x``,
|
||||
``U+``, ``u``, or ``\u``; e.g. ``U+262E``), or XML-style numeric character
|
||||
entities (e.g. ``☮``). Text following ".." is a comment and is
|
||||
ignored. Spaces are ignored, and any other text remains as-is.
|
||||
"""
|
||||
|
||||
required_arguments = 1
|
||||
optional_arguments = 0
|
||||
final_argument_whitespace = True
|
||||
option_spec = {'trim': directives.flag,
|
||||
'ltrim': directives.flag,
|
||||
'rtrim': directives.flag}
|
||||
|
||||
comment_pattern = re.compile(r'( |\n|^)\.\. ')
|
||||
|
||||
def run(self):
|
||||
if not isinstance(self.state, states.SubstitutionDef):
|
||||
raise self.error(
|
||||
'Invalid context: the "%s" directive can only be used within '
|
||||
'a substitution definition.' % self.name)
|
||||
substitution_definition = self.state_machine.node
|
||||
if 'trim' in self.options:
|
||||
substitution_definition.attributes['ltrim'] = 1
|
||||
substitution_definition.attributes['rtrim'] = 1
|
||||
if 'ltrim' in self.options:
|
||||
substitution_definition.attributes['ltrim'] = 1
|
||||
if 'rtrim' in self.options:
|
||||
substitution_definition.attributes['rtrim'] = 1
|
||||
codes = self.comment_pattern.split(self.arguments[0])[0].split()
|
||||
element = nodes.Element()
|
||||
for code in codes:
|
||||
try:
|
||||
decoded = directives.unicode_code(code)
|
||||
except ValueError as error:
|
||||
raise self.error('Invalid character code: %s\n%s'
|
||||
% (code, ErrorString(error)))
|
||||
element += nodes.Text(utils.unescape(decoded), decoded)
|
||||
return element.children
|
||||
|
||||
|
||||
class Class(Directive):
|
||||
|
||||
"""
|
||||
Set a "class" attribute on the directive content or the next element.
|
||||
When applied to the next element, a "pending" element is inserted, and a
|
||||
transform does the work later.
|
||||
"""
|
||||
|
||||
required_arguments = 1
|
||||
optional_arguments = 0
|
||||
final_argument_whitespace = True
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
class_value = directives.class_option(self.arguments[0])
|
||||
except ValueError:
|
||||
raise self.error(
|
||||
'Invalid class attribute value for "%s" directive: "%s".'
|
||||
% (self.name, self.arguments[0]))
|
||||
node_list = []
|
||||
if self.content:
|
||||
container = nodes.Element()
|
||||
self.state.nested_parse(self.content, self.content_offset,
|
||||
container)
|
||||
for node in container:
|
||||
node['classes'].extend(class_value)
|
||||
node_list.extend(container.children)
|
||||
else:
|
||||
pending = nodes.pending(
|
||||
misc.ClassAttribute,
|
||||
{'class': class_value, 'directive': self.name},
|
||||
self.block_text)
|
||||
self.state_machine.document.note_pending(pending)
|
||||
node_list.append(pending)
|
||||
return node_list
|
||||
|
||||
|
||||
class Role(Directive):
|
||||
|
||||
has_content = True
|
||||
|
||||
argument_pattern = re.compile(r'(%s)\s*(\(\s*(%s)\s*\)\s*)?$'
|
||||
% ((states.Inliner.simplename,) * 2))
|
||||
|
||||
def run(self):
|
||||
"""Dynamically create and register a custom interpreted text role."""
|
||||
if self.content_offset > self.lineno or not self.content:
|
||||
raise self.error('"%s" directive requires arguments on the first '
|
||||
'line.' % self.name)
|
||||
args = self.content[0]
|
||||
match = self.argument_pattern.match(args)
|
||||
if not match:
|
||||
raise self.error('"%s" directive arguments not valid role names: '
|
||||
'"%s".' % (self.name, args))
|
||||
new_role_name = match.group(1)
|
||||
base_role_name = match.group(3)
|
||||
messages = []
|
||||
if base_role_name:
|
||||
base_role, messages = roles.role(
|
||||
base_role_name, self.state_machine.language, self.lineno,
|
||||
self.state.reporter)
|
||||
if base_role is None:
|
||||
error = self.state.reporter.error(
|
||||
'Unknown interpreted text role "%s".' % base_role_name,
|
||||
nodes.literal_block(self.block_text, self.block_text),
|
||||
line=self.lineno)
|
||||
return messages + [error]
|
||||
else:
|
||||
base_role = roles.generic_custom_role
|
||||
assert not hasattr(base_role, 'arguments'), (
|
||||
'Supplemental directive arguments for "%s" directive not '
|
||||
'supported (specified by "%r" role).' % (self.name, base_role))
|
||||
try:
|
||||
converted_role = convert_directive_function(base_role)
|
||||
(arguments, options, content, content_offset) = (
|
||||
self.state.parse_directive_block(
|
||||
self.content[1:], self.content_offset, converted_role,
|
||||
option_presets={}))
|
||||
except states.MarkupError as detail:
|
||||
error = self.state_machine.reporter.error(
|
||||
'Error in "%s" directive:\n%s.' % (self.name, detail),
|
||||
nodes.literal_block(self.block_text, self.block_text),
|
||||
line=self.lineno)
|
||||
return messages + [error]
|
||||
if 'class' not in options:
|
||||
try:
|
||||
options['class'] = directives.class_option(new_role_name)
|
||||
except ValueError as detail:
|
||||
error = self.state_machine.reporter.error(
|
||||
'Invalid argument for "%s" directive:\n%s.'
|
||||
% (self.name, SafeString(detail)), nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
return messages + [error]
|
||||
role = roles.CustomRole(new_role_name, base_role, options, content)
|
||||
roles.register_local_role(new_role_name, role)
|
||||
return messages
|
||||
|
||||
|
||||
class DefaultRole(Directive):
|
||||
|
||||
"""Set the default interpreted text role."""
|
||||
|
||||
optional_arguments = 1
|
||||
final_argument_whitespace = False
|
||||
|
||||
def run(self):
|
||||
if not self.arguments:
|
||||
if '' in roles._roles:
|
||||
# restore the "default" default role
|
||||
del roles._roles['']
|
||||
return []
|
||||
role_name = self.arguments[0]
|
||||
role, messages = roles.role(role_name, self.state_machine.language,
|
||||
self.lineno, self.state.reporter)
|
||||
if role is None:
|
||||
error = self.state.reporter.error(
|
||||
'Unknown interpreted text role "%s".' % role_name,
|
||||
nodes.literal_block(self.block_text, self.block_text),
|
||||
line=self.lineno)
|
||||
return messages + [error]
|
||||
roles._roles[''] = role
|
||||
return messages
|
||||
|
||||
|
||||
class Title(Directive):
|
||||
|
||||
required_arguments = 1
|
||||
optional_arguments = 0
|
||||
final_argument_whitespace = True
|
||||
|
||||
def run(self):
|
||||
self.state_machine.document['title'] = self.arguments[0]
|
||||
return []
|
||||
|
||||
|
||||
class Date(Directive):
|
||||
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
if not isinstance(self.state, states.SubstitutionDef):
|
||||
raise self.error(
|
||||
'Invalid context: the "%s" directive can only be used within '
|
||||
'a substitution definition.' % self.name)
|
||||
format_str = '\n'.join(self.content) or '%Y-%m-%d'
|
||||
if sys.version_info< (3, 0):
|
||||
try:
|
||||
format_str = format_str.encode(locale_encoding or 'utf-8')
|
||||
except UnicodeEncodeError:
|
||||
raise self.warning('Cannot encode date format string '
|
||||
'with locale encoding "%s".' % locale_encoding)
|
||||
# @@@
|
||||
# Use timestamp from the `SOURCE_DATE_EPOCH`_ environment variable?
|
||||
# Pro: Docutils-generated documentation
|
||||
# can easily be part of `reproducible software builds`__
|
||||
#
|
||||
# __ https://reproducible-builds.org/
|
||||
#
|
||||
# Con: Changes the specs, hard to predict behaviour,
|
||||
# no actual use case!
|
||||
#
|
||||
# See also the discussion about \date \time \year in TeX
|
||||
# http://tug.org/pipermail/tex-k/2016-May/002704.html
|
||||
# source_date_epoch = os.environ.get('SOURCE_DATE_EPOCH')
|
||||
# if (source_date_epoch
|
||||
# and self.state.document.settings.use_source_date_epoch):
|
||||
# text = time.strftime(format_str,
|
||||
# time.gmtime(int(source_date_epoch)))
|
||||
# else:
|
||||
text = time.strftime(format_str)
|
||||
if sys.version_info< (3, 0):
|
||||
# `text` is a byte string that may contain non-ASCII characters:
|
||||
try:
|
||||
text = text.decode(locale_encoding or 'utf-8')
|
||||
except UnicodeDecodeError:
|
||||
text = text.decode(locale_encoding or 'utf-8', 'replace')
|
||||
raise self.warning('Error decoding "%s"'
|
||||
'with locale encoding "%s".' % (text, locale_encoding))
|
||||
return [nodes.Text(text)]
|
||||
|
||||
|
||||
class TestDirective(Directive):
|
||||
|
||||
"""This directive is useful only for testing purposes."""
|
||||
|
||||
optional_arguments = 1
|
||||
final_argument_whitespace = True
|
||||
option_spec = {'option': directives.unchanged_required}
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
if self.content:
|
||||
text = '\n'.join(self.content)
|
||||
info = self.state_machine.reporter.info(
|
||||
'Directive processed. Type="%s", arguments=%r, options=%r, '
|
||||
'content:' % (self.name, self.arguments, self.options),
|
||||
nodes.literal_block(text, text), line=self.lineno)
|
||||
else:
|
||||
info = self.state_machine.reporter.info(
|
||||
'Directive processed. Type="%s", arguments=%r, options=%r, '
|
||||
'content: None' % (self.name, self.arguments, self.options),
|
||||
line=self.lineno)
|
||||
return [info]
|
||||
|
||||
# Old-style, functional definition:
|
||||
#
|
||||
# def directive_test_function(name, arguments, options, content, lineno,
|
||||
# content_offset, block_text, state, state_machine):
|
||||
# """This directive is useful only for testing purposes."""
|
||||
# if content:
|
||||
# text = '\n'.join(content)
|
||||
# info = state_machine.reporter.info(
|
||||
# 'Directive processed. Type="%s", arguments=%r, options=%r, '
|
||||
# 'content:' % (name, arguments, options),
|
||||
# nodes.literal_block(text, text), line=lineno)
|
||||
# else:
|
||||
# info = state_machine.reporter.info(
|
||||
# 'Directive processed. Type="%s", arguments=%r, options=%r, '
|
||||
# 'content: None' % (name, arguments, options), line=lineno)
|
||||
# return [info]
|
||||
#
|
||||
# directive_test_function.arguments = (0, 1, 1)
|
||||
# directive_test_function.options = {'option': directives.unchanged_required}
|
||||
# directive_test_function.content = 1
|
||||
@@ -0,0 +1,126 @@
|
||||
# $Id: parts.py 7308 2012-01-06 12:08:43Z milde $
|
||||
# Authors: David Goodger <goodger@python.org>; Dmitry Jemerov
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
Directives for document parts.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
from docutils import nodes, languages
|
||||
from docutils.transforms import parts
|
||||
from docutils.parsers.rst import Directive
|
||||
from docutils.parsers.rst import directives
|
||||
|
||||
|
||||
class Contents(Directive):
|
||||
|
||||
"""
|
||||
Table of contents.
|
||||
|
||||
The table of contents is generated in two passes: initial parse and
|
||||
transform. During the initial parse, a 'pending' element is generated
|
||||
which acts as a placeholder, storing the TOC title and any options
|
||||
internally. At a later stage in the processing, the 'pending' element is
|
||||
replaced by a 'topic' element, a title and the table of contents proper.
|
||||
"""
|
||||
|
||||
backlinks_values = ('top', 'entry', 'none')
|
||||
|
||||
def backlinks(arg):
|
||||
value = directives.choice(arg, Contents.backlinks_values)
|
||||
if value == 'none':
|
||||
return None
|
||||
else:
|
||||
return value
|
||||
|
||||
optional_arguments = 1
|
||||
final_argument_whitespace = True
|
||||
option_spec = {'depth': directives.nonnegative_int,
|
||||
'local': directives.flag,
|
||||
'backlinks': backlinks,
|
||||
'class': directives.class_option}
|
||||
|
||||
def run(self):
|
||||
if not (self.state_machine.match_titles
|
||||
or isinstance(self.state_machine.node, nodes.sidebar)):
|
||||
raise self.error('The "%s" directive may not be used within '
|
||||
'topics or body elements.' % self.name)
|
||||
document = self.state_machine.document
|
||||
language = languages.get_language(document.settings.language_code,
|
||||
document.reporter)
|
||||
if self.arguments:
|
||||
title_text = self.arguments[0]
|
||||
text_nodes, messages = self.state.inline_text(title_text,
|
||||
self.lineno)
|
||||
title = nodes.title(title_text, '', *text_nodes)
|
||||
else:
|
||||
messages = []
|
||||
if 'local' in self.options:
|
||||
title = None
|
||||
else:
|
||||
title = nodes.title('', language.labels['contents'])
|
||||
topic = nodes.topic(classes=['contents'])
|
||||
topic['classes'] += self.options.get('class', [])
|
||||
# the latex2e writer needs source and line for a warning:
|
||||
topic.source, topic.line = self.state_machine.get_source_and_line()
|
||||
topic.line -= 1
|
||||
if 'local' in self.options:
|
||||
topic['classes'].append('local')
|
||||
if title:
|
||||
name = title.astext()
|
||||
topic += title
|
||||
else:
|
||||
name = language.labels['contents']
|
||||
name = nodes.fully_normalize_name(name)
|
||||
if not document.has_name(name):
|
||||
topic['names'].append(name)
|
||||
document.note_implicit_target(topic)
|
||||
pending = nodes.pending(parts.Contents, rawsource=self.block_text)
|
||||
pending.details.update(self.options)
|
||||
document.note_pending(pending)
|
||||
topic += pending
|
||||
return [topic] + messages
|
||||
|
||||
|
||||
class Sectnum(Directive):
|
||||
|
||||
"""Automatic section numbering."""
|
||||
|
||||
option_spec = {'depth': int,
|
||||
'start': int,
|
||||
'prefix': directives.unchanged_required,
|
||||
'suffix': directives.unchanged_required}
|
||||
|
||||
def run(self):
|
||||
pending = nodes.pending(parts.SectNum)
|
||||
pending.details.update(self.options)
|
||||
self.state_machine.document.note_pending(pending)
|
||||
return [pending]
|
||||
|
||||
|
||||
class Header(Directive):
|
||||
|
||||
"""Contents of document header."""
|
||||
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
self.assert_has_content()
|
||||
header = self.state_machine.document.get_decoration().get_header()
|
||||
self.state.nested_parse(self.content, self.content_offset, header)
|
||||
return []
|
||||
|
||||
|
||||
class Footer(Directive):
|
||||
|
||||
"""Contents of document footer."""
|
||||
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
self.assert_has_content()
|
||||
footer = self.state_machine.document.get_decoration().get_footer()
|
||||
self.state.nested_parse(self.content, self.content_offset, footer)
|
||||
return []
|
||||
@@ -0,0 +1,29 @@
|
||||
# $Id: references.py 7062 2011-06-30 22:14:29Z milde $
|
||||
# Authors: David Goodger <goodger@python.org>; Dmitry Jemerov
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
Directives for references and targets.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.transforms import references
|
||||
from docutils.parsers.rst import Directive
|
||||
from docutils.parsers.rst import directives
|
||||
|
||||
|
||||
class TargetNotes(Directive):
|
||||
|
||||
"""Target footnote generation."""
|
||||
|
||||
option_spec = {'class': directives.class_option,
|
||||
'name': directives.unchanged}
|
||||
|
||||
def run(self):
|
||||
pending = nodes.pending(references.TargetNotes)
|
||||
self.add_name(pending)
|
||||
pending.details.update(self.options)
|
||||
self.state_machine.document.note_pending(pending)
|
||||
return [pending]
|
||||
@@ -0,0 +1,510 @@
|
||||
# $Id: tables.py 8187 2017-10-19 16:21:27Z milde $
|
||||
# Authors: David Goodger <goodger@python.org>; David Priest
|
||||
# Copyright: This module has been placed in the public domain.
|
||||
|
||||
"""
|
||||
Directives for table elements.
|
||||
"""
|
||||
|
||||
__docformat__ = 'reStructuredText'
|
||||
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
import csv
|
||||
|
||||
from docutils import io, nodes, statemachine, utils
|
||||
from docutils.utils.error_reporting import SafeString
|
||||
from docutils.utils import SystemMessagePropagation
|
||||
from docutils.parsers.rst import Directive
|
||||
from docutils.parsers.rst import directives
|
||||
|
||||
|
||||
def align(argument):
|
||||
return directives.choice(argument, ('left', 'center', 'right'))
|
||||
|
||||
|
||||
class Table(Directive):
|
||||
|
||||
"""
|
||||
Generic table base class.
|
||||
"""
|
||||
|
||||
optional_arguments = 1
|
||||
final_argument_whitespace = True
|
||||
option_spec = {'class': directives.class_option,
|
||||
'name': directives.unchanged,
|
||||
'align': align,
|
||||
'width': directives.length_or_percentage_or_unitless,
|
||||
'widths': directives.value_or(('auto', 'grid'),
|
||||
directives.positive_int_list)}
|
||||
has_content = True
|
||||
|
||||
def make_title(self):
|
||||
if self.arguments:
|
||||
title_text = self.arguments[0]
|
||||
text_nodes, messages = self.state.inline_text(title_text,
|
||||
self.lineno)
|
||||
title = nodes.title(title_text, '', *text_nodes)
|
||||
(title.source,
|
||||
title.line) = self.state_machine.get_source_and_line(self.lineno)
|
||||
else:
|
||||
title = None
|
||||
messages = []
|
||||
return title, messages
|
||||
|
||||
def process_header_option(self):
|
||||
source = self.state_machine.get_source(self.lineno - 1)
|
||||
table_head = []
|
||||
max_header_cols = 0
|
||||
if 'header' in self.options: # separate table header in option
|
||||
rows, max_header_cols = self.parse_csv_data_into_rows(
|
||||
self.options['header'].split('\n'), self.HeaderDialect(),
|
||||
source)
|
||||
table_head.extend(rows)
|
||||
return table_head, max_header_cols
|
||||
|
||||
def check_table_dimensions(self, rows, header_rows, stub_columns):
|
||||
if len(rows) < header_rows:
|
||||
error = self.state_machine.reporter.error(
|
||||
'%s header row(s) specified but only %s row(s) of data '
|
||||
'supplied ("%s" directive).'
|
||||
% (header_rows, len(rows), self.name), nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
raise SystemMessagePropagation(error)
|
||||
if len(rows) == header_rows > 0:
|
||||
error = self.state_machine.reporter.error(
|
||||
'Insufficient data supplied (%s row(s)); no data remaining '
|
||||
'for table body, required by "%s" directive.'
|
||||
% (len(rows), self.name), nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
raise SystemMessagePropagation(error)
|
||||
for row in rows:
|
||||
if len(row) < stub_columns:
|
||||
error = self.state_machine.reporter.error(
|
||||
'%s stub column(s) specified but only %s columns(s) of '
|
||||
'data supplied ("%s" directive).' %
|
||||
(stub_columns, len(row), self.name), nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
raise SystemMessagePropagation(error)
|
||||
if len(row) == stub_columns > 0:
|
||||
error = self.state_machine.reporter.error(
|
||||
'Insufficient data supplied (%s columns(s)); no data remaining '
|
||||
'for table body, required by "%s" directive.'
|
||||
% (len(row), self.name), nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
raise SystemMessagePropagation(error)
|
||||
|
||||
def set_table_width(self, table_node):
|
||||
if 'width' in self.options:
|
||||
table_node['width'] = self.options.get('width')
|
||||
|
||||
@property
|
||||
def widths(self):
|
||||
return self.options.get('widths', '')
|
||||
|
||||
def get_column_widths(self, max_cols):
|
||||
if type(self.widths) == list:
|
||||
if len(self.widths) != max_cols:
|
||||
error = self.state_machine.reporter.error(
|
||||
'"%s" widths do not match the number of columns in table '
|
||||
'(%s).' % (self.name, max_cols), nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
raise SystemMessagePropagation(error)
|
||||
col_widths = self.widths
|
||||
elif max_cols:
|
||||
col_widths = [100 // max_cols] * max_cols
|
||||
else:
|
||||
error = self.state_machine.reporter.error(
|
||||
'No table data detected in CSV file.', nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
raise SystemMessagePropagation(error)
|
||||
return col_widths
|
||||
|
||||
def extend_short_rows_with_empty_cells(self, columns, parts):
|
||||
for part in parts:
|
||||
for row in part:
|
||||
if len(row) < columns:
|
||||
row.extend([(0, 0, 0, [])] * (columns - len(row)))
|
||||
|
||||
|
||||
class RSTTable(Table):
|
||||
|
||||
def run(self):
|
||||
if not self.content:
|
||||
warning = self.state_machine.reporter.warning(
|
||||
'Content block expected for the "%s" directive; none found.'
|
||||
% self.name, nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
return [warning]
|
||||
title, messages = self.make_title()
|
||||
node = nodes.Element() # anonymous container for parsing
|
||||
self.state.nested_parse(self.content, self.content_offset, node)
|
||||
if len(node) != 1 or not isinstance(node[0], nodes.table):
|
||||
error = self.state_machine.reporter.error(
|
||||
'Error parsing content block for the "%s" directive: exactly '
|
||||
'one table expected.' % self.name, nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
return [error]
|
||||
table_node = node[0]
|
||||
table_node['classes'] += self.options.get('class', [])
|
||||
self.set_table_width(table_node)
|
||||
if 'align' in self.options:
|
||||
table_node['align'] = self.options.get('align')
|
||||
tgroup = table_node[0]
|
||||
if type(self.widths) == list:
|
||||
colspecs = [child for child in tgroup.children
|
||||
if child.tagname == 'colspec']
|
||||
for colspec, col_width in zip(colspecs, self.widths):
|
||||
colspec['colwidth'] = col_width
|
||||
# @@@ the colwidths argument for <tgroup> is not part of the
|
||||
# XML Exchange Table spec (https://www.oasis-open.org/specs/tm9901.htm)
|
||||
# and hence violates the docutils.dtd.
|
||||
if self.widths == 'auto':
|
||||
table_node['classes'] += ['colwidths-auto']
|
||||
elif self.widths: # "grid" or list of integers
|
||||
table_node['classes'] += ['colwidths-given']
|
||||
self.add_name(table_node)
|
||||
if title:
|
||||
table_node.insert(0, title)
|
||||
return [table_node] + messages
|
||||
|
||||
|
||||
class CSVTable(Table):
|
||||
|
||||
option_spec = {'header-rows': directives.nonnegative_int,
|
||||
'stub-columns': directives.nonnegative_int,
|
||||
'header': directives.unchanged,
|
||||
'width': directives.length_or_percentage_or_unitless,
|
||||
'widths': directives.value_or(('auto', ),
|
||||
directives.positive_int_list),
|
||||
'file': directives.path,
|
||||
'url': directives.uri,
|
||||
'encoding': directives.encoding,
|
||||
'class': directives.class_option,
|
||||
'name': directives.unchanged,
|
||||
'align': align,
|
||||
# field delimiter char
|
||||
'delim': directives.single_char_or_whitespace_or_unicode,
|
||||
# treat whitespace after delimiter as significant
|
||||
'keepspace': directives.flag,
|
||||
# text field quote/unquote char:
|
||||
'quote': directives.single_char_or_unicode,
|
||||
# char used to escape delim & quote as-needed:
|
||||
'escape': directives.single_char_or_unicode,}
|
||||
|
||||
class DocutilsDialect(csv.Dialect):
|
||||
|
||||
"""CSV dialect for `csv_table` directive."""
|
||||
|
||||
delimiter = ','
|
||||
quotechar = '"'
|
||||
doublequote = True
|
||||
skipinitialspace = True
|
||||
strict = True
|
||||
lineterminator = '\n'
|
||||
quoting = csv.QUOTE_MINIMAL
|
||||
|
||||
def __init__(self, options):
|
||||
if 'delim' in options:
|
||||
self.delimiter = CSVTable.encode_for_csv(options['delim'])
|
||||
if 'keepspace' in options:
|
||||
self.skipinitialspace = False
|
||||
if 'quote' in options:
|
||||
self.quotechar = CSVTable.encode_for_csv(options['quote'])
|
||||
if 'escape' in options:
|
||||
self.doublequote = False
|
||||
self.escapechar = CSVTable.encode_for_csv(options['escape'])
|
||||
csv.Dialect.__init__(self)
|
||||
|
||||
|
||||
class HeaderDialect(csv.Dialect):
|
||||
|
||||
"""CSV dialect to use for the "header" option data."""
|
||||
|
||||
delimiter = ','
|
||||
quotechar = '"'
|
||||
escapechar = '\\'
|
||||
doublequote = False
|
||||
skipinitialspace = True
|
||||
strict = True
|
||||
lineterminator = '\n'
|
||||
quoting = csv.QUOTE_MINIMAL
|
||||
|
||||
def check_requirements(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
if (not self.state.document.settings.file_insertion_enabled
|
||||
and ('file' in self.options
|
||||
or 'url' in self.options)):
|
||||
warning = self.state_machine.reporter.warning(
|
||||
'File and URL access deactivated; ignoring "%s" '
|
||||
'directive.' % self.name, nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
return [warning]
|
||||
self.check_requirements()
|
||||
title, messages = self.make_title()
|
||||
csv_data, source = self.get_csv_data()
|
||||
table_head, max_header_cols = self.process_header_option()
|
||||
rows, max_cols = self.parse_csv_data_into_rows(
|
||||
csv_data, self.DocutilsDialect(self.options), source)
|
||||
max_cols = max(max_cols, max_header_cols)
|
||||
header_rows = self.options.get('header-rows', 0)
|
||||
stub_columns = self.options.get('stub-columns', 0)
|
||||
self.check_table_dimensions(rows, header_rows, stub_columns)
|
||||
table_head.extend(rows[:header_rows])
|
||||
table_body = rows[header_rows:]
|
||||
col_widths = self.get_column_widths(max_cols)
|
||||
self.extend_short_rows_with_empty_cells(max_cols,
|
||||
(table_head, table_body))
|
||||
except SystemMessagePropagation as detail:
|
||||
return [detail.args[0]]
|
||||
except csv.Error as detail:
|
||||
message = str(detail)
|
||||
if sys.version_info < (3,) and '1-character string' in message:
|
||||
message += '\nwith Python 2.x this must be an ASCII character.'
|
||||
error = self.state_machine.reporter.error(
|
||||
'Error with CSV data in "%s" directive:\n%s'
|
||||
% (self.name, message), nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
return [error]
|
||||
table = (col_widths, table_head, table_body)
|
||||
table_node = self.state.build_table(table, self.content_offset,
|
||||
stub_columns, widths=self.widths)
|
||||
table_node['classes'] += self.options.get('class', [])
|
||||
if 'align' in self.options:
|
||||
table_node['align'] = self.options.get('align')
|
||||
self.set_table_width(table_node)
|
||||
self.add_name(table_node)
|
||||
if title:
|
||||
table_node.insert(0, title)
|
||||
return [table_node] + messages
|
||||
|
||||
def get_csv_data(self):
|
||||
"""
|
||||
Get CSV data from the directive content, from an external
|
||||
file, or from a URL reference.
|
||||
"""
|
||||
encoding = self.options.get(
|
||||
'encoding', self.state.document.settings.input_encoding)
|
||||
error_handler = self.state.document.settings.input_encoding_error_handler
|
||||
if self.content:
|
||||
# CSV data is from directive content.
|
||||
if 'file' in self.options or 'url' in self.options:
|
||||
error = self.state_machine.reporter.error(
|
||||
'"%s" directive may not both specify an external file and'
|
||||
' have content.' % self.name, nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
raise SystemMessagePropagation(error)
|
||||
source = self.content.source(0)
|
||||
csv_data = self.content
|
||||
elif 'file' in self.options:
|
||||
# CSV data is from an external file.
|
||||
if 'url' in self.options:
|
||||
error = self.state_machine.reporter.error(
|
||||
'The "file" and "url" options may not be simultaneously'
|
||||
' specified for the "%s" directive.' % self.name,
|
||||
nodes.literal_block(self.block_text, self.block_text),
|
||||
line=self.lineno)
|
||||
raise SystemMessagePropagation(error)
|
||||
source_dir = os.path.dirname(
|
||||
os.path.abspath(self.state.document.current_source))
|
||||
source = os.path.normpath(os.path.join(source_dir,
|
||||
self.options['file']))
|
||||
source = utils.relative_path(None, source)
|
||||
try:
|
||||
self.state.document.settings.record_dependencies.add(source)
|
||||
csv_file = io.FileInput(source_path=source,
|
||||
encoding=encoding,
|
||||
error_handler=error_handler)
|
||||
csv_data = csv_file.read().splitlines()
|
||||
except IOError as error:
|
||||
severe = self.state_machine.reporter.severe(
|
||||
'Problems with "%s" directive path:\n%s.'
|
||||
% (self.name, SafeString(error)),
|
||||
nodes.literal_block(self.block_text, self.block_text),
|
||||
line=self.lineno)
|
||||
raise SystemMessagePropagation(severe)
|
||||
elif 'url' in self.options:
|
||||
# CSV data is from a URL.
|
||||
# Do not import urllib2 at the top of the module because
|
||||
# it may fail due to broken SSL dependencies, and it takes
|
||||
# about 0.15 seconds to load.
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
source = self.options['url']
|
||||
try:
|
||||
csv_text = urllib.request.urlopen(source).read()
|
||||
except (urllib.error.URLError, IOError, OSError, ValueError) as error:
|
||||
severe = self.state_machine.reporter.severe(
|
||||
'Problems with "%s" directive URL "%s":\n%s.'
|
||||
% (self.name, self.options['url'], SafeString(error)),
|
||||
nodes.literal_block(self.block_text, self.block_text),
|
||||
line=self.lineno)
|
||||
raise SystemMessagePropagation(severe)
|
||||
csv_file = io.StringInput(
|
||||
source=csv_text, source_path=source, encoding=encoding,
|
||||
error_handler=(self.state.document.settings.\
|
||||
input_encoding_error_handler))
|
||||
csv_data = csv_file.read().splitlines()
|
||||
else:
|
||||
error = self.state_machine.reporter.warning(
|
||||
'The "%s" directive requires content; none supplied.'
|
||||
% self.name, nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
raise SystemMessagePropagation(error)
|
||||
return csv_data, source
|
||||
|
||||
if sys.version_info < (3,):
|
||||
# 2.x csv module doesn't do Unicode
|
||||
def decode_from_csv(s):
|
||||
return s.decode('utf-8')
|
||||
def encode_for_csv(s):
|
||||
return s.encode('utf-8')
|
||||
else:
|
||||
def decode_from_csv(s):
|
||||
return s
|
||||
def encode_for_csv(s):
|
||||
return s
|
||||
decode_from_csv = staticmethod(decode_from_csv)
|
||||
encode_for_csv = staticmethod(encode_for_csv)
|
||||
|
||||
def parse_csv_data_into_rows(self, csv_data, dialect, source):
|
||||
# csv.py doesn't do Unicode; encode temporarily as UTF-8
|
||||
csv_reader = csv.reader([self.encode_for_csv(line + '\n')
|
||||
for line in csv_data],
|
||||
dialect=dialect)
|
||||
rows = []
|
||||
max_cols = 0
|
||||
for row in csv_reader:
|
||||
row_data = []
|
||||
for cell in row:
|
||||
# decode UTF-8 back to Unicode
|
||||
cell_text = self.decode_from_csv(cell)
|
||||
cell_data = (0, 0, 0, statemachine.StringList(
|
||||
cell_text.splitlines(), source=source))
|
||||
row_data.append(cell_data)
|
||||
rows.append(row_data)
|
||||
max_cols = max(max_cols, len(row))
|
||||
return rows, max_cols
|
||||
|
||||
|
||||
class ListTable(Table):
|
||||
|
||||
"""
|
||||
Implement tables whose data is encoded as a uniform two-level bullet list.
|
||||
For further ideas, see
|
||||
http://docutils.sf.net/docs/dev/rst/alternatives.html#list-driven-tables
|
||||
"""
|
||||
|
||||
option_spec = {'header-rows': directives.nonnegative_int,
|
||||
'stub-columns': directives.nonnegative_int,
|
||||
'width': directives.length_or_percentage_or_unitless,
|
||||
'widths': directives.value_or(('auto', ),
|
||||
directives.positive_int_list),
|
||||
'class': directives.class_option,
|
||||
'name': directives.unchanged,
|
||||
'align': align}
|
||||
|
||||
def run(self):
|
||||
if not self.content:
|
||||
error = self.state_machine.reporter.error(
|
||||
'The "%s" directive is empty; content required.' % self.name,
|
||||
nodes.literal_block(self.block_text, self.block_text),
|
||||
line=self.lineno)
|
||||
return [error]
|
||||
title, messages = self.make_title()
|
||||
node = nodes.Element() # anonymous container for parsing
|
||||
self.state.nested_parse(self.content, self.content_offset, node)
|
||||
try:
|
||||
num_cols, col_widths = self.check_list_content(node)
|
||||
table_data = [[item.children for item in row_list[0]]
|
||||
for row_list in node[0]]
|
||||
header_rows = self.options.get('header-rows', 0)
|
||||
stub_columns = self.options.get('stub-columns', 0)
|
||||
self.check_table_dimensions(table_data, header_rows, stub_columns)
|
||||
except SystemMessagePropagation as detail:
|
||||
return [detail.args[0]]
|
||||
table_node = self.build_table_from_list(table_data, col_widths,
|
||||
header_rows, stub_columns)
|
||||
if 'align' in self.options:
|
||||
table_node['align'] = self.options.get('align')
|
||||
table_node['classes'] += self.options.get('class', [])
|
||||
self.set_table_width(table_node)
|
||||
self.add_name(table_node)
|
||||
if title:
|
||||
table_node.insert(0, title)
|
||||
return [table_node] + messages
|
||||
|
||||
def check_list_content(self, node):
|
||||
if len(node) != 1 or not isinstance(node[0], nodes.bullet_list):
|
||||
error = self.state_machine.reporter.error(
|
||||
'Error parsing content block for the "%s" directive: '
|
||||
'exactly one bullet list expected.' % self.name,
|
||||
nodes.literal_block(self.block_text, self.block_text),
|
||||
line=self.lineno)
|
||||
raise SystemMessagePropagation(error)
|
||||
list_node = node[0]
|
||||
# Check for a uniform two-level bullet list:
|
||||
for item_index in range(len(list_node)):
|
||||
item = list_node[item_index]
|
||||
if len(item) != 1 or not isinstance(item[0], nodes.bullet_list):
|
||||
error = self.state_machine.reporter.error(
|
||||
'Error parsing content block for the "%s" directive: '
|
||||
'two-level bullet list expected, but row %s does not '
|
||||
'contain a second-level bullet list.'
|
||||
% (self.name, item_index + 1), nodes.literal_block(
|
||||
self.block_text, self.block_text), line=self.lineno)
|
||||
raise SystemMessagePropagation(error)
|
||||
elif item_index:
|
||||
# ATTN pychecker users: num_cols is guaranteed to be set in the
|
||||
# "else" clause below for item_index==0, before this branch is
|
||||
# triggered.
|
||||
if len(item[0]) != num_cols:
|
||||
error = self.state_machine.reporter.error(
|
||||
'Error parsing content block for the "%s" directive: '
|
||||
'uniform two-level bullet list expected, but row %s '
|
||||
'does not contain the same number of items as row 1 '
|
||||
'(%s vs %s).'
|
||||
% (self.name, item_index + 1, len(item[0]), num_cols),
|
||||
nodes.literal_block(self.block_text, self.block_text),
|
||||
line=self.lineno)
|
||||
raise SystemMessagePropagation(error)
|
||||
else:
|
||||
num_cols = len(item[0])
|
||||
col_widths = self.get_column_widths(num_cols)
|
||||
return num_cols, col_widths
|
||||
|
||||
def build_table_from_list(self, table_data, col_widths, header_rows, stub_columns):
|
||||
table = nodes.table()
|
||||
if self.widths == 'auto':
|
||||
table['classes'] += ['colwidths-auto']
|
||||
elif self.widths: # "grid" or list of integers
|
||||
table['classes'] += ['colwidths-given']
|
||||
tgroup = nodes.tgroup(cols=len(col_widths))
|
||||
table += tgroup
|
||||
for col_width in col_widths:
|
||||
colspec = nodes.colspec()
|
||||
if col_width is not None:
|
||||
colspec.attributes['colwidth'] = col_width
|
||||
if stub_columns:
|
||||
colspec.attributes['stub'] = 1
|
||||
stub_columns -= 1
|
||||
tgroup += colspec
|
||||
rows = []
|
||||
for row in table_data:
|
||||
row_node = nodes.row()
|
||||
for cell in row:
|
||||
entry = nodes.entry()
|
||||
entry += cell
|
||||
row_node += entry
|
||||
rows.append(row_node)
|
||||
if header_rows:
|
||||
thead = nodes.thead()
|
||||
thead.extend(rows[:header_rows])
|
||||
tgroup += thead
|
||||
tbody = nodes.tbody()
|
||||
tbody.extend(rows[header_rows:])
|
||||
tgroup += tbody
|
||||
return table
|
||||
@@ -0,0 +1,17 @@
|
||||
============================================
|
||||
``docutils/parsers/rst/include`` Directory
|
||||
============================================
|
||||
|
||||
This directory contains standard data files intended for inclusion in
|
||||
reStructuredText documents. To access these files, use the "include"
|
||||
directive with the special syntax for standard "include" data files,
|
||||
angle brackets around the file name::
|
||||
|
||||
.. include:: <isonum.txt>
|
||||
|
||||
See the documentation for the `"include" directive`__ and
|
||||
`reStructuredText Standard Substitution Definition Sets`__ for
|
||||
details.
|
||||
|
||||
__ http://docutils.sf.net/docs/ref/rst/directives.html#include
|
||||
__ http://docutils.sf.net/docs/ref/rst/substitutions.html
|
||||
@@ -0,0 +1,162 @@
|
||||
.. This data file has been placed in the public domain.
|
||||
.. Derived from the Unicode character mappings available from
|
||||
<http://www.w3.org/2003/entities/xml/>.
|
||||
Processed by unicode2rstsubs.py, part of Docutils:
|
||||
<http://docutils.sourceforge.net>.
|
||||
|
||||
.. |angzarr| unicode:: U+0237C .. RIGHT ANGLE WITH DOWNWARDS ZIGZAG ARROW
|
||||
.. |cirmid| unicode:: U+02AEF .. VERTICAL LINE WITH CIRCLE ABOVE
|
||||
.. |cudarrl| unicode:: U+02938 .. RIGHT-SIDE ARC CLOCKWISE ARROW
|
||||
.. |cudarrr| unicode:: U+02935 .. ARROW POINTING RIGHTWARDS THEN CURVING DOWNWARDS
|
||||
.. |cularr| unicode:: U+021B6 .. ANTICLOCKWISE TOP SEMICIRCLE ARROW
|
||||
.. |cularrp| unicode:: U+0293D .. TOP ARC ANTICLOCKWISE ARROW WITH PLUS
|
||||
.. |curarr| unicode:: U+021B7 .. CLOCKWISE TOP SEMICIRCLE ARROW
|
||||
.. |curarrm| unicode:: U+0293C .. TOP ARC CLOCKWISE ARROW WITH MINUS
|
||||
.. |Darr| unicode:: U+021A1 .. DOWNWARDS TWO HEADED ARROW
|
||||
.. |dArr| unicode:: U+021D3 .. DOWNWARDS DOUBLE ARROW
|
||||
.. |darr2| unicode:: U+021CA .. DOWNWARDS PAIRED ARROWS
|
||||
.. |ddarr| unicode:: U+021CA .. DOWNWARDS PAIRED ARROWS
|
||||
.. |DDotrahd| unicode:: U+02911 .. RIGHTWARDS ARROW WITH DOTTED STEM
|
||||
.. |dfisht| unicode:: U+0297F .. DOWN FISH TAIL
|
||||
.. |dHar| unicode:: U+02965 .. DOWNWARDS HARPOON WITH BARB LEFT BESIDE DOWNWARDS HARPOON WITH BARB RIGHT
|
||||
.. |dharl| unicode:: U+021C3 .. DOWNWARDS HARPOON WITH BARB LEFTWARDS
|
||||
.. |dharr| unicode:: U+021C2 .. DOWNWARDS HARPOON WITH BARB RIGHTWARDS
|
||||
.. |dlarr| unicode:: U+02199 .. SOUTH WEST ARROW
|
||||
.. |drarr| unicode:: U+02198 .. SOUTH EAST ARROW
|
||||
.. |duarr| unicode:: U+021F5 .. DOWNWARDS ARROW LEFTWARDS OF UPWARDS ARROW
|
||||
.. |duhar| unicode:: U+0296F .. DOWNWARDS HARPOON WITH BARB LEFT BESIDE UPWARDS HARPOON WITH BARB RIGHT
|
||||
.. |dzigrarr| unicode:: U+027FF .. LONG RIGHTWARDS SQUIGGLE ARROW
|
||||
.. |erarr| unicode:: U+02971 .. EQUALS SIGN ABOVE RIGHTWARDS ARROW
|
||||
.. |hArr| unicode:: U+021D4 .. LEFT RIGHT DOUBLE ARROW
|
||||
.. |harr| unicode:: U+02194 .. LEFT RIGHT ARROW
|
||||
.. |harrcir| unicode:: U+02948 .. LEFT RIGHT ARROW THROUGH SMALL CIRCLE
|
||||
.. |harrw| unicode:: U+021AD .. LEFT RIGHT WAVE ARROW
|
||||
.. |hoarr| unicode:: U+021FF .. LEFT RIGHT OPEN-HEADED ARROW
|
||||
.. |imof| unicode:: U+022B7 .. IMAGE OF
|
||||
.. |lAarr| unicode:: U+021DA .. LEFTWARDS TRIPLE ARROW
|
||||
.. |Larr| unicode:: U+0219E .. LEFTWARDS TWO HEADED ARROW
|
||||
.. |larr2| unicode:: U+021C7 .. LEFTWARDS PAIRED ARROWS
|
||||
.. |larrbfs| unicode:: U+0291F .. LEFTWARDS ARROW FROM BAR TO BLACK DIAMOND
|
||||
.. |larrfs| unicode:: U+0291D .. LEFTWARDS ARROW TO BLACK DIAMOND
|
||||
.. |larrhk| unicode:: U+021A9 .. LEFTWARDS ARROW WITH HOOK
|
||||
.. |larrlp| unicode:: U+021AB .. LEFTWARDS ARROW WITH LOOP
|
||||
.. |larrpl| unicode:: U+02939 .. LEFT-SIDE ARC ANTICLOCKWISE ARROW
|
||||
.. |larrsim| unicode:: U+02973 .. LEFTWARDS ARROW ABOVE TILDE OPERATOR
|
||||
.. |larrtl| unicode:: U+021A2 .. LEFTWARDS ARROW WITH TAIL
|
||||
.. |lAtail| unicode:: U+0291B .. LEFTWARDS DOUBLE ARROW-TAIL
|
||||
.. |latail| unicode:: U+02919 .. LEFTWARDS ARROW-TAIL
|
||||
.. |lBarr| unicode:: U+0290E .. LEFTWARDS TRIPLE DASH ARROW
|
||||
.. |lbarr| unicode:: U+0290C .. LEFTWARDS DOUBLE DASH ARROW
|
||||
.. |ldca| unicode:: U+02936 .. ARROW POINTING DOWNWARDS THEN CURVING LEFTWARDS
|
||||
.. |ldrdhar| unicode:: U+02967 .. LEFTWARDS HARPOON WITH BARB DOWN ABOVE RIGHTWARDS HARPOON WITH BARB DOWN
|
||||
.. |ldrushar| unicode:: U+0294B .. LEFT BARB DOWN RIGHT BARB UP HARPOON
|
||||
.. |ldsh| unicode:: U+021B2 .. DOWNWARDS ARROW WITH TIP LEFTWARDS
|
||||
.. |lfisht| unicode:: U+0297C .. LEFT FISH TAIL
|
||||
.. |lHar| unicode:: U+02962 .. LEFTWARDS HARPOON WITH BARB UP ABOVE LEFTWARDS HARPOON WITH BARB DOWN
|
||||
.. |lhard| unicode:: U+021BD .. LEFTWARDS HARPOON WITH BARB DOWNWARDS
|
||||
.. |lharu| unicode:: U+021BC .. LEFTWARDS HARPOON WITH BARB UPWARDS
|
||||
.. |lharul| unicode:: U+0296A .. LEFTWARDS HARPOON WITH BARB UP ABOVE LONG DASH
|
||||
.. |llarr| unicode:: U+021C7 .. LEFTWARDS PAIRED ARROWS
|
||||
.. |llhard| unicode:: U+0296B .. LEFTWARDS HARPOON WITH BARB DOWN BELOW LONG DASH
|
||||
.. |loarr| unicode:: U+021FD .. LEFTWARDS OPEN-HEADED ARROW
|
||||
.. |lrarr| unicode:: U+021C6 .. LEFTWARDS ARROW OVER RIGHTWARDS ARROW
|
||||
.. |lrarr2| unicode:: U+021C6 .. LEFTWARDS ARROW OVER RIGHTWARDS ARROW
|
||||
.. |lrhar| unicode:: U+021CB .. LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON
|
||||
.. |lrhar2| unicode:: U+021CB .. LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON
|
||||
.. |lrhard| unicode:: U+0296D .. RIGHTWARDS HARPOON WITH BARB DOWN BELOW LONG DASH
|
||||
.. |lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS
|
||||
.. |lurdshar| unicode:: U+0294A .. LEFT BARB UP RIGHT BARB DOWN HARPOON
|
||||
.. |luruhar| unicode:: U+02966 .. LEFTWARDS HARPOON WITH BARB UP ABOVE RIGHTWARDS HARPOON WITH BARB UP
|
||||
.. |Map| unicode:: U+02905 .. RIGHTWARDS TWO-HEADED ARROW FROM BAR
|
||||
.. |map| unicode:: U+021A6 .. RIGHTWARDS ARROW FROM BAR
|
||||
.. |midcir| unicode:: U+02AF0 .. VERTICAL LINE WITH CIRCLE BELOW
|
||||
.. |mumap| unicode:: U+022B8 .. MULTIMAP
|
||||
.. |nearhk| unicode:: U+02924 .. NORTH EAST ARROW WITH HOOK
|
||||
.. |neArr| unicode:: U+021D7 .. NORTH EAST DOUBLE ARROW
|
||||
.. |nearr| unicode:: U+02197 .. NORTH EAST ARROW
|
||||
.. |nesear| unicode:: U+02928 .. NORTH EAST ARROW AND SOUTH EAST ARROW
|
||||
.. |nhArr| unicode:: U+021CE .. LEFT RIGHT DOUBLE ARROW WITH STROKE
|
||||
.. |nharr| unicode:: U+021AE .. LEFT RIGHT ARROW WITH STROKE
|
||||
.. |nlArr| unicode:: U+021CD .. LEFTWARDS DOUBLE ARROW WITH STROKE
|
||||
.. |nlarr| unicode:: U+0219A .. LEFTWARDS ARROW WITH STROKE
|
||||
.. |nrArr| unicode:: U+021CF .. RIGHTWARDS DOUBLE ARROW WITH STROKE
|
||||
.. |nrarr| unicode:: U+0219B .. RIGHTWARDS ARROW WITH STROKE
|
||||
.. |nrarrc| unicode:: U+02933 U+00338 .. WAVE ARROW POINTING DIRECTLY RIGHT with slash
|
||||
.. |nrarrw| unicode:: U+0219D U+00338 .. RIGHTWARDS WAVE ARROW with slash
|
||||
.. |nvHarr| unicode:: U+02904 .. LEFT RIGHT DOUBLE ARROW WITH VERTICAL STROKE
|
||||
.. |nvlArr| unicode:: U+02902 .. LEFTWARDS DOUBLE ARROW WITH VERTICAL STROKE
|
||||
.. |nvrArr| unicode:: U+02903 .. RIGHTWARDS DOUBLE ARROW WITH VERTICAL STROKE
|
||||
.. |nwarhk| unicode:: U+02923 .. NORTH WEST ARROW WITH HOOK
|
||||
.. |nwArr| unicode:: U+021D6 .. NORTH WEST DOUBLE ARROW
|
||||
.. |nwarr| unicode:: U+02196 .. NORTH WEST ARROW
|
||||
.. |nwnear| unicode:: U+02927 .. NORTH WEST ARROW AND NORTH EAST ARROW
|
||||
.. |olarr| unicode:: U+021BA .. ANTICLOCKWISE OPEN CIRCLE ARROW
|
||||
.. |orarr| unicode:: U+021BB .. CLOCKWISE OPEN CIRCLE ARROW
|
||||
.. |origof| unicode:: U+022B6 .. ORIGINAL OF
|
||||
.. |rAarr| unicode:: U+021DB .. RIGHTWARDS TRIPLE ARROW
|
||||
.. |Rarr| unicode:: U+021A0 .. RIGHTWARDS TWO HEADED ARROW
|
||||
.. |rarr2| unicode:: U+021C9 .. RIGHTWARDS PAIRED ARROWS
|
||||
.. |rarrap| unicode:: U+02975 .. RIGHTWARDS ARROW ABOVE ALMOST EQUAL TO
|
||||
.. |rarrbfs| unicode:: U+02920 .. RIGHTWARDS ARROW FROM BAR TO BLACK DIAMOND
|
||||
.. |rarrc| unicode:: U+02933 .. WAVE ARROW POINTING DIRECTLY RIGHT
|
||||
.. |rarrfs| unicode:: U+0291E .. RIGHTWARDS ARROW TO BLACK DIAMOND
|
||||
.. |rarrhk| unicode:: U+021AA .. RIGHTWARDS ARROW WITH HOOK
|
||||
.. |rarrlp| unicode:: U+021AC .. RIGHTWARDS ARROW WITH LOOP
|
||||
.. |rarrpl| unicode:: U+02945 .. RIGHTWARDS ARROW WITH PLUS BELOW
|
||||
.. |rarrsim| unicode:: U+02974 .. RIGHTWARDS ARROW ABOVE TILDE OPERATOR
|
||||
.. |Rarrtl| unicode:: U+02916 .. RIGHTWARDS TWO-HEADED ARROW WITH TAIL
|
||||
.. |rarrtl| unicode:: U+021A3 .. RIGHTWARDS ARROW WITH TAIL
|
||||
.. |rarrw| unicode:: U+0219D .. RIGHTWARDS WAVE ARROW
|
||||
.. |rAtail| unicode:: U+0291C .. RIGHTWARDS DOUBLE ARROW-TAIL
|
||||
.. |ratail| unicode:: U+0291A .. RIGHTWARDS ARROW-TAIL
|
||||
.. |RBarr| unicode:: U+02910 .. RIGHTWARDS TWO-HEADED TRIPLE DASH ARROW
|
||||
.. |rBarr| unicode:: U+0290F .. RIGHTWARDS TRIPLE DASH ARROW
|
||||
.. |rbarr| unicode:: U+0290D .. RIGHTWARDS DOUBLE DASH ARROW
|
||||
.. |rdca| unicode:: U+02937 .. ARROW POINTING DOWNWARDS THEN CURVING RIGHTWARDS
|
||||
.. |rdldhar| unicode:: U+02969 .. RIGHTWARDS HARPOON WITH BARB DOWN ABOVE LEFTWARDS HARPOON WITH BARB DOWN
|
||||
.. |rdsh| unicode:: U+021B3 .. DOWNWARDS ARROW WITH TIP RIGHTWARDS
|
||||
.. |rfisht| unicode:: U+0297D .. RIGHT FISH TAIL
|
||||
.. |rHar| unicode:: U+02964 .. RIGHTWARDS HARPOON WITH BARB UP ABOVE RIGHTWARDS HARPOON WITH BARB DOWN
|
||||
.. |rhard| unicode:: U+021C1 .. RIGHTWARDS HARPOON WITH BARB DOWNWARDS
|
||||
.. |rharu| unicode:: U+021C0 .. RIGHTWARDS HARPOON WITH BARB UPWARDS
|
||||
.. |rharul| unicode:: U+0296C .. RIGHTWARDS HARPOON WITH BARB UP ABOVE LONG DASH
|
||||
.. |rlarr| unicode:: U+021C4 .. RIGHTWARDS ARROW OVER LEFTWARDS ARROW
|
||||
.. |rlarr2| unicode:: U+021C4 .. RIGHTWARDS ARROW OVER LEFTWARDS ARROW
|
||||
.. |rlhar| unicode:: U+021CC .. RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON
|
||||
.. |rlhar2| unicode:: U+021CC .. RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON
|
||||
.. |roarr| unicode:: U+021FE .. RIGHTWARDS OPEN-HEADED ARROW
|
||||
.. |rrarr| unicode:: U+021C9 .. RIGHTWARDS PAIRED ARROWS
|
||||
.. |rsh| unicode:: U+021B1 .. UPWARDS ARROW WITH TIP RIGHTWARDS
|
||||
.. |ruluhar| unicode:: U+02968 .. RIGHTWARDS HARPOON WITH BARB UP ABOVE LEFTWARDS HARPOON WITH BARB UP
|
||||
.. |searhk| unicode:: U+02925 .. SOUTH EAST ARROW WITH HOOK
|
||||
.. |seArr| unicode:: U+021D8 .. SOUTH EAST DOUBLE ARROW
|
||||
.. |searr| unicode:: U+02198 .. SOUTH EAST ARROW
|
||||
.. |seswar| unicode:: U+02929 .. SOUTH EAST ARROW AND SOUTH WEST ARROW
|
||||
.. |simrarr| unicode:: U+02972 .. TILDE OPERATOR ABOVE RIGHTWARDS ARROW
|
||||
.. |slarr| unicode:: U+02190 .. LEFTWARDS ARROW
|
||||
.. |srarr| unicode:: U+02192 .. RIGHTWARDS ARROW
|
||||
.. |swarhk| unicode:: U+02926 .. SOUTH WEST ARROW WITH HOOK
|
||||
.. |swArr| unicode:: U+021D9 .. SOUTH WEST DOUBLE ARROW
|
||||
.. |swarr| unicode:: U+02199 .. SOUTH WEST ARROW
|
||||
.. |swnwar| unicode:: U+0292A .. SOUTH WEST ARROW AND NORTH WEST ARROW
|
||||
.. |Uarr| unicode:: U+0219F .. UPWARDS TWO HEADED ARROW
|
||||
.. |uArr| unicode:: U+021D1 .. UPWARDS DOUBLE ARROW
|
||||
.. |uarr2| unicode:: U+021C8 .. UPWARDS PAIRED ARROWS
|
||||
.. |Uarrocir| unicode:: U+02949 .. UPWARDS TWO-HEADED ARROW FROM SMALL CIRCLE
|
||||
.. |udarr| unicode:: U+021C5 .. UPWARDS ARROW LEFTWARDS OF DOWNWARDS ARROW
|
||||
.. |udhar| unicode:: U+0296E .. UPWARDS HARPOON WITH BARB LEFT BESIDE DOWNWARDS HARPOON WITH BARB RIGHT
|
||||
.. |ufisht| unicode:: U+0297E .. UP FISH TAIL
|
||||
.. |uHar| unicode:: U+02963 .. UPWARDS HARPOON WITH BARB LEFT BESIDE UPWARDS HARPOON WITH BARB RIGHT
|
||||
.. |uharl| unicode:: U+021BF .. UPWARDS HARPOON WITH BARB LEFTWARDS
|
||||
.. |uharr| unicode:: U+021BE .. UPWARDS HARPOON WITH BARB RIGHTWARDS
|
||||
.. |uuarr| unicode:: U+021C8 .. UPWARDS PAIRED ARROWS
|
||||
.. |vArr| unicode:: U+021D5 .. UP DOWN DOUBLE ARROW
|
||||
.. |varr| unicode:: U+02195 .. UP DOWN ARROW
|
||||
.. |xhArr| unicode:: U+027FA .. LONG LEFT RIGHT DOUBLE ARROW
|
||||
.. |xharr| unicode:: U+027F7 .. LONG LEFT RIGHT ARROW
|
||||
.. |xlArr| unicode:: U+027F8 .. LONG LEFTWARDS DOUBLE ARROW
|
||||
.. |xlarr| unicode:: U+027F5 .. LONG LEFTWARDS ARROW
|
||||
.. |xmap| unicode:: U+027FC .. LONG RIGHTWARDS ARROW FROM BAR
|
||||
.. |xrArr| unicode:: U+027F9 .. LONG RIGHTWARDS DOUBLE ARROW
|
||||
.. |xrarr| unicode:: U+027F6 .. LONG RIGHTWARDS ARROW
|
||||
.. |zigrarr| unicode:: U+021DD .. RIGHTWARDS SQUIGGLE ARROW
|
||||
@@ -0,0 +1,126 @@
|
||||
.. This data file has been placed in the public domain.
|
||||
.. Derived from the Unicode character mappings available from
|
||||
<http://www.w3.org/2003/entities/xml/>.
|
||||
Processed by unicode2rstsubs.py, part of Docutils:
|
||||
<http://docutils.sourceforge.net>.
|
||||
|
||||
.. |ac| unicode:: U+0223E .. INVERTED LAZY S
|
||||
.. |acE| unicode:: U+0223E U+00333 .. INVERTED LAZY S with double underline
|
||||
.. |amalg| unicode:: U+02A3F .. AMALGAMATION OR COPRODUCT
|
||||
.. |barvee| unicode:: U+022BD .. NOR
|
||||
.. |Barwed| unicode:: U+02306 .. PERSPECTIVE
|
||||
.. |barwed| unicode:: U+02305 .. PROJECTIVE
|
||||
.. |bsolb| unicode:: U+029C5 .. SQUARED FALLING DIAGONAL SLASH
|
||||
.. |Cap| unicode:: U+022D2 .. DOUBLE INTERSECTION
|
||||
.. |capand| unicode:: U+02A44 .. INTERSECTION WITH LOGICAL AND
|
||||
.. |capbrcup| unicode:: U+02A49 .. INTERSECTION ABOVE BAR ABOVE UNION
|
||||
.. |capcap| unicode:: U+02A4B .. INTERSECTION BESIDE AND JOINED WITH INTERSECTION
|
||||
.. |capcup| unicode:: U+02A47 .. INTERSECTION ABOVE UNION
|
||||
.. |capdot| unicode:: U+02A40 .. INTERSECTION WITH DOT
|
||||
.. |caps| unicode:: U+02229 U+0FE00 .. INTERSECTION with serifs
|
||||
.. |ccaps| unicode:: U+02A4D .. CLOSED INTERSECTION WITH SERIFS
|
||||
.. |ccups| unicode:: U+02A4C .. CLOSED UNION WITH SERIFS
|
||||
.. |ccupssm| unicode:: U+02A50 .. CLOSED UNION WITH SERIFS AND SMASH PRODUCT
|
||||
.. |coprod| unicode:: U+02210 .. N-ARY COPRODUCT
|
||||
.. |Cup| unicode:: U+022D3 .. DOUBLE UNION
|
||||
.. |cupbrcap| unicode:: U+02A48 .. UNION ABOVE BAR ABOVE INTERSECTION
|
||||
.. |cupcap| unicode:: U+02A46 .. UNION ABOVE INTERSECTION
|
||||
.. |cupcup| unicode:: U+02A4A .. UNION BESIDE AND JOINED WITH UNION
|
||||
.. |cupdot| unicode:: U+0228D .. MULTISET MULTIPLICATION
|
||||
.. |cupor| unicode:: U+02A45 .. UNION WITH LOGICAL OR
|
||||
.. |cups| unicode:: U+0222A U+0FE00 .. UNION with serifs
|
||||
.. |cuvee| unicode:: U+022CE .. CURLY LOGICAL OR
|
||||
.. |cuwed| unicode:: U+022CF .. CURLY LOGICAL AND
|
||||
.. |Dagger| unicode:: U+02021 .. DOUBLE DAGGER
|
||||
.. |dagger| unicode:: U+02020 .. DAGGER
|
||||
.. |diam| unicode:: U+022C4 .. DIAMOND OPERATOR
|
||||
.. |divonx| unicode:: U+022C7 .. DIVISION TIMES
|
||||
.. |eplus| unicode:: U+02A71 .. EQUALS SIGN ABOVE PLUS SIGN
|
||||
.. |hercon| unicode:: U+022B9 .. HERMITIAN CONJUGATE MATRIX
|
||||
.. |intcal| unicode:: U+022BA .. INTERCALATE
|
||||
.. |iprod| unicode:: U+02A3C .. INTERIOR PRODUCT
|
||||
.. |loplus| unicode:: U+02A2D .. PLUS SIGN IN LEFT HALF CIRCLE
|
||||
.. |lotimes| unicode:: U+02A34 .. MULTIPLICATION SIGN IN LEFT HALF CIRCLE
|
||||
.. |lthree| unicode:: U+022CB .. LEFT SEMIDIRECT PRODUCT
|
||||
.. |ltimes| unicode:: U+022C9 .. LEFT NORMAL FACTOR SEMIDIRECT PRODUCT
|
||||
.. |midast| unicode:: U+0002A .. ASTERISK
|
||||
.. |minusb| unicode:: U+0229F .. SQUARED MINUS
|
||||
.. |minusd| unicode:: U+02238 .. DOT MINUS
|
||||
.. |minusdu| unicode:: U+02A2A .. MINUS SIGN WITH DOT BELOW
|
||||
.. |ncap| unicode:: U+02A43 .. INTERSECTION WITH OVERBAR
|
||||
.. |ncup| unicode:: U+02A42 .. UNION WITH OVERBAR
|
||||
.. |oast| unicode:: U+0229B .. CIRCLED ASTERISK OPERATOR
|
||||
.. |ocir| unicode:: U+0229A .. CIRCLED RING OPERATOR
|
||||
.. |odash| unicode:: U+0229D .. CIRCLED DASH
|
||||
.. |odiv| unicode:: U+02A38 .. CIRCLED DIVISION SIGN
|
||||
.. |odot| unicode:: U+02299 .. CIRCLED DOT OPERATOR
|
||||
.. |odsold| unicode:: U+029BC .. CIRCLED ANTICLOCKWISE-ROTATED DIVISION SIGN
|
||||
.. |ofcir| unicode:: U+029BF .. CIRCLED BULLET
|
||||
.. |ogt| unicode:: U+029C1 .. CIRCLED GREATER-THAN
|
||||
.. |ohbar| unicode:: U+029B5 .. CIRCLE WITH HORIZONTAL BAR
|
||||
.. |olcir| unicode:: U+029BE .. CIRCLED WHITE BULLET
|
||||
.. |olt| unicode:: U+029C0 .. CIRCLED LESS-THAN
|
||||
.. |omid| unicode:: U+029B6 .. CIRCLED VERTICAL BAR
|
||||
.. |ominus| unicode:: U+02296 .. CIRCLED MINUS
|
||||
.. |opar| unicode:: U+029B7 .. CIRCLED PARALLEL
|
||||
.. |operp| unicode:: U+029B9 .. CIRCLED PERPENDICULAR
|
||||
.. |oplus| unicode:: U+02295 .. CIRCLED PLUS
|
||||
.. |osol| unicode:: U+02298 .. CIRCLED DIVISION SLASH
|
||||
.. |Otimes| unicode:: U+02A37 .. MULTIPLICATION SIGN IN DOUBLE CIRCLE
|
||||
.. |otimes| unicode:: U+02297 .. CIRCLED TIMES
|
||||
.. |otimesas| unicode:: U+02A36 .. CIRCLED MULTIPLICATION SIGN WITH CIRCUMFLEX ACCENT
|
||||
.. |ovbar| unicode:: U+0233D .. APL FUNCTIONAL SYMBOL CIRCLE STILE
|
||||
.. |plusacir| unicode:: U+02A23 .. PLUS SIGN WITH CIRCUMFLEX ACCENT ABOVE
|
||||
.. |plusb| unicode:: U+0229E .. SQUARED PLUS
|
||||
.. |pluscir| unicode:: U+02A22 .. PLUS SIGN WITH SMALL CIRCLE ABOVE
|
||||
.. |plusdo| unicode:: U+02214 .. DOT PLUS
|
||||
.. |plusdu| unicode:: U+02A25 .. PLUS SIGN WITH DOT BELOW
|
||||
.. |pluse| unicode:: U+02A72 .. PLUS SIGN ABOVE EQUALS SIGN
|
||||
.. |plussim| unicode:: U+02A26 .. PLUS SIGN WITH TILDE BELOW
|
||||
.. |plustwo| unicode:: U+02A27 .. PLUS SIGN WITH SUBSCRIPT TWO
|
||||
.. |prod| unicode:: U+0220F .. N-ARY PRODUCT
|
||||
.. |race| unicode:: U+029DA .. LEFT DOUBLE WIGGLY FENCE
|
||||
.. |roplus| unicode:: U+02A2E .. PLUS SIGN IN RIGHT HALF CIRCLE
|
||||
.. |rotimes| unicode:: U+02A35 .. MULTIPLICATION SIGN IN RIGHT HALF CIRCLE
|
||||
.. |rthree| unicode:: U+022CC .. RIGHT SEMIDIRECT PRODUCT
|
||||
.. |rtimes| unicode:: U+022CA .. RIGHT NORMAL FACTOR SEMIDIRECT PRODUCT
|
||||
.. |sdot| unicode:: U+022C5 .. DOT OPERATOR
|
||||
.. |sdotb| unicode:: U+022A1 .. SQUARED DOT OPERATOR
|
||||
.. |setmn| unicode:: U+02216 .. SET MINUS
|
||||
.. |simplus| unicode:: U+02A24 .. PLUS SIGN WITH TILDE ABOVE
|
||||
.. |smashp| unicode:: U+02A33 .. SMASH PRODUCT
|
||||
.. |solb| unicode:: U+029C4 .. SQUARED RISING DIAGONAL SLASH
|
||||
.. |sqcap| unicode:: U+02293 .. SQUARE CAP
|
||||
.. |sqcaps| unicode:: U+02293 U+0FE00 .. SQUARE CAP with serifs
|
||||
.. |sqcup| unicode:: U+02294 .. SQUARE CUP
|
||||
.. |sqcups| unicode:: U+02294 U+0FE00 .. SQUARE CUP with serifs
|
||||
.. |ssetmn| unicode:: U+02216 .. SET MINUS
|
||||
.. |sstarf| unicode:: U+022C6 .. STAR OPERATOR
|
||||
.. |subdot| unicode:: U+02ABD .. SUBSET WITH DOT
|
||||
.. |sum| unicode:: U+02211 .. N-ARY SUMMATION
|
||||
.. |supdot| unicode:: U+02ABE .. SUPERSET WITH DOT
|
||||
.. |timesb| unicode:: U+022A0 .. SQUARED TIMES
|
||||
.. |timesbar| unicode:: U+02A31 .. MULTIPLICATION SIGN WITH UNDERBAR
|
||||
.. |timesd| unicode:: U+02A30 .. MULTIPLICATION SIGN WITH DOT ABOVE
|
||||
.. |top| unicode:: U+022A4 .. DOWN TACK
|
||||
.. |tridot| unicode:: U+025EC .. WHITE UP-POINTING TRIANGLE WITH DOT
|
||||
.. |triminus| unicode:: U+02A3A .. MINUS SIGN IN TRIANGLE
|
||||
.. |triplus| unicode:: U+02A39 .. PLUS SIGN IN TRIANGLE
|
||||
.. |trisb| unicode:: U+029CD .. TRIANGLE WITH SERIFS AT BOTTOM
|
||||
.. |tritime| unicode:: U+02A3B .. MULTIPLICATION SIGN IN TRIANGLE
|
||||
.. |uplus| unicode:: U+0228E .. MULTISET UNION
|
||||
.. |veebar| unicode:: U+022BB .. XOR
|
||||
.. |wedbar| unicode:: U+02A5F .. LOGICAL AND WITH UNDERBAR
|
||||
.. |wreath| unicode:: U+02240 .. WREATH PRODUCT
|
||||
.. |xcap| unicode:: U+022C2 .. N-ARY INTERSECTION
|
||||
.. |xcirc| unicode:: U+025EF .. LARGE CIRCLE
|
||||
.. |xcup| unicode:: U+022C3 .. N-ARY UNION
|
||||
.. |xdtri| unicode:: U+025BD .. WHITE DOWN-POINTING TRIANGLE
|
||||
.. |xodot| unicode:: U+02A00 .. N-ARY CIRCLED DOT OPERATOR
|
||||
.. |xoplus| unicode:: U+02A01 .. N-ARY CIRCLED PLUS OPERATOR
|
||||
.. |xotime| unicode:: U+02A02 .. N-ARY CIRCLED TIMES OPERATOR
|
||||
.. |xsqcup| unicode:: U+02A06 .. N-ARY SQUARE UNION OPERATOR
|
||||
.. |xuplus| unicode:: U+02A04 .. N-ARY UNION OPERATOR WITH PLUS
|
||||
.. |xutri| unicode:: U+025B3 .. WHITE UP-POINTING TRIANGLE
|
||||
.. |xvee| unicode:: U+022C1 .. N-ARY LOGICAL OR
|
||||
.. |xwedge| unicode:: U+022C0 .. N-ARY LOGICAL AND
|
||||
@@ -0,0 +1,29 @@
|
||||
.. This data file has been placed in the public domain.
|
||||
.. Derived from the Unicode character mappings available from
|
||||
<http://www.w3.org/2003/entities/xml/>.
|
||||
Processed by unicode2rstsubs.py, part of Docutils:
|
||||
<http://docutils.sourceforge.net>.
|
||||
|
||||
.. |dlcorn| unicode:: U+0231E .. BOTTOM LEFT CORNER
|
||||
.. |drcorn| unicode:: U+0231F .. BOTTOM RIGHT CORNER
|
||||
.. |gtlPar| unicode:: U+02995 .. DOUBLE LEFT ARC GREATER-THAN BRACKET
|
||||
.. |langd| unicode:: U+02991 .. LEFT ANGLE BRACKET WITH DOT
|
||||
.. |lbrke| unicode:: U+0298B .. LEFT SQUARE BRACKET WITH UNDERBAR
|
||||
.. |lbrksld| unicode:: U+0298F .. LEFT SQUARE BRACKET WITH TICK IN BOTTOM CORNER
|
||||
.. |lbrkslu| unicode:: U+0298D .. LEFT SQUARE BRACKET WITH TICK IN TOP CORNER
|
||||
.. |lceil| unicode:: U+02308 .. LEFT CEILING
|
||||
.. |lfloor| unicode:: U+0230A .. LEFT FLOOR
|
||||
.. |lmoust| unicode:: U+023B0 .. UPPER LEFT OR LOWER RIGHT CURLY BRACKET SECTION
|
||||
.. |lpargt| unicode:: U+029A0 .. SPHERICAL ANGLE OPENING LEFT
|
||||
.. |lparlt| unicode:: U+02993 .. LEFT ARC LESS-THAN BRACKET
|
||||
.. |ltrPar| unicode:: U+02996 .. DOUBLE RIGHT ARC LESS-THAN BRACKET
|
||||
.. |rangd| unicode:: U+02992 .. RIGHT ANGLE BRACKET WITH DOT
|
||||
.. |rbrke| unicode:: U+0298C .. RIGHT SQUARE BRACKET WITH UNDERBAR
|
||||
.. |rbrksld| unicode:: U+0298E .. RIGHT SQUARE BRACKET WITH TICK IN BOTTOM CORNER
|
||||
.. |rbrkslu| unicode:: U+02990 .. RIGHT SQUARE BRACKET WITH TICK IN TOP CORNER
|
||||
.. |rceil| unicode:: U+02309 .. RIGHT CEILING
|
||||
.. |rfloor| unicode:: U+0230B .. RIGHT FLOOR
|
||||
.. |rmoust| unicode:: U+023B1 .. UPPER RIGHT OR LOWER LEFT CURLY BRACKET SECTION
|
||||
.. |rpargt| unicode:: U+02994 .. RIGHT ARC GREATER-THAN BRACKET
|
||||
.. |ulcorn| unicode:: U+0231C .. TOP LEFT CORNER
|
||||
.. |urcorn| unicode:: U+0231D .. TOP RIGHT CORNER
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user