comparison env/lib/python3.7/site-packages/docutils/__init__.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
1 # $Id: __init__.py 8453 2020-01-12 13:28:32Z grubert $
2 # Author: David Goodger <goodger@python.org>
3 # Copyright: This module has been placed in the public domain.
4
5 """
6 This is the Docutils (Python Documentation Utilities) package.
7
8 Package Structure
9 =================
10
11 Modules:
12
13 - __init__.py: Contains component base classes, exception classes, and
14 Docutils version information.
15
16 - core.py: Contains the ``Publisher`` class and ``publish_*()`` convenience
17 functions.
18
19 - frontend.py: Runtime settings (command-line interface, configuration files)
20 processing, for Docutils front-ends.
21
22 - io.py: Provides a uniform API for low-level input and output.
23
24 - nodes.py: Docutils document tree (doctree) node class library.
25
26 - statemachine.py: A finite state machine specialized for
27 regular-expression-based text filters.
28
29 Subpackages:
30
31 - languages: Language-specific mappings of terms.
32
33 - parsers: Syntax-specific input parser modules or packages.
34
35 - readers: Context-specific input handlers which understand the data
36 source and manage a parser.
37
38 - transforms: Modules used by readers and writers to modify DPS
39 doctrees.
40
41 - utils: Contains the ``Reporter`` system warning class and miscellaneous
42 utilities used by readers, writers, and transforms.
43
44 utils/urischemes.py: Contains a complete mapping of known URI addressing
45 scheme names to descriptions.
46
47 - utils/math: Contains functions for conversion of mathematical notation
48 between different formats (LaTeX, MathML, text, ...).
49
50 - writers: Format-specific output translators.
51 """
52
53 import sys
54 from collections import namedtuple
55
56
57 __docformat__ = 'reStructuredText'
58
59 __version__ = '0.16'
60 """Docutils version identifier (complies with PEP 440)::
61
62 major.minor[.micro][releaselevel[serial]][.dev]
63
64 For version comparison operations, use `__version_info__` (see, below)
65 rather than parsing the text of `__version__`.
66
67 See 'Version Numbering' in docs/dev/policies.txt.
68 """
69
70 VersionInfo = namedtuple(
71 'VersionInfo', 'major minor micro releaselevel serial release')
72
73 __version_info__ = VersionInfo(
74 major=0,
75 minor=16,
76 micro=0,
77 releaselevel='final', # one of 'alpha', 'beta', 'candidate', 'final'
78 # pre-release serial number (0 for final releases and active development):
79 serial=0,
80 release=True # True for official releases and pre-releases
81 )
82 """Comprehensive version information tuple. See 'Version Numbering' in
83 docs/dev/policies.txt."""
84
85 __version_details__ = 'release'
86 """Optional extra version details (e.g. 'snapshot 2005-05-29, r3410').
87 (For development and release status see `__version_info__`.)
88 """
89
90
91 class ApplicationError(Exception): pass
92
93 class DataError(ApplicationError): pass
94
95
96 class SettingsSpec(object):
97
98 """
99 Runtime setting specification base class.
100
101 SettingsSpec subclass objects used by `docutils.frontend.OptionParser`.
102 """
103
104 settings_spec = ()
105 """Runtime settings specification. Override in subclasses.
106
107 Defines runtime settings and associated command-line options, as used by
108 `docutils.frontend.OptionParser`. This is a tuple of:
109
110 - Option group title (string or `None` which implies no group, just a list
111 of single options).
112
113 - Description (string or `None`).
114
115 - A sequence of option tuples. Each consists of:
116
117 - Help text (string)
118
119 - List of option strings (e.g. ``['-Q', '--quux']``).
120
121 - Dictionary of keyword arguments sent to the OptionParser/OptionGroup
122 ``add_option`` method.
123
124 Runtime setting names are derived implicitly from long option names
125 ('--a-setting' becomes ``settings.a_setting``) or explicitly from the
126 'dest' keyword argument.
127
128 Most settings will also have a 'validator' keyword & function. The
129 validator function validates setting values (from configuration files
130 and command-line option arguments) and converts them to appropriate
131 types. For example, the ``docutils.frontend.validate_boolean``
132 function, **required by all boolean settings**, converts true values
133 ('1', 'on', 'yes', and 'true') to 1 and false values ('0', 'off',
134 'no', 'false', and '') to 0. Validators need only be set once per
135 setting. See the `docutils.frontend.validate_*` functions.
136
137 See the optparse docs for more details.
138
139 - More triples of group title, description, options, as many times as
140 needed. Thus, `settings_spec` tuples can be simply concatenated.
141 """
142
143 settings_defaults = None
144 """A dictionary of defaults for settings not in `settings_spec` (internal
145 settings, intended to be inaccessible by command-line and config file).
146 Override in subclasses."""
147
148 settings_default_overrides = None
149 """A dictionary of auxiliary defaults, to override defaults for settings
150 defined in other components. Override in subclasses."""
151
152 relative_path_settings = ()
153 """Settings containing filesystem paths. Override in subclasses.
154 Settings listed here are to be interpreted relative to the current working
155 directory."""
156
157 config_section = None
158 """The name of the config file section specific to this component
159 (lowercase, no brackets). Override in subclasses."""
160
161 config_section_dependencies = None
162 """A list of names of config file sections that are to be applied before
163 `config_section`, in order (from general to specific). In other words,
164 the settings in `config_section` are to be overlaid on top of the settings
165 from these sections. The "general" section is assumed implicitly.
166 Override in subclasses."""
167
168
169 class TransformSpec:
170
171 """
172 Runtime transform specification base class.
173
174 TransformSpec subclass objects used by `docutils.transforms.Transformer`.
175 """
176
177 def get_transforms(self):
178 """Transforms required by this class. Override in subclasses."""
179 if self.default_transforms != ():
180 import warnings
181 warnings.warn('default_transforms attribute deprecated.\n'
182 'Use get_transforms() method instead.',
183 DeprecationWarning)
184 return list(self.default_transforms)
185 return []
186
187 # Deprecated; for compatibility.
188 default_transforms = ()
189
190 unknown_reference_resolvers = ()
191 """List of functions to try to resolve unknown references. Unknown
192 references have a 'refname' attribute which doesn't correspond to any
193 target in the document. Called when the transforms in
194 `docutils.tranforms.references` are unable to find a correct target. The
195 list should contain functions which will try to resolve unknown
196 references, with the following signature::
197
198 def reference_resolver(node):
199 '''Returns boolean: true if resolved, false if not.'''
200
201 If the function is able to resolve the reference, it should also remove
202 the 'refname' attribute and mark the node as resolved::
203
204 del node['refname']
205 node.resolved = 1
206
207 Each function must have a "priority" attribute which will affect the order
208 the unknown_reference_resolvers are run::
209
210 reference_resolver.priority = 100
211
212 Override in subclasses."""
213
214
215 class Component(SettingsSpec, TransformSpec):
216
217 """Base class for Docutils components."""
218
219 component_type = None
220 """Name of the component type ('reader', 'parser', 'writer'). Override in
221 subclasses."""
222
223 supported = ()
224 """Names for this component. Override in subclasses."""
225
226 def supports(self, format):
227 """
228 Is `format` supported by this component?
229
230 To be used by transforms to ask the dependent component if it supports
231 a certain input context or output format.
232 """
233 return format in self.supported