Debian Codegraph @

docs/dev/policies.rst

raw
1 .. include:: ../header.rst
2
3 ===========================
4 Docutils Project Policies
5 ===========================
6
7 :Author: David Goodger; open to all Docutils developers
8 :Contact: [email protected]
9 :Date: $Date: 2026-05-08 16:57:38 +0200 (Fr, 08. Mai 2026) $
10 :Revision: $Revision: 10332 $
11 :Copyright: This document has been placed in the public domain.
12
13 .. contents::
14
15 The Docutils project group is a meritocracy based on code contribution
16 and lots of discussion [#bcs]_. A few quotes sum up the policies of
17 the Docutils project. The IETF's classic credo (by MIT professor Dave
18 Clark) is an ideal we can aspire to:
19
20 We reject: kings, presidents, and voting. We believe in: rough
21 consensus and running code.
22
23 As architect, chief cook and bottle-washer, David Goodger currently
24 functions as BDFN (Benevolent Dictator For Now). (But he would
25 happily abdicate the throne given a suitable candidate. Any takers?)
26
27 Eric S. Raymond, anthropologist of the hacker subculture, writes in
28 his essay `The Magic Cauldron`_:
29
30 The number of contributors [to] projects is strongly and inversely
31 correlated with the number of hoops each project makes a user go
32 through to contribute.
33
34 We will endeavour to keep the barrier to entry as low as possible.
35 The policies below should not be thought of as barriers, but merely as
36 a codification of experience to date. These are "best practices";
37 guidelines, not absolutes. Exceptions are expected, tolerated, and
38 used as a source of improvement. Feedback and criticism is welcome.
39
40 As for control issues, Emmett Plant (CEO of the Xiph.org Foundation,
41 originators of Ogg Vorbis) put it well when he said:
42
43 Open source dictates that you lose a certain amount of control
44 over your codebase, and that's okay with us.
45
46 .. [#bcs] Phrase borrowed from `Ben Collins-Sussman of the Subversion
47 project <http://www.red-bean.com/sussman/svn-anti-fud.html>`__.
48
49 .. _The Magic Cauldron:
50 http://www.catb.org/~esr/writings/magic-cauldron/
51
52
53 Python Coding Conventions
54 =========================
55
56 Contributed code will not be refused merely because it does not
57 strictly adhere to these conditions; as long as it's internally
58 consistent, clean, and correct, it probably will be accepted. But
59 don't be surprised if the "offending" code gets fiddled over time to
60 conform to these conventions.
61
62 The Docutils project shall follow the generic coding conventions as
63 specified in the `Style Guide for Python Code` (:PEP:`8`) and `Docstring
64 Conventions` (:PEP:`257`), summarized, clarified, and extended as follows:
65
66 * 4 spaces per indentation level. No hard tabs.
67
68 * Use UTF-8 encoding (no encoding declaration).
69 Identifiers must use ASCII only.
70
71 * No one-liner compound statements (i.e., no ``if x: return``: use two
72 lines & indentation), except for degenerate class or method
73 definitions (i.e., ``class X: pass`` is OK.).
74
75 * Lines should be no more than 78 characters long.
76
77 * Use "StudlyCaps" for class names (except for element classes in
78 docutils.nodes).
79
80 * Use "lowercase" or "lowercase_with_underscores" for function,
81 method, and variable names. For short names, maximum two words,
82 joined lowercase may be used (e.g. "tagname"). For long names with
83 three or more words, or where it's hard to parse the split between
84 two words, use lowercase_with_underscores (e.g.,
85 "note_explicit_target", "explicit_target"). If in doubt, use
86 underscores.
87
88 * Avoid lambda expressions, which are inherently difficult to
89 understand. Named functions are preferable and superior: they're
90 faster (no run-time compilation), and well-chosen names serve to
91 document and aid understanding.
92
93 * Avoid functional constructs (filter, map, etc.). Use list
94 comprehensions instead.
95
96 * Avoid ``from __future__ import`` constructs. They are inappropriate
97 for production code.
98
99 * Use 'single quotes' for string literals, and """triple double
100 quotes""" for docstrings.
101
102 .. _Docutils Internationalization: ../howto/i18n.html#python-code
103
104
105 Documentation Conventions
106 =========================
107
108 * Docutils documentation is written using reStructuredText, of course.
109
110 * The encoding of the documentation files is UTF-8.
111
112 * Use the following section title adornment styles::
113
114 ================
115 Document Title
116 ================
117
118 --------------------------------------------
119 Document Subtitle, or Major Division Title
120 --------------------------------------------
121
122 Section
123 =======
124
125 Subsection
126 ----------
127
128 Sub-Subsection
129 ``````````````
130
131 Sub-Sub-Subsection
132 ..................
133
134 * Use two blank lines before each section/subsection/etc. title. One
135 blank line is sufficient between immediately adjacent titles.
136
137 * Add a bibliographic field list immediately after the document
138 title/subtitle. See the beginning of this document for an example.
139
140 * Add an Emacs "local variables" block in a comment at the end of the
141 document. See the end of this document for an example.
142
143
144 Copyrights and Licensing
145 ========================
146
147 The majority of the Docutils project code and documentation has been
148 placed in the public domain (see `Copying Docutils`_).
149
150 Unless clearly and explicitly indicated
151 otherwise, any patches (modifications to existing files) submitted to
152 the project for inclusion (via Subversion, SourceForge trackers,
153 mailing lists, or private email) are assumed to be in the public
154 domain as well.
155
156 Any new files contributed to the project should clearly state their
157 intentions regarding copyright, in one of the following ways:
158
159 * Public domain (preferred): include the statement "This
160 module/document has been placed in the public domain."
161
162 * Copyright & open source license: include a copyright notice, along
163 with either an embedded license statement, a reference to an
164 accompanying license file, or a license URL.
165
166 The license should be well known, simple and compatible with other
167 open source software licenses. To keep the number of different
168 licenses at a minimum, using the `2-Clause BSD license`_
169 (`local copy`__) is recommended.
170
171 .. Rationale:
172 + clear wording, structured text
173 + license used by the closely related Sphinx project
174
175 .. _Copying Docutils: ../../COPYING.html
176 .. _2-Clause BSD license: http://opensource.org/licenses/BSD-2-Clause
177 __ ../../licenses/BSD-2-Clause.rst
178
179
180 .. _Subversion Repository:
181
182 Repository
183 ==========
184
185 Please see the `repository documentation`_ for details on how to
186 access Docutils' Subversion repository. Anyone can access the
187 repository anonymously. Only project developers can make changes.
188 (If you would like to become a project developer, just ask!) Also see
189 `Setting Up For Docutils Development`_ below for some useful info.
190
191 Unless you really *really* know what you're doing, please do *not* use
192 ``svn import``. It's quite easy to mess up the repository with an
193 import.
194
195 .. _repository documentation: repository.html
196
197
198 Branches
199 --------
200
201 (These branch policies go into effect with Docutils 0.4.)
202
203 The "docutils" directory of the **trunk** (a.k.a. the **Docutils
204 core**) is used for active -- but stable, fully tested, and reviewed
205 -- development.
206
207 If we need to cut a bugfix release, we'll create a **maintenance branch**
208 based on the latest feature release. For example, when Docutils 0.5 is
209 released, this would be ``branches/docutils-0.5``, and any existing 0.4.x
210 maintenance branches may be retired. Maintenance branches will receive bug
211 fixes only; no new features will be allowed here.
212
213 Obvious and uncontroversial bug fixes *with tests* can be checked in
214 directly to the core and to the maintenance branches. Don't forget to
215 add test cases! Many (but not all) bug fixes will be applicable both
216 to the core and to the maintenance branches; these should be applied
217 to both. No patches or dedicated branches are required for bug fixes,
218 but they may be used. It is up to the discretion of project
219 developers to decide which mechanism to use for each case.
220
221 .. _feature branches:
222 .. _feature branch:
223
224 Feature additions and API changes will be done in **feature
225 branches**. Feature branches will not be managed in any way.
226 Frequent small check-ins are encouraged here. Feature branches must be
227 discussed on the `docutils-develop mailing list`_ and reviewed before
228 being merged into the core.
229
230 .. _docutils-develop mailing list:
231 https://lists.sourceforge.net/lists/listinfo/docutils-develop
232
233
234 Review Criteria
235 ```````````````
236
237 Before a new feature, an API change, or a complex, disruptive, or
238 controversial bug fix can be checked in to the core or into a
239 maintenance branch, it must undergo review. These are the criteria:
240
241 * The branch must be complete, and include full documentation and
242 tests.
243
244 * There should ideally be one branch merge commit per feature or
245 change. In other words, each branch merge should represent a
246 coherent change set.
247
248 * The code must be stable and uncontroversial. Moving targets and
249 features under debate are not ready to be merged.
250
251 * The code must work. The test suite must complete with no failures.
252 See `Docutils Testing`_.
253
254 The review process will ensure that at least one other set of eyeballs
255 & brains sees the code before it enters the core. In addition to the
256 above, the general `Check-ins`_ policy (below) also applies.
257
258 .. _Docutils testing: testing.html
259
260
261 Check-ins
262 ---------
263
264 Changes or additions to the Docutils core and maintenance branches
265 carry a commitment to the Docutils user community. Developers must be
266 prepared to fix and maintain any code they have committed.
267
268 The Docutils core (``trunk/docutils`` directory) and maintenance
269 branches should always be kept in a stable state (usable and as
270 problem-free as possible). All changes to the Docutils core or
271 maintenance branches must be in `good shape`_, usable_, documented_,
272 tested_, and `reasonably complete`_. Starting with version 1.0, they must
273 also comply with the `backwards compatibility policy`_.
274
275 * _`Good shape` means that the code is clean, readable, and free of
276 junk code (unused legacy code; by analogy to "junk DNA").
277
278 * _`Usable` means that the code does what it claims to do. An "XYZ
279 Writer" should produce reasonable XYZ output.
280
281 * _`Documented`: The more complete the documentation the better.
282 Modules & files must be at least minimally documented internally.
283 `Docutils Front-End Tools`_ should have a new section for any
284 front-end tool that is added. `Docutils Configuration Files`_
285 should be modified with any settings/options defined. For any
286 non-trivial change, the HISTORY.rst_ file should be updated.
287
288 * _`Tested` means that unit and/or functional tests, that catch all
289 bugs fixed and/or cover all new functionality, have been added to
290 the test suite. These tests must be checked by running the test
291 suite under all supported Python versions, and the entire test suite
292 must pass. See `Docutils Testing`_.
293
294 * _`Reasonably complete` means that the code must handle all input.
295 Here "handle" means that no input can cause the code to fail (cause
296 an exception, or silently and incorrectly produce nothing).
297 "Reasonably complete" does not mean "finished" (no work left to be
298 done). For example, a writer must handle every standard element
299 from the Docutils document model; for unimplemented elements, it
300 must *at the very least* warn that "Output for element X is not yet
301 implemented in writer Y".
302
303 If you really want to check code directly into the Docutils core,
304 you can, but you must ensure that it fulfills the above criteria
305 first. People will start to use it and they will expect it to work!
306 If there are any issues with your code, or if you only have time for
307 gradual development, you should put it on a branch or in the sandbox
308 first. It's easy to move code over to the Docutils core once it's
309 complete.
310
311 It is the responsibility and obligation of all developers to keep the
312 Docutils core and maintenance branches stable. If a commit is made to
313 the core or maintenance branch which breaks any test, the solution is
314 simply to revert the change. This is not vindictive; it's practical.
315 We revert first, and discuss later.
316
317 Docutils will pursue an open and trusting policy for as long as
318 possible, and deal with any aberrations if (and hopefully not when)
319 they happen. We'd rather see a torrent of loose contributions than
320 just a trickle of perfect-as-they-stand changes. The occasional
321 mistake is easy to fix. That's what version control is for!
322
323 .. _Docutils Front-End Tools: ../user/tools.html
324 .. _Docutils Configuration Files: ../user/config.html
325 .. _HISTORY.rst: ../../HISTORY.rst
326
327
328 .. _`Version Numbering`:
329
330 Version Identification
331 ======================
332
333 The state of development of the current Docutils codebase is stored in
334 two forms: the sequence `docutils.__version_info__`_ and the
335 `PEP 440`_ conformant text string `docutils.__version__`_.
336 See also the `Docutils Release Procedure`_
337
338 .. _Docutils Release Procedure: release.html#version-numbers
339
340
341 ``docutils.__version_info__``
342 -----------------------------
343
344 ``docutils.__version_info__`` is an instance of ``docutils.VersionInfo``
345 based on collections.namedtuple_. It is modelled on `sys.version_info`_
346 and has the following attributes:
347
348 _`major` : non-negative integer
349 **Major releases** (x.0, e.g. 1.0) contain changes in
350 the `public API`_, functionality, or commitment.
351 The major number will be bumped to 1 when the project is
352 feature-complete, and incremented later if there are
353 backwards-incompatible changes.
354 For details, see the `backwards compatibility policy`_.
355
356 _`minor` : non-negative integer
357 Releases that change the minor number (x.y, e.g. 0.5) will be
358 **feature releases**; new features from the `Docutils core`_ will
359 be included.
360
361 micro : non-negative integer
362 Releases that change the micro number (x.y.z, e.g. 0.4.1) will be
363 **bug-fix releases**. No new features will be introduced in these
364 releases; only bug fixes will be included.
365
366 The micro number is omitted from `docutils.__version__`_ when it
367 equals zero.
368
369 _`releaselevel` : text string
370 The release level indicates the `development status`_ (or phase)
371 of the project's codebase:
372
373 ============= ========== ===============================================
374 Release Level Label [#]_ Description
375 ============= ========== ===============================================
376 alpha ``a`` Reserved for use after major experimental
377 changes, to indicate an unstable codebase.
378
379 beta ``b`` Indicates active development, between releases.
380
381 candidate ``rc`` Release candidate: indicates that the
382 codebase is ready to release unless
383 significant bugs emerge.
384
385 final Indicates an official project release.
386 ============= ========== ===============================================
387
388 .. [#] The labels are used in the `docutils.__version__`_ pre-release
389 segment.
390
391 .. _development status:
392 https://en.wikipedia.org/wiki/Software_release_life_cycle
393
394 _`serial` : non-negative integer
395 The serial number is zero for final releases and incremented
396 whenever a new pre-release is begun.
397
398 _`release` : boolean
399 True for official releases and pre-releases, False during
400 development.
401
402 * One of *{major, minor, micro, serial}* is incremented after each
403 release, and the lower-order numbers are reset to 0.
404
405 * The default state of the repository during active development is
406 releaseĀ level = "beta", serial = 0, release = False.
407
408 ``docutils.__version_info__`` can be used to test for a minimally
409 required version, e.g. ::
410
411 docutils.__version_info__ >= (0, 13)
412
413 is True for all versions after ``"0.13"``.
414
415 .. _collections.namedtuple:
416 https://docs.python.org/3/library/collections.html#collections.namedtuple
417 .. _sys.version_info:
418 https://docs.python.org/3/library/sys.html#sys.version_info
419
420 ``docutils.__version__``
421 ------------------------
422
423 The text string ``docutils.__version__`` is a human readable,
424 `PEPĀ 440`_-conforming version specifier. For version comparison
425 operations, use `docutils.__version_info__`_.
426
427 ``docutils.__version__`` takes the following form::
428
429 "<major>.<minor>[.<micro>][<releaselevel>[<serial>]][.dev]"
430 <--- release segment ---><-- pre-release segment -><- development ->
431
432 * The *pre-release segment* contains a label representing the
433 releaselevel_ ("a", "b", or "rc") and eventually a serial_ number
434 (omitted, if zero).
435
436 * The *development segment* is ``".dev"`` during active development
437 (release_ == False) and omitted for official releases and pre-releases.
438
439 Examples of ``docutils.__version__`` identifiers, over the course of
440 normal development (without branches), in ascending order:
441
442 ============================== =============================
443 Release Level Version Identifier
444 ============================== =============================
445 final (release) 0.14
446 beta (development) [#dev]_ 0.15b.dev
447 beta (release) [#skip]_ 0.15b
448 candidate 1 (dev.) 0.15rc1.dev
449 candidate 1 (release) 0.15rc1
450 candidate 2 (dev.) [#skip]_ 0.15rc2.dev
451 candidate 2 (release) [#skip]_ 0.15rc2
452 ...
453 final (release) 0.15
454 beta (development) [#dev]_ 0.16b.dev
455 ============================== =============================
456
457 .. [#dev] Default active development state between releases.
458 .. [#skip] These steps may be skipped.
459
460 .. _PEP 440: https://peps.python.org/pep-0440/
461
462 Policy History
463 --------------
464
465 * Prior to version 0.4, Docutils didn't have an official version
466 numbering policy, and micro releases contained both bug fixes and
467 new features.
468
469 * An earlier version of this policy was adopted in October 2005, and
470 took effect with Docutils version 0.4.
471
472 * This policy was updated in June 2017 for Docutils version 0.14. See
473 `Feature Request #50`_ and the `discussion on docutils-devel`__ from
474 May 28 to June 20 2017.
475
476 * The policy was updated in May 2026 to comply with the rules of
477 `Semantic Versioning`_ (cf. `EP 10`__).
478
479 .. _Feature Request #50:
480 https://sourceforge.net/p/docutils/feature-requests/50/
481 __ https://sourceforge.net/p/docutils/mailman/message/35903816/
482 .. _Semantic Versioning: https://semver.org/
483 __ ../eps/ep-010.html#backwards-compatibility
484
485
486 Backwards Compatibility Policy
487 ==============================
488
489 Beginning with version 1.0, Docutils will follow the rules of `Semantic
490 Versioning`_: All incompatible changes to the `public API`_ require
491 increasing the `major`_ part of the version specifier. Backwards
492 compatible changes can be done in `minor`_ releases.
493
494 * A majority of the projects depending on Docutils does this indirectly,
495 via the Sphinx_ document processor.
496
497 Sphinx developers should be given the chance to fix or work around a
498 DeprecationWarning_ in the Sphinx development version before a new
499 Docutils version is released. Otherwise, use a PendingDeprecationWarning_.
500
501 * Changes that may affect end-users (e.g. by requiring changes to the
502 configuration file or potentially breaking custom style sheets) should
503 be announced with a FutureWarning_.
504
505 .. _public API: ../eps/ep-010.html#public-api
506 .. _Sphinx: https://www.sphinx-doc.org/
507 .. _DeprecationWarning:
508 https://docs.python.org/3/library/exceptions.html#DeprecationWarning
509 .. _PendingDeprecationWarning:
510 https://docs.python.org/3/library/exceptions.html#PendingDeprecationWarning
511 .. _FutureWarning:
512 https://docs.python.org/3/library/exceptions.html#FutureWarning
513
514
515 Snapshots
516 =========
517
518 Snapshot tarballs can be downloaded from the repository (see the "download
519 snapshot" button in the head of the code listing table).
520
521 * the `Docutils core`_, representing the current cutting-edge state of
522 development;
523
524 * the `sandbox directory`_ with contributed projects and extensions from
525 `the Sandbox`_;
526
527 .. * maintenance branches, for bug fixes;
528
529 TODO: do we have active maintenance branches?
530 (the only branch looking like a maintenance branch is
531 https://sourceforge.net/p/docutils/code/HEAD/tree/branches/docutils-0.4)
532
533 * `development branches`_, representing ongoing development efforts to bring
534 new features into Docutils.
535
536 .. _Docutils core:
537 https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils
538 .. _development branches:
539 https://sourceforge.net/p/docutils/code/HEAD/tree/branches/
540
541
542 Setting Up For Docutils Development
543 ===================================
544
545 When making changes to the code, testing_ is a must. The code should
546 be run to verify that it produces the expected results, and the entire
547 test suite should be run too. The modified Docutils code has to be
548 accessible to Python for the tests to have any meaning.
549 See `editable installs`_ for ways to keep the Docutils code
550 accessible during development.
551
552 .. _testing: tested_
553 .. _editable installs: repository.html#editable-installs
554
555
556 Mailing Lists
557 =============
558
559 Developers are recommended to subscribe to all `Docutils mailing
560 lists`_.
561
562 .. _Docutils mailing lists: ../user/mailing-lists.html
563
564
565 .. The Wiki
566 ========
567
568 The development wiki at http://docutils.python-hosting.com/
569 is no longer active.
570
571
572 Extensions and Related Projects
573 ===============================
574
575 The Sandbox
576 -----------
577
578 The `sandbox directory`_ is a place to play around, to try out and
579 share ideas. It's a part of the Subversion repository but it isn't
580 distributed as part of Docutils releases. Feel free to check in code
581 to the sandbox; that way people can try it out but you won't have to
582 worry about it working 100% error-free, as is the goal of the Docutils
583 core. A project-specific subdirectory should be created for each new
584 project. Any developer who wants to play in the sandbox may do so,
585 but project directories are recommended over personal directories,
586 which discourage collaboration. It's OK to make a mess in the
587 sandbox! But please, play nice.
588
589 Please update the `sandbox README`_ file with links and a brief
590 description of your work.
591
592 In order to minimize the work necessary for others to install and try
593 out new, experimental components, the following sandbox directory
594 structure is recommended::
595
596 sandbox/
597 project_name/ # For a collaborative project.
598 README.rst # Describe the requirements, purpose/goals, usage,
599 # and list the maintainers.
600 docs/
601 ...
602 component.py # The component is a single module.
603 # *OR* (but *not* both)
604 component/ # The component is a package.
605 __init__.py # Contains the Reader/Writer class.
606 other1.py # Other modules and data files used
607 data.rst # by this component.
608 ...
609 test/ # Test suite.
610 ...
611 tools/ # For front ends etc.
612 ...
613 pyproject.toml # Project metadata
614 userid/ # For *temporary* personal space.
615
616 Some sandbox projects are destined to move to the Docutils core once
617 completed. Others, such as add-ons to Docutils or applications of
618 Docutils, may graduate to become `parallel projects`_.
619
620 .. _sandbox README: https://docutils.sourceforge.io/sandbox/README.html
621 .. _sandbox directory:
622 https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/sandbox/
623
624
625 .. _parallel project:
626
627 Parallel Projects
628 -----------------
629
630 Parallel projects contain useful code that is not central to the
631 functioning of Docutils. Examples are specialized add-ons or
632 plug-ins, and applications of Docutils. They use Docutils, but
633 Docutils does not require their presence to function.
634
635 An official parallel project will have its own directory beside (or
636 parallel to) the main ``docutils`` directory in the Subversion
637 repository. It can have its own web page in the
638 docutils.sourceforge.io domain, its own file releases and
639 downloadable snapshots, and even a mailing list if that proves useful.
640 However, an official parallel project has implications: it is expected
641 to be maintained and continue to work with changes to the core
642 Docutils.
643
644 A parallel project requires a project leader, who must commit to
645 coordinate and maintain the implementation:
646
647 * Answer questions from users and developers.
648 * Review suggestions, bug reports, and patches.
649 * Monitor changes and ensure the quality of the code and
650 documentation.
651 * Coordinate with Docutils to ensure interoperability.
652 * Put together official project releases.
653
654 Of course, related projects may be created independently of Docutils.
655 The advantage of a parallel project is that the SourceForge
656 environment and the developer and user communities are already
657 established. Core Docutils developers are available for consultation
658 and may contribute to the parallel project. It's easier to keep the
659 projects in sync when there are changes made to the core Docutils
660 code.
661
662 Other related projects
663 ----------------------
664
665 Many related but independent projects are listed in the Docutils
666 `link list`_. If you want your project to appear there, drop a note at
667 the Docutils-develop_ mailing list.
668
669 .. _link list: https://docutils.sourceforge.io/docs/user/links.html
670 .. _docutils-develop: docs/user/mailing-lists.html#docutils-develop
671
672 .. Emacs settings
673
674 Local Variables:
675 mode: indented-text
676 mode: rst
677 indent-tabs-mode: nil
678 sentence-end-double-space: t
679 fill-column: 70
680 End: