Debian Codegraph @

docs/eps/ep-010.rst

raw
1 .. include:: header.rst
2
3 =====================================================
4 EP 10 — Public API and Backwards Compatibility Policy
5 =====================================================
6
7 :Authors: Günter Milde, Adam Turner
8 :Discussions-To: https://sourceforge.net/p/docutils/feature-requests/89/
9 :Status: Active
10 :Type: Process
11 :Created: 2025-04-22
12 :Docutils-Version: 0.23
13 :Resolution: `2026-04-09
14 <https://sourceforge.net/p/docutils/feature-requests/89/#a268>`__
15
16 :Abstract:
17 This document defines the public API provided by the
18 Docutils project and its backwards compatibility policy.
19
20 .. contents::
21
22
23 Motivation
24 ==========
25
26 .. Clearly explain why the existing specification is inadequate to
27 address the problem that the proposal solves.
28
29 Docutils has a large user base and is used in production at several
30 places (Python documentation, Linux kernel documentation, CMake
31 documentation, readthedocs, ...). OTOH, Docutils has a version number
32 below 1.0 (widely seen as an indicator of "beta" status of a project).
33
34 The current `Docutils Project Policies`_ section on `version
35 identification`_ concentrates on the formal definition of the version
36 specifier but leaves open what consists a "major change in the design
37 or API".
38
39 The current `backwards compatibility policy`_ is a stub referencing
40 :PEP:`387`.
41
42
43 Rationale
44 =========
45
46 .. Describe why particular design decisions were made.
47
48 Clearly defining how we will balance evolution with stability is
49 important to both users and project developers.
50
51 People affected by changes in Docutils include:
52
53 .. class:: description
54
55 Authors
56 writing or maintaining reStructuredText documents.
57
58 End-Users
59 of the `Docutils front-end tools`_ (optionally with 3rd-party
60 drop-in extensions) or alternative tools using Docutils either as a
61 library (Sphinx_, …) or via the command line interface
62 (build systems, Makefiles, scripts in other languages).
63
64 Developers
65 i.e. authors and maintainers of
66
67 - projects that use Docutils as a library (Sphinx_, rsted_, Leo_,
68 Pelican_, ebookmaker_, MyST_, readthedocs_, rinohtype_, …),
69 - drop-in components (pycmark_, rst2pdf_, rst2beamer_, …),
70 - alternative front-end tools,
71 - custom stylesheets (CSS style sheets, LaTeX styles, ODT styles),
72 or
73 - re-implementations of the `reStructuredText Markup Specification`_,
74 e.g. Pandoc_ or Text-Restructured_ (prest).
75
76 A person may belong to more than one of these categories.
77
78 .. _Sphinx: https://www.sphinx-doc.org/
79 .. _rsted: https://github.com/anru/rsted
80 .. _Leo: https://leo-editor.github.io/leo-editor/
81 .. _Pelican: https://docs.getpelican.com/en/latest/
82 .. _MyST: https://myst-parser.readthedocs.io/
83 .. _readthedocs: https://readthedocs.org/
84 .. _pycmark: https://github.com/pycmark/pycmark
85 .. _rst2pdf: https://rst2pdf.org/
86 .. _rst2beamer: https://docutils.sourceforge.io/sandbox/rst2beamer/
87 .. _rinohtype: https://pypi.org/project/rinohtype/
88 .. _ebookmaker: https://pypi.org/project/ebookmaker/
89 .. _PanDoc: https://pandoc.org/
90 .. _Text-Restructured: https://metacpan.org/dist/Text-Restructured
91
92
93 .. _specification:
94
95 Public API
96 ==========
97
98 .. Describe the syntax and semantics of any new feature.
99
100 Docutils' public API includes:
101
102 * the `reStructuredText Markup Specification` [restructuredtext]_,
103
104 * the `Docutils Document Model` [doctree]_ [docutils.dtd]_,
105
106 * names and behaviour of the `Front End Tools`
107 ("console_scripts" entry points) [tools]_,
108
109 * the core ``docutils`` Python package API:
110
111 - the "publisher" interface for programmatic use [publisher]_,
112 - the runtime settings [settings]_,
113 - component interfaces as defined by the abstract base classes
114 `docutils.readers.Reader`, `docutils.parsers.Parser`,
115 `docutils.writer.Writer`, and `docutils.transform.Transform`,
116
117 * behaviour and names of *documented Python objects*,
118
119 * *output templates* and *style sheets* provided with the writers,
120
121 .. template.txt, default.tex, titlepage.tex, xelatex.tex
122 .. html4css1.css, minimal.css, docutils.sty (LaTeX), styles.odt
123
124 * the interface to custom stylesheets -- elements, macros and classes
125 used by writers to represent Doctree_ nodes in the output format.
126
127 Exemptions:
128
129 * Python objects, stylesheets, and templates can "opt-out" of
130 the public API with a docstring noting that the object is
131 |provisional|_ or *internal*.
132 * All **undocumented** objects should be assumed to be internal. [#]_
133
134 .. tip::
135
136 To find out if an object from the *docutils* package is safe to use,
137 look up its docstring and the docstring of its parent(s). [*]_
138
139 If there is no documentation or the documentation says *provisional* or
140 *internal*, the name, behaviour, and existence of the object is not
141 guaranteed to be stable.
142
143 Code relying on non-public objects should be made robust using
144 public alternatives. If there is a no such alternative or the
145 required change would be a problem, `contact the Docutils
146 developers`__ or file a `feature request`_.
147
148 .. [*] `Attribute docstrings`_ are not shown by pydoc_.
149 To find out whether attributes have a docstring, check the source.
150
151 __ https://docutils.sourceforge.io/docs/user/mailing-lists.html
152 .. _feature request: https://sourceforge.net/p/docutils/feature-requests/
153 .. _attribute docstrings:
154 https://peps.python.org/pep-0258/#attribute-docstrings
155 .. _pydoc: https://docs.python.org/3/library/pydoc.html
156
157 .. [#] Cf. `Backwards Compatibility Rules`_ in :PEP:`387` and
158 `Public and Internal Interfaces`_ in :PEP:`8`.
159
160
161 .. |provisional| replace:: *provisional*
162
163
164 Backwards Compatibility
165 =======================
166
167 .. Describe potential impact and severity on pre-existing code.
168
169 Beginning with version 1.0, Docutils will follow the rules of
170 `Semantic Versioning`_. All incompatible changes to the public APIs
171 require increasing the `major` part of the `version specifier`_.
172 Backwards compatible changes can be done in `minor` releases.
173
174
175 Security Implications
176 =====================
177
178 If required, critical bug fixes may change the public API without advance
179 warning.
180
181
182 Rejected Ideas
183 ==============
184
185 .. Why certain ideas that were brought while discussing this proposal were not
186 ultimately pursued.
187
188 Use type annotations as an indication of status in the public API.
189
190 - There is no known precedence for this approach.
191 - Type annotations may be helpful also for non-public code.
192
193 Use Calendar Versioning (CalVer).
194
195 - Would be a break from current versioning without clear advantages.
196
197 Allow breaking API changes in *minor* versions after prior announcement
198 and a deprecation period.
199
200 - Breaks the principle of least surprise.
201
202 Mark all internal objects with a prefix underscore.
203
204 - May needlessly break applications using internal objects.
205
206 Use the ``__all__`` attribute to declare modules, classes, and
207 functions that form the public API.
208
209 - This may be done later to improve "pydoc_" output, but should not hold
210 up the declaration of a Backwards Compatibility Policy.
211
212
213 Open Issues
214 ===========
215
216 .. Any points that are still being decided/discussed.
217
218 * Differentiate between "core API" and "extended API"?
219
220 There are many objects that were not intended for public use but are
221 still used by downstream projects.
222
223 Before the switch to semantic versioning, the `Docutils Project Policies`_
224 contained the lines:
225
226 When Docutils reaches version 1.0, the major APIs will be considered
227 frozen.
228
229 The major number [...] may be incremented later if there is a major
230 change in the design or API.
231
232 * Define a minimum deprecation time similar to DocBook?
233
234 A "major" release […] may contain backward-incompatible changes if:
235
236 * the change was announced in the release notes for the previous
237 version (major or minor) and
238 * the change was announced in a release that occurred at least six
239 months previously.
240
241 By these rules, the technical committee can announce, in 5.1,
242 for example, plans to make a backward-incompatible change in 6.0.
243 Then, in 6.0, if it’s been at least six months since 5.1 was
244 released, they can make that change.
245
246 --- https://tdg.docbook.org/tdg/5.1/ch01.html#bwcompat
247
248 * Generate API documentation with Sphinx?
249
250 - nicely format rST docstrings
251 - include attribute docstrings (ignored by pydoc_).
252
253 .. _pydoc: https://docs.python.org/3/library/pydoc.html
254
255
256 References
257 ==========
258
259 .. A collection of URLs used as references through the proposal.
260
261
262 .. [doctree] `The Docutils Document Tree <../ref/doctree.html>`_
263 .. [docutils.dtd] `Docutils Generic DTD <../ref/docutils.dtd>`_
264 .. [publisher] `The Docutils Publisher <../api/publisher.html>`_
265 .. [tools] `Docutils Front-End Tools <../user/tools.html>`_
266 .. [restructuredtext] `reStructuredText Markup Specification
267 <../ref/rst/restructuredtext.html>`_
268 .. [settings] `Docutils Runtime Settings <../api/runtime-settings.html>`_
269 .. [transforms] `Docutils Transforms <../api/transforms.html>`_
270
271 .. _API Reference Material for Client-Developers:
272 ../index.html#api-reference-material-for-client-developers
273 .. _Docutils Design Specification: ../peps/pep-0258.html
274 .. _Docutils Project Policies: ../dev/policies.html
275 .. _version specifier:
276 .. _version identification:
277 ../dev/policies.html#version-identification
278 .. _backwards compatibility policy:
279 ../dev/policies.html#backwards-compatibility-policy
280 .. _HISTORY: ../docutils/HISTORY.html
281 .. _RELEASE-NOTES: ../docutils/RELEASE-NOTES.html
282
283 .. _`Backwards Compatibility Rules`:
284 https://peps.python.org/pep-0387/#backwards-compatibility-rules
285 .. _`Public and Internal Interfaces`:
286 https://peps.python.org/pep-0008/#public-and-internal-interfaces
287 .. _provisional: https://docs.python.org/3/glossary.html#term-provisional-API
288
289 .. _Semantic Versioning: https://semver.org/
290
291
292 Copyright
293 =========
294
295 This document is placed in the public domain or under the
296 CC0-1.0-Universal license, whichever is more permissive.