Added "How to get a new feature into Docutils".
[docutils.git] / docs / dev / policies.txt
blob03dc50e184ba687b569270f07c7753753fb74881
1 ===========================
2  Docutils Project Policies
3 ===========================
5 :Author: David Goodger; open to all Docutils developers
6 :Contact: docutils-develop@lists.sourceforge.net
7 :Date: $Date$
8 :Revision: $Revision$
9 :Copyright: This document has been placed in the public domain.
11 .. contents::
13 The Docutils project group is a meritocracy based on code contribution
14 and lots of discussion [#bcs]_.  A few quotes sum up the policies of
15 the Docutils project.  The IETF's classic credo (by MIT professor Dave
16 Clark) is an ideal we can aspire to:
18     We reject: kings, presidents, and voting.  We believe in: rough
19     consensus and running code.
21 As architect, chief cook and bottle-washer, David Goodger currently
22 functions as BDFN (Benevolent Dictator For Now).  (But he would
23 happily abdicate the throne given a suitable candidate.  Any takers?)
25 Eric S. Raymond, anthropologist of the hacker subculture, writes in
26 his essay `The Magic Cauldron`_:
28     The number of contributors [to] projects is strongly and inversely
29     correlated with the number of hoops each project makes a user go
30     through to contribute.
32 We will endeavour to keep the barrier to entry as low as possible.
33 The policies below should not be thought of as barriers, but merely as
34 a codification of experience to date.  These are "best practices";
35 guidelines, not absolutes.  Exceptions are expected, tolerated, and
36 used as a source of improvement.  Feedback and criticism is welcome.
38 As for control issues, Emmett Plant (CEO of the Xiph.org Foundation,
39 originators of Ogg Vorbis) put it well when he said:
41     Open source dictates that you lose a certain amount of control
42     over your codebase, and that's okay with us.
44 .. [#bcs] Phrase borrowed from `Ben Collins-Sussman of the Subversion
45    project <http://www.red-bean.com/sussman/svn-anti-fud.html>`__.
47 .. _The Magic Cauldron:
48    http://www.catb.org/~esr/writings/magic-cauldron/
51 How to get a new feature into Docutils
52 ========================================
54 Question:
55    I would very much like to have this new feature in the Docutils core.
56    What exactly do I have to do to make this possible?
58 * Present your idea at the Docutils-develop_ mailing list,
60   +1  usually triggers a fast response,
61   -1  may be forgotten later,
63   and/or file a feature request at the `docutils tracker`_
65   +1  there is a permanent record,
66   -1  it may stay forgotten among all the other feature requests.
69 * Convince a Docutils developer that this is a valuable addition worth the
70   effort.
72 * Contribute. The developers will make sure that the contribution fits
73   nicely into Docutils (cf. the `review criteria`_). This might involve
74   discussing (and compromising on) design and implementation details. It
75   might also lead to the conclusion that the addition fits better in `the
76   sandbox`_ than in the Docutils core.
78 * Be patient, and be persistent.  None of us are paid to do this,
79   it's all in our spare time -- which is precious and rare.
81 How to make code contributions that are easily accepted:
83 * Have a look at the `Python coding conventions`_ and `documentation
84   conventions`_ below.
86 * **Prepare test cases.** This vastly helps when integrating new code. Test
87   cases are also examples and showcases for new features. See `Docutils
88   Testing`_ for a description of the test suite in ``docutils/test/``.
90   Ensure the addition works with all supported Python versions
91   (2.3 ... 3.2).
93 * Look at the Docutils sources to see how similar features are implemented,
94   learn to do it "the Docutils way".
96 * Prepare the a patch or an addition to the existing documentation.
97   Include links.
99 * If you are familiar with version control, consider creating a `feature
100   branch`_ in a Docutils repository_ checkout. (Working with branches is
101   *much* easier with git_. You can get a git clone of the repository from
102   http://repo.or.cz/w/docutils.git or with git-svn.)
104 .. _docutils-develop: ../user/mailing-lists.html#docutils-develop
105 .. _docutils tracker: http://sourceforge.net/tracker/?group_id=38414
106 .. _git: http://git-scm.com/
107 .. _Docutils testing: testing.html
110 Python Coding Conventions
111 =========================
113 Contributed code will not be refused merely because it does not
114 strictly adhere to these conditions; as long as it's internally
115 consistent, clean, and correct, it probably will be accepted.  But
116 don't be surprised if the "offending" code gets fiddled over time to
117 conform to these conventions.
119 The Docutils project shall follow the generic coding conventions as
120 specified in the `Style Guide for Python Code`_ and `Docstring
121 Conventions`_ PEPs, summarized, clarified, and extended as follows:
123 * 4 spaces per indentation level.  No hard tabs.
125 * Use only 7-bit ASCII, no 8-bit strings.  See `Docutils
126   Internationalization`_.
128 * No one-liner compound statements (i.e., no ``if x: return``: use two
129   lines & indentation), except for degenerate class or method
130   definitions (i.e., ``class X: pass`` is OK.).
132 * Lines should be no more than 78 characters long.
134 * Use "StudlyCaps" for class names (except for element classes in
135   docutils.nodes).
137 * Use "lowercase" or "lowercase_with_underscores" for function,
138   method, and variable names.  For short names, maximum two words,
139   joined lowercase may be used (e.g. "tagname").  For long names with
140   three or more words, or where it's hard to parse the split between
141   two words, use lowercase_with_underscores (e.g.,
142   "note_explicit_target", "explicit_target").  If in doubt, use
143   underscores.
145 * Avoid lambda expressions, which are inherently difficult to
146   understand.  Named functions are preferable and superior: they're
147   faster (no run-time compilation), and well-chosen names serve to
148   document and aid understanding.
150 * Avoid functional constructs (filter, map, etc.).  Use list
151   comprehensions instead.
153 * Avoid ``from __future__ import`` constructs.  They are inappropriate
154   for production code.
156 * Use 'single quotes' for string literals, and """triple double
157   quotes""" for docstrings.
159 .. _Style Guide for Python Code:
160    http://www.python.org/peps/pep-0008.html
161 .. _Docstring Conventions: http://www.python.org/peps/pep-0257.html
162 .. _Docutils Internationalization: ../howto/i18n.html#python-code
165 Documentation Conventions
166 =========================
168 * Docutils documentation is written using reStructuredText, of course.
170 * Use 7-bit ASCII if at all possible, and Unicode substitutions when
171   necessary.
173 * Use the following section title adornment styles::
175       ================
176        Document Title
177       ================
179       --------------------------------------------
180        Document Subtitle, or Major Division Title
181       --------------------------------------------
183       Section
184       =======
186       Subsection
187       ----------
189       Sub-Subsection
190       ``````````````
192       Sub-Sub-Subsection
193       ..................
195 * Use two blank lines before each section/subsection/etc. title.  One
196   blank line is sufficient between immediately adjacent titles.
198 * Add a bibliographic field list immediately after the document
199   title/subtitle.  See the beginning of this document for an example.
201 * Add an Emacs "local variables" block in a comment at the end of the
202   document.  See the end of this document for an example.
205 Copyrights and Licensing
206 ========================
208 The majority of the Docutils project code and documentation has been
209 placed in the public domain.  Unless clearly and explicitly indicated
210 otherwise, any patches (modifications to existing files) submitted to
211 the project for inclusion (via Subversion, SourceForge trackers,
212 mailing lists, or private email) are assumed to be in the public
213 domain as well.
215 Any new files contributed to the project should clearly state their
216 intentions regarding copyright, in one of the following ways:
218 * Public domain (preferred): include the statement "This
219   module/document has been placed in the public domain."
221 * Copyright & open source license: include a copyright notice, along
222   with either an embedded license statement, a reference to an
223   accompanying license file, or a license URL.
225   The license should be well known, simple and compatible with other
226   open source software licenses. To keep the number of different
227   licenses at a minimum, using the `2-Clause BSD license`_
228   (also known as "Simplified" or `FreeBSD license`_) is recommended.
230   .. _2-Clause BSD license: http://www.opensource.org/licenses/BSD-2-Clause
231   .. _FreeBSD license:  http://www.freebsd.org/copyright/freebsd-license.html
235   The following licenses are described as simple
236   and permissible on `Various Licenses and Comments about Them`_ by
237   the GNU Project and listed as popular in `OSI Approved Licenses`_:
239   Expat License / MIT License
241     http://www.jclark.com/xml/copying.txt
242     http://www.opensource.org/licenses/MIT
243     http://www.spdx.org/licenses/MIT
245     The term MIT License is ambiguous and may accurately refer to the
246     Expat license or the X11 license
247     [http://en.wikipedia.org/wiki/MIT_License]
249     -1  called `MIT license` by OSI and in the
250         `SPDX Open Source License Registry`_
251         but `Expat license` by GNU
253   2-Clause BSD license / FreeBSD license
255     http://www.freebsd.org/copyright/freebsd-license.html
256     http://www.opensource.org/licenses/BSD-2-Clause
257     http://www.spdx.org/licenses/BSD-2-Clause
259       If you want a simple, permissive non-copyleft free software
260       license, the FreeBSD license is a reasonable choice. However,
261       please don't call it a “BSD” or “BSD-style” license, because
262       that is likely to cause confusion which could lead to use of the
263       flawed original BSD license.
265       -- `Various Licenses and Comments about Them`_
267      +1  license used by the closely related Sphinx project
268      +1  "2-Clause BSD license" is a non-ambiguous name,
269          used by both, OSI and GNU.
270      +1  clear wording, structured text
272   .. _Various Licenses and Comments about Them:
273      http://www.gnu.org/licenses/license-list.html
274   .. _OSI Approved Licenses: http://www.opensource.org/licenses/category
275   .. _SPDX Open Source License Registry: http://www.spdx.org/licenses/
276   .. _pypi: http://pypi.python.org/pypi?:action=browse&c=54
279 .. _Subversion Repository:
281 Repository
282 ==========
284 Please see the `repository documentation`_ for details on how to
285 access Docutils' Subversion repository.  Anyone can access the
286 repository anonymously.  Only project developers can make changes.
287 (If you would like to become a project developer, just ask!)  Also see
288 `Setting Up For Docutils Development`_ below for some useful info.
290 Unless you really *really* know what you're doing, please do *not* use
291 ``svn import``.  It's quite easy to mess up the repository with an
292 import.
294 .. _repository documentation: repository.html
297 Branches
298 --------
300 (These branch policies go into effect with Docutils 0.4.)
302 The "docutils" directory of the **trunk** (a.k.a. the **Docutils
303 core**) is used for active -- but stable, fully tested, and reviewed
304 -- development.
306 There will be at least one active **maintenance branch** at a time,
307 based on at least the latest feature release.  For example, when
308 Docutils 0.5 is released, its maintenance branch will take over, and
309 the 0.4.x maintenance branch may be retired.  Maintenance branches
310 will receive bug fixes only; no new features will be allowed here.
312 Obvious and uncontroversial bug fixes *with tests* can be checked in
313 directly to the core and to the maintenance branches.  Don't forget to
314 add test cases!  Many (but not all) bug fixes will be applicable both
315 to the core and to the maintenance branches; these should be applied
316 to both.  No patches or dedicated branches are required for bug fixes,
317 but they may be used.  It is up to the discretion of project
318 developers to decide which mechanism to use for each case.
320 .. _feature branches:
321 .. _feature branch:
323 Feature additions and API changes will be done in **feature
324 branches**.  Feature branches will not be managed in any way.
325 Frequent small checkins are encouraged here.  Feature branches must be
326 discussed on the `docutils-develop mailing list`_ and reviewed before
327 being merged into the core.
329 .. _docutils-develop mailing list:
330    http://lists.sourceforge.net/lists/listinfo/docutils-develop
333 Review Criteria
334 ```````````````
336 Before a new feature, an API change, or a complex, disruptive, or
337 controversial bug fix can be checked in to the core or into a
338 maintenance branch, it must undergo review.  These are the criteria:
340 * The branch must be complete, and include full documentation and
341   tests.
343 * There should ideally be one branch merge commit per feature or
344   change.  In other words, each branch merge should represent a
345   coherent change set.
347 * The code must be stable and uncontroversial.  Moving targets and
348   features under debate are not ready to be merged.
350 * The code must work.  The test suite must complete with no failures.
351   See `Docutils Testing`_.
353 The review process will ensure that at least one other set of eyeballs
354 & brains sees the code before it enters the core.  In addition to the
355 above, the general `Check-ins`_ policy (below) also applies.
358 Check-ins
359 ---------
361 Changes or additions to the Docutils core and maintenance branches
362 carry a commitment to the Docutils user community.  Developers must be
363 prepared to fix and maintain any code they have committed.
365 The Docutils core (``trunk/docutils`` directory) and maintenance
366 branches should always be kept in a stable state (usable and as
367 problem-free as possible).  All changes to the Docutils core or
368 maintenance branches must be in `good shape`_, usable_, documented_,
369 tested_, and `reasonably complete`_.
371 * _`Good shape` means that the code is clean, readable, and free of
372   junk code (unused legacy code; by analogy to "junk DNA").
374 * _`Usable` means that the code does what it claims to do.  An "XYZ
375   Writer" should produce reasonable XYZ output.
377 * _`Documented`: The more complete the documentation the better.
378   Modules & files must be at least minimally documented internally.
379   `Docutils Front-End Tools`_ should have a new section for any
380   front-end tool that is added.  `Docutils Configuration Files`_
381   should be modified with any settings/options defined.  For any
382   non-trivial change, the HISTORY.txt_ file should be updated.
384 * _`Tested` means that unit and/or functional tests, that catch all
385   bugs fixed and/or cover all new functionality, have been added to
386   the test suite.  These tests must be checked by running the test
387   suite under all supported Python versions, and the entire test suite
388   must pass.  See `Docutils Testing`_.
390 * _`Reasonably complete` means that the code must handle all input.
391   Here "handle" means that no input can cause the code to fail (cause
392   an exception, or silently and incorrectly produce nothing).
393   "Reasonably complete" does not mean "finished" (no work left to be
394   done).  For example, a writer must handle every standard element
395   from the Docutils document model; for unimplemented elements, it
396   must *at the very least* warn that "Output for element X is not yet
397   implemented in writer Y".
399 If you really want to check code directly into the Docutils core,
400 you can, but you must ensure that it fulfills the above criteria
401 first.  People will start to use it and they will expect it to work!
402 If there are any issues with your code, or if you only have time for
403 gradual development, you should put it on a branch or in the sandbox
404 first.  It's easy to move code over to the Docutils core once it's
405 complete.
407 It is the responsibility and obligation of all developers to keep the
408 Docutils core and maintenance branches stable.  If a commit is made to
409 the core or maintenance branch which breaks any test, the solution is
410 simply to revert the change.  This is not vindictive; it's practical.
411 We revert first, and discuss later.
413 Docutils will pursue an open and trusting policy for as long as
414 possible, and deal with any aberrations if (and hopefully not when)
415 they happen.  We'd rather see a torrent of loose contributions than
416 just a trickle of perfect-as-they-stand changes.  The occasional
417 mistake is easy to fix.  That's what Subversion is for!
419 .. _Docutils Front-End Tools: ../user/tools.html
420 .. _Docutils Configuration Files: ../user/config.html
421 .. _HISTORY.txt: ../../HISTORY.txt
424 Version Numbering
425 =================
427 Docutils version numbering uses a ``major.minor.micro`` scheme (x.y.z;
428 for example, 0.4.1).
430 **Major releases** (x.0, e.g. 1.0) will be rare, and will represent
431 major changes in API, functionality, or commitment.  For example, as
432 long as the major version of Docutils is 0, it is to be considered
433 *experimental code*.  When Docutils reaches version 1.0, the major
434 APIs will be considered frozen and backward compatibility will become
435 of paramount importance.
437 Releases that change the minor number (x.y, e.g. 0.5) will be
438 **feature releases**; new features from the `Docutils core`_ will be
439 included.
441 Releases that change the micro number (x.y.z, e.g. 0.4.1) will be
442 **bug-fix releases**.  No new features will be introduced in these
443 releases; only bug fixes off of `maintenance branches`_ will be
444 included.
446 This policy was adopted in October 2005, and will take effect with
447 Docutils version 0.4.  Prior to version 0.4, Docutils didn't have an
448 official version numbering policy, and micro releases contained both
449 bug fixes and new features.
451 .. _Docutils core:
452    http://docutils.svn.sourceforge.net/viewvc/docutils/trunk/docutils/
453 .. _maintenance branches:
454    http://docutils.svn.sourceforge.net/viewvc/docutils/branches/
457 Snapshots
458 =========
460 Snapshot tarballs will be generated regularly from
462 * the Docutils core, representing the current cutting-edge state of
463   development;
465 * each active maintenance branch, for bug fixes;
467 * each development branch, representing the unstable
468   seat-of-your-pants bleeding edge.
470 The ``sandbox/infrastructure/docutils-update`` shell script, run as an
471 hourly cron job on the BerliOS server, is responsible for
472 automatically generating the snapshots and updating the web site.  See
473 the `web site docs <website.html>`__.
476 Setting Up For Docutils Development
477 ===================================
479 When making changes to the code, testing is a must.  The code should
480 be run to verify that it produces the expected results, and the entire
481 test suite should be run too.  The modified Docutils code has to be
482 accessible to Python for the tests to have any meaning.  There are two
483 ways to keep the Docutils code accessible during development:
485 1. Update your ``PYTHONPATH`` environment variable so that Python
486    picks up your local working copy of the code.  This is the
487    recommended method.
489    We'll assume that the Docutils trunk is checked out under your
490    ~/projects/ directory as follows::
492        svn co https://<user>@docutils.svn.sourceforge.net/svnroot/docutils/trunk \
493            docutils
495    For the bash shell, add this to your ``~/.profile``::
497        PYTHONPATH=$HOME/projects/docutils/docutils
498        PYTHONPATH=$PYTHONPATH:$HOME/projects/docutils/docutils/extras
499        export PYTHONPATH
501    The first line points to the directory containing the ``docutils``
502    package.  The second line adds the directory containing the
503    third-party modules Docutils depends on.  The third line exports
504    this environment variable.  You may also wish to add the ``tools``
505    directory to your ``PATH``::
507        PATH=$PATH:$HOME/projects/docutils/docutils/tools
508        export PATH
510 2. Before you run anything, every time you make a change, reinstall
511    Docutils::
513        python setup.py install
515    .. CAUTION::
517       This method is **not** recommended for day-to-day development;
518       it's too easy to forget.  Confusion inevitably ensues.
520       If you install Docutils this way, Python will always pick up the
521       last-installed copy of the code.  If you ever forget to
522       reinstall the "docutils" package, Python won't see your latest
523       changes.
525 A useful addition to the ``docutils`` top-level directory in branches
526 and alternate copies of the code is a ``set-PATHS`` file
527 containing the following lines::
529     # source this file
530     export PYTHONPATH=$PWD:$PWD/extras
531     export PATH=$PWD/tools:$PATH
533 Open a shell for this branch, ``cd`` to the ``docutils`` top-level
534 directory, and "source" this file.  For example, using the bash
535 shell::
537     $ cd some-branch/docutils
538     $ . set-PATHS
541 Mailing Lists
542 =============
544 Developers are recommended to subscribe to all `Docutils mailing
545 lists`_.
547 .. _Docutils mailing lists: ../user/mailing-lists.html
550 The Wiki
551 ========
553 There is a development wiki at http://docutils.python-hosting.com/ as
554 a scratchpad for transient notes.  Please use the repository for
555 permament document storage.
558 The Sandbox
559 ===========
561 The `sandbox directory`_ is a place to play around, to try out and
562 share ideas.  It's a part of the Subversion repository but it isn't
563 distributed as part of Docutils releases.  Feel free to check in code
564 to the sandbox; that way people can try it out but you won't have to
565 worry about it working 100% error-free, as is the goal of the Docutils
566 core.  A project-specific subdirectory should be created for each new
567 project.  Any developer who wants to play in the sandbox may do so,
568 but project directories are recommended over personal directories,
569 which discourage collaboration.  It's OK to make a mess in the
570 sandbox!  But please, play nice.
572 Please update the `sandbox README`_ file with links and a brief
573 description of your work.
575 In order to minimize the work necessary for others to install and try
576 out new, experimental components, the following sandbox directory
577 structure is recommended::
579     sandbox/
580         project_name/ # For a collaborative project.
581             README.txt  # Describe the requirements, purpose/goals, usage,
582                         # and list the maintainers.
583             docs/
584                 ...
585             component.py    # The component is a single module.
586                             # *OR* (but *not* both)
587             component/      # The component is a package.
588                 __init__.py  # Contains the Reader/Writer class.
589                 other1.py    # Other modules and data files used
590                 data.txt     # by this component.
591                 ...
592             test/       # Test suite.
593                 ...
594             tools/      # For front ends etc.
595                 ...
596             setup.py    # Use Distutils to install the component
597                         # code and tools/ files into the right
598                         # places in Docutils.
599         userid/       # For *temporary* personal space.
601 Some sandbox projects are destined to move to the Docutils core once
602 completed.  Others, such as add-ons to Docutils or applications of
603 Docutils, may graduate to become `parallel projects`_.
605 .. _sandbox README: http://docutils.sf.net/sandbox/README.html
606 .. _sandbox directory:
607    http://docutils.svn.sourceforge.net/viewvc/docutils/trunk/sandbox/
610 .. _parallel project:
612 Parallel Projects
613 =================
615 Parallel projects contain useful code that is not central to the
616 functioning of Docutils.  Examples are specialized add-ons or
617 plug-ins, and applications of Docutils.  They use Docutils, but
618 Docutils does not require their presence to function.
620 An official parallel project will have its own directory beside (or
621 parallel to) the main ``docutils`` directory in the Subversion
622 repository.  It can have its own web page in the
623 docutils.sourceforge.net domain, its own file releases and
624 downloadable snapshots, and even a mailing list if that proves useful.
625 However, an official parallel project has implications: it is expected
626 to be maintained and continue to work with changes to the core
627 Docutils.
629 A parallel project requires a project leader, who must commit to
630 coordinate and maintain the implementation:
632 * Answer questions from users and developers.
633 * Review suggestions, bug reports, and patches.
634 * Monitor changes and ensure the quality of the code and
635   documentation.
636 * Coordinate with Docutils to ensure interoperability.
637 * Put together official project releases.
639 Of course, related projects may be created independently of Docutils.
640 The advantage of a parallel project is that the SourceForge
641 environment and the developer and user communities are already
642 established.  Core Docutils developers are available for consultation
643 and may contribute to the parallel project.  It's easier to keep the
644 projects in sync when there are changes made to the core Docutils
645 code.
649    Local Variables:
650    mode: indented-text
651    indent-tabs-mode: nil
652    sentence-end-double-space: t
653    fill-column: 70
654    End: