Debian Codegraph @

test/expensive_benchmarks/docutils_data/docs/api/runtime-settings.txt

raw
1 ===========================
2 Docutils Runtime Settings
3 ===========================
4
5 :Author: David Goodger, Günter Milde
6 :Contact: [email protected]
7 :Date: $Date$
8 :Revision: $Revision$
9 :Copyright: This document has been placed in the public domain.
10
11 .. contents::
12
13
14 Introduction
15 ============
16
17 Docutils runtime settings are assembled from several sources:
18
19 * Settings specifications of the selected components_,
20 * `configuration files`_ (if enabled), and
21 * command-line options (if enabled).
22
23 Docutils overlays default and explicitly specified values from these
24 sources such that settings behave the way we want and expect them to
25 behave.
26
27
28 Settings priority
29 =================
30
31 The sources are overlaid in the following order (later sources
32 overwrite earlier ones):
33
34 1. Defaults specified in the `settings_spec`__ and
35 `settings_defaults`__ attributes for each component_.
36
37 __ SettingsSpec.settings_spec_
38 __ SettingsSpec.settings_defaults_
39
40 2. Defaults specified in the `settings_default_overrides`__ attribute
41 for each component_.
42
43 __ SettingsSpec.settings_default_overrides_
44
45 3. Settings specified in the `settings_overrides`__ parameter of the
46 `convenience functions`_ resp. the `settings_overrides` attribute of
47 a `Publisher`_ instance.
48
49 __ `settings_overrides parameter`_
50
51 4. Settings specified in `active sections`_ of the `configuration files`_
52 in the order described in `Configuration File Sections & Entries`_
53 (if enabled).
54
55 5. Command line options (if enabled).
56
57 For details see the ``docutils/__init__.py``, ``docutils/core.py``, and
58 ``docutils.frontend.py`` modules and the implementation description in
59 `Runtime Settings Processing`_.
60
61
62 .. _SettingsSpec:
63
64 SettingsSpec base class
65 =======================
66
67 .. note::
68 Implementation details will change with the move to replace the
69 deprecated optparse_ module with argparse_.
70
71 The `docutils.SettingsSpec` base class is inherited by Docutils
72 components_ and `frontend.OptionParser`.
73 It defines the following six **attributes**:
74
75 .. _SettingsSpec.settings_spec:
76
77 `settings_spec`
78 a sequence of
79
80 1. option group title (string or None)
81
82 2. description (string or None)
83
84 3. option tuples with
85
86 a) help text
87 b) options string(s)
88 c) dictionary with keyword arguments for `OptionParser.add_option()`_
89 and an optional "validator", a `frontend.validate_*()` function
90 that processes the values (e.g. convert to other data types).
91
92 For examples, see the source of ``frontend.OptionParser.settings_spec``
93 or the `settings_spec` attributes of the Docutils components_.
94
95 .. _SettingsSpec.settings_defaults:
96
97 `settings_defaults`
98 for purely programmatic settings
99 (not accessible from command line and configuration files).
100
101 .. _SettingsSpec.settings_default_overrides:
102
103 `settings_default_overrides`
104 to override defaults for settings
105 defined in other components' `setting_specs`.
106
107 `relative_path_settings`
108 listing settings containing filesystem paths.
109
110 .. _active sections:
111
112 `config_section`
113 the configuration file section specific to this
114 component.
115
116 `config_section_dependencies`
117 lists configuration files sections
118 that should also be read (before the `config_section`).
119
120 The last two attributes define which configuration file sections are
121 "active". See also `Configuration File Sections & Entries`_.
122
123
124 Glossary
125 ========
126
127 .. _component:
128
129 components
130 ----------
131
132 Docutils front-ends and applications combine a selection of
133 *components* of the `Docutils Project Model`_.
134
135 All components inherit the `SettingsSpec`_ base class.
136 This means that all instances of ``readers.Reader``, ``parsers.Parser``, and
137 ``writers.Writer`` are also instances of ``docutils.SettingsSpec``.
138
139 For the determination of runtime settings, ``frontend.OptionParser`` and
140 the `settings_spec parameter`_ in application settings specifications
141 are treated as components as well.
142
143
144 .. _convenience function:
145
146 convenience functions
147 ---------------------
148
149 Applications usually deploy Docutils by one of the
150 `Publisher convenience functions`_.
151
152 All convenience functions accept the following optional parameters:
153
154 .. _settings parameter:
155
156 `settings`
157 a ``frontend.Values`` instance.
158 If present, it must be complete.
159
160 No further runtime settings processing is done and the
161 following parameters have no effect.
162
163 .. _settings_spec parameter:
164
165 `settings_spec`
166 a `SettingsSpec`_ subclass or instance containing the settings
167 specification for the "Application" itself.
168 The instance is added to the components_ (after the generic
169 settings, parser, reader, and writer).
170
171 .. _settings_overrides parameter:
172
173 `settings_overrides`
174 a dictionary which is used to update the
175 defaults of the components' settings specifications.
176
177 .. _config_section parameter:
178
179 `config_section`
180 the name of an application-specific
181 `configuration file section`_ for this application.
182
183 Can be specified instead of a `settings_spec` (a new SettingsSpec_
184 instance that just defines a configuration section will be created)
185 or in addition to a `settings_spec`
186 (overriding its `config_section` attribute).
187
188
189 settings_spec
190 -------------
191
192 The name ``settings_spec`` may refer to
193
194 a) an instance of the SettingsSpec_ class, or
195 b) the data structure `SettingsSpec.settings_spec`_ which is used to
196 store settings details.
197
198
199 .. References:
200
201 .. _Publisher: publisher.html
202 .. _Publisher convenience functions:
203 publisher.html#publisher-convenience-functions
204 .. _front-end tools: ../user/tools.html
205 .. _configuration files:
206 .. _Docutils Configuration: ../user/config.html#configuration-files
207 .. _configuration file section:
208 .. _Configuration File Sections & Entries:
209 ../user/config.html#configuration-file-sections-entries
210 .. _Docutils Project Model: ../peps/pep-0258.html#docutils-project-model
211 .. _Reader: ../peps/pep-0258.html#reader
212 .. _Runtime Settings Processing: ../dev/runtime-settings-processing.html
213
214 .. _optparse: https://docs.python.org/dev/library/optparse.html
215 .. _argparse: https://docs.python.org/dev/library/argparse.html
216 .. _OptionParser.add_option():
217 https://docs.python.org/dev/library/optparse.html
218 #optparse.OptionParser.add_option