@ -0,0 +1,137 @@ |
|||||||
|
================== |
||||||
|
Copying Docutils |
||||||
|
================== |
||||||
|
|
||||||
|
:Author: David Goodger |
||||||
|
:Contact: goodger@python.org |
||||||
|
:Date: $Date: 2015-05-08 17:56:32 +0200 (Fr, 08 Mai 2015) $ |
||||||
|
:Web site: http://docutils.sourceforge.net/ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
Most of the files included in this project have been placed in the |
||||||
|
public domain, and therefore have no license requirements and no |
||||||
|
restrictions on copying or usage; see the `Public Domain Dedication`_ |
||||||
|
below. There are a few exceptions_, listed below. |
||||||
|
Files in the Sandbox_ are not distributed with Docutils releases and |
||||||
|
may have different license terms. |
||||||
|
|
||||||
|
|
||||||
|
Public Domain Dedication |
||||||
|
======================== |
||||||
|
|
||||||
|
The persons who have associated their work with this project (the |
||||||
|
"Dedicator": David Goodger and the many contributors to the Docutils |
||||||
|
project) hereby dedicate the entire copyright, less the exceptions_ |
||||||
|
listed below, in the work of authorship known as "Docutils" identified |
||||||
|
below (the "Work") to the public domain. |
||||||
|
|
||||||
|
The primary repository for the Work is the Internet World Wide Web |
||||||
|
site <http://docutils.sourceforge.net/>. The Work consists of the |
||||||
|
files within the "docutils" module of the Docutils project Subversion |
||||||
|
repository (Internet host docutils.svn.sourceforge.net, filesystem path |
||||||
|
/svnroot/docutils), whose Internet web interface is located at |
||||||
|
<http://docutils.svn.sourceforge.net/viewvc/docutils/>. Files dedicated to the |
||||||
|
public domain may be identified by the inclusion, near the beginning |
||||||
|
of each file, of a declaration of the form:: |
||||||
|
|
||||||
|
Copyright: This document/module/DTD/stylesheet/file/etc. has been |
||||||
|
placed in the public domain. |
||||||
|
|
||||||
|
Dedicator makes this dedication for the benefit of the public at large |
||||||
|
and to the detriment of Dedicator's heirs and successors. Dedicator |
||||||
|
intends this dedication to be an overt act of relinquishment in |
||||||
|
perpetuity of all present and future rights under copyright law, |
||||||
|
whether vested or contingent, in the Work. Dedicator understands that |
||||||
|
such relinquishment of all rights includes the relinquishment of all |
||||||
|
rights to enforce (by lawsuit or otherwise) those copyrights in the |
||||||
|
Work. |
||||||
|
|
||||||
|
Dedicator recognizes that, once placed in the public domain, the Work |
||||||
|
may be freely reproduced, distributed, transmitted, used, modified, |
||||||
|
built upon, or otherwise exploited by anyone for any purpose, |
||||||
|
commercial or non-commercial, and in any way, including by methods |
||||||
|
that have not yet been invented or conceived. |
||||||
|
|
||||||
|
(This dedication is derived from the text of the `Creative Commons |
||||||
|
Public Domain Dedication`. [#]_) |
||||||
|
|
||||||
|
.. [#] Creative Commons has `retired this legal tool`__ and does not |
||||||
|
recommend that it be applied to works: This tool is based on United |
||||||
|
States law and may not be applicable outside the US. For dedicating new |
||||||
|
works to the public domain, Creative Commons recommend the replacement |
||||||
|
Public Domain Dedication CC0_ (CC zero, "No Rights Reserved"). So does |
||||||
|
the Free Software Foundation in its license-list_. |
||||||
|
|
||||||
|
__ http://creativecommons.org/retiredlicenses |
||||||
|
.. _CC0: http://creativecommons.org/about/cc0 |
||||||
|
|
||||||
|
Exceptions |
||||||
|
========== |
||||||
|
|
||||||
|
The exceptions to the `Public Domain Dedication`_ above are: |
||||||
|
|
||||||
|
* docutils/writers/s5_html/themes/default/iepngfix.htc: |
||||||
|
|
||||||
|
IE5.5+ PNG Alpha Fix v1.0 by Angus Turnbull |
||||||
|
<http://www.twinhelix.com>. Free usage permitted as long as |
||||||
|
this notice remains intact. |
||||||
|
|
||||||
|
* docutils/utils/math/__init__.py, |
||||||
|
docutils/utils/math/latex2mathml.py, |
||||||
|
docutils/writers/xetex/__init__.py, |
||||||
|
docutils/writers/latex2e/docutils-05-compat.sty, |
||||||
|
docs/user/docutils-05-compat.sty.txt, |
||||||
|
docutils/utils/error_reporting.py, |
||||||
|
docutils/test/transforms/test_smartquotes.py: |
||||||
|
|
||||||
|
Copyright © Günter Milde. |
||||||
|
Released under the terms of the `2-Clause BSD license`_ |
||||||
|
(`local copy <licenses/BSD-2-Clause.txt>`__). |
||||||
|
|
||||||
|
* docutils/utils/smartquotes.py |
||||||
|
|
||||||
|
Copyright © 2011 Günter Milde, |
||||||
|
based on `SmartyPants`_ © 2003 John Gruber |
||||||
|
(released under a 3-Clause BSD license included in the file) |
||||||
|
and smartypants.py © 2004, 2007 Chad Miller. |
||||||
|
Released under the terms of the `2-Clause BSD license`_ |
||||||
|
(`local copy <licenses/BSD-2-Clause.txt>`__). |
||||||
|
|
||||||
|
.. _SmartyPants: http://daringfireball.net/projects/smartypants/ |
||||||
|
|
||||||
|
* docutils/utils/math/math2html.py, |
||||||
|
docutils/writers/html4css1/math.css |
||||||
|
|
||||||
|
Copyright © Alex Fernández |
||||||
|
These files are part of eLyXer_, released under the `GNU |
||||||
|
General Public License`_ version 3 or later. The author relicensed |
||||||
|
them for Docutils under the terms of the `2-Clause BSD license`_ |
||||||
|
(`local copy <licenses/BSD-2-Clause.txt>`__). |
||||||
|
|
||||||
|
.. _eLyXer: http://www.nongnu.org/elyxer/ |
||||||
|
|
||||||
|
* docutils/utils/roman.py, copyright by Mark Pilgrim, released under the |
||||||
|
`Python 2.1.1 license`_ (`local copy`__). |
||||||
|
|
||||||
|
__ licenses/python-2-1-1.txt |
||||||
|
|
||||||
|
* tools/editors/emacs/rst.el, copyright by Free Software Foundation, |
||||||
|
Inc., released under the `GNU General Public License`_ version 3 or |
||||||
|
later (`local copy`__). |
||||||
|
|
||||||
|
__ licenses/gpl-3-0.txt |
||||||
|
|
||||||
|
The `2-Clause BSD license`_ and the Python licenses are OSI-approved_ |
||||||
|
and GPL-compatible_. |
||||||
|
|
||||||
|
Plaintext versions of all the linked-to licenses are provided in the |
||||||
|
licenses_ directory. |
||||||
|
|
||||||
|
.. _sandbox: http://docutils.sourceforge.net/sandbox/README.html |
||||||
|
.. _licenses: licenses/ |
||||||
|
.. _Python 2.1.1 license: http://www.python.org/2.1.1/license.html |
||||||
|
.. _GNU General Public License: http://www.gnu.org/copyleft/gpl.html |
||||||
|
.. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause |
||||||
|
.. _OSI-approved: http://opensource.org/licenses/ |
||||||
|
.. _license-list: |
||||||
|
.. _GPL-compatible: http://www.gnu.org/licenses/license-list.html |
@ -0,0 +1,11 @@ |
|||||||
|
include *.txt |
||||||
|
include *.py |
||||||
|
include setup.cfg |
||||||
|
include MANIFEST |
||||||
|
include MANIFEST.in |
||||||
|
recursive-include docutils * |
||||||
|
recursive-include docs * |
||||||
|
recursive-include licenses * |
||||||
|
recursive-include test * |
||||||
|
recursive-include tools * |
||||||
|
recursive-exclude * *.pyc *~ .DS_Store |
@ -0,0 +1,169 @@ |
|||||||
|
.. -*- coding: utf-8 -*- |
||||||
|
|
||||||
|
Acknowledgements |
||||||
|
================ |
||||||
|
|
||||||
|
:Author: David Goodger |
||||||
|
:Contact: goodger@python.org |
||||||
|
:Date: $Date: 2015-02-09 00:21:18 +0100 (Mo, 09 Feb 2015) $ |
||||||
|
:Revision: $Revision: 7784 $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
I would like to acknowledge the people who have made a direct impact |
||||||
|
on the Docutils project, knowingly or not, in terms of encouragement, |
||||||
|
suggestions, criticism, bug reports, code contributions, cash |
||||||
|
donations, tasty treats, and related projects: |
||||||
|
|
||||||
|
* Aahz |
||||||
|
* David Abrahams |
||||||
|
* Guy D. Alcos |
||||||
|
* David Ascher |
||||||
|
* Ned Batchelder |
||||||
|
* Heiko Baumann |
||||||
|
* Anthony Baxter |
||||||
|
* Eric Bellot |
||||||
|
* Frank Bennett |
||||||
|
* Ian Bicking |
||||||
|
* Marek Blaha |
||||||
|
* Martin Blais |
||||||
|
* Stephen Boulet |
||||||
|
* Fred Bremmer |
||||||
|
* Simon Budig |
||||||
|
* Bill Bumgarner |
||||||
|
* Brett Cannon |
||||||
|
* Greg Chapman |
||||||
|
* Nicolas Chauveau |
||||||
|
* Beni Cherniavsky |
||||||
|
* Adam Chodorowski |
||||||
|
* Brent Cook |
||||||
|
* Laura Creighton |
||||||
|
* Artur de Sousa Rocha |
||||||
|
* Stephan Deibel & `Wing IDE <http://wingide.com/>`__ |
||||||
|
* Jason Diamond |
||||||
|
* William Dode |
||||||
|
* Fred Drake |
||||||
|
* Reggie Dugard |
||||||
|
* Dethe Elza |
||||||
|
* Marcus Ertl |
||||||
|
* Benja Fallenstein |
||||||
|
* fantasai |
||||||
|
* Stefane Fermigier |
||||||
|
* Michael Foord |
||||||
|
* Jim Fulton |
||||||
|
* Peter Funk |
||||||
|
* Lele Gaifax |
||||||
|
* Dinu C. Gherman |
||||||
|
* Matt Gilbert |
||||||
|
* Jorge Gonzalez |
||||||
|
* Engelbert Gruber |
||||||
|
* Jacob Hallen |
||||||
|
* Simon Hefti |
||||||
|
* Doug Hellmann |
||||||
|
* Marc Herbert |
||||||
|
* Juergen Hermann |
||||||
|
* Jannie Hofmeyr |
||||||
|
* Steve Holden |
||||||
|
* Michael Hudson |
||||||
|
* Marcelo Huerta San Martin |
||||||
|
* Ludger Humbert |
||||||
|
* Jeremy Hylton |
||||||
|
* Tony Ibbs |
||||||
|
* Alan G. Isaac |
||||||
|
* Alan Jaffray |
||||||
|
* Joe YS Jaw |
||||||
|
* Dmitry Jemerov |
||||||
|
* Richard Jones |
||||||
|
* Andreas Jung |
||||||
|
* Robert Kern |
||||||
|
* Garth Kidd |
||||||
|
* Philipp Knüsel |
||||||
|
* Axel Kollmorgen |
||||||
|
* Jeff Kowalczyk |
||||||
|
* Martin F. Krafft |
||||||
|
* Meir Kriheli |
||||||
|
* Dave Kuhlman |
||||||
|
* Lloyd Kvam |
||||||
|
* Kirill Lapshin |
||||||
|
* Nicola Larosa |
||||||
|
* Daniel Larsson |
||||||
|
* Marc-Andre Lemburg |
||||||
|
* Julien Letessier |
||||||
|
* Chris Liechti |
||||||
|
* Wolfgang Lipp |
||||||
|
* Edward Loper |
||||||
|
* Dallas Mahrt |
||||||
|
* Brecht Machiels |
||||||
|
* Mikolaj Machowski |
||||||
|
* Ken Manheimer |
||||||
|
* Bob Marshall |
||||||
|
* Mark McEahern |
||||||
|
* Vincent McIntyre |
||||||
|
* John F Meinel Jr |
||||||
|
* Ivan Mendez for Free Software Office of the University of A Coruña |
||||||
|
* Eric Meyer |
||||||
|
* Günter Milde |
||||||
|
* Skip Montanaro |
||||||
|
* Paul Moore |
||||||
|
* Nigel W. Moriarty |
||||||
|
* Hisashi Morita |
||||||
|
* Mark Nodine |
||||||
|
* Omidyar Network (Pierre Omidyar & Doug Solomon) |
||||||
|
* Panjunyong |
||||||
|
* Patrick K. O'Brien |
||||||
|
* Michel Pelletier |
||||||
|
* Toshio Kuratomi |
||||||
|
* Sam Penrose |
||||||
|
* Tim Peters |
||||||
|
* Pearu Peterson |
||||||
|
* Martijn Pieters |
||||||
|
* Mark Pilgrim |
||||||
|
* Brett g Porter |
||||||
|
* David Priest |
||||||
|
* Jens Quade |
||||||
|
* Stefan Rank |
||||||
|
* Edward K. Ream |
||||||
|
* Andy Robinson |
||||||
|
* Tavis Rudd |
||||||
|
* Tracy Ruggles |
||||||
|
* Oliver Rutherfurd |
||||||
|
* Luc Saffre |
||||||
|
* Seo Sanghyeon |
||||||
|
* Kenichi Sato |
||||||
|
* Ueli Schlaepfer |
||||||
|
* Gunnar Schwant |
||||||
|
* Bill Sconce |
||||||
|
* Frank Siebenlist |
||||||
|
* Bruce Smith |
||||||
|
* Nir Soffer |
||||||
|
* Asko Soukka |
||||||
|
* Darek Suchojad |
||||||
|
* Roman Suzi |
||||||
|
* Janet Swisher |
||||||
|
* tav |
||||||
|
* Kent Tenney |
||||||
|
* Bob Tolbert |
||||||
|
* Paul Tremblay |
||||||
|
* Laurence Tratt |
||||||
|
* Adrian van den Dries |
||||||
|
* Guido van Rossum |
||||||
|
* Miroslav Vasko |
||||||
|
* Paul Viren |
||||||
|
* Martin von Loewis |
||||||
|
* Greg Ward |
||||||
|
* Barry Warsaw |
||||||
|
* Wu Wei |
||||||
|
* Edward Welbourne |
||||||
|
* Lea Wiemann |
||||||
|
* Anthony Williams |
||||||
|
* Robert Wojciechowicz |
||||||
|
* Ka-Ping Yee |
||||||
|
* Moshe Zadka |
||||||
|
* Shmuel Zeigerman |
||||||
|
|
||||||
|
Thank you! |
||||||
|
|
||||||
|
Special thanks to `SourceForge <http://sourceforge.net>`__ and the |
||||||
|
`Python Software Foundation <http://www.python.org/psf/>`__. |
||||||
|
|
||||||
|
Hopefully I haven't forgotten anyone or misspelled any names; |
||||||
|
apologies (and please let me know!) if I have. |
@ -0,0 +1,66 @@ |
|||||||
|
=============================================== |
||||||
|
Inside A Docutils Command-Line Front-End Tool |
||||||
|
=============================================== |
||||||
|
|
||||||
|
:Author: David Goodger |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Date: $Date: 2012-01-03 20:23:53 +0100 (Di, 03 Jan 2012) $ |
||||||
|
:Revision: $Revision: 7302 $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
`The Docutils Publisher`_ class was set up to make building |
||||||
|
command-line tools easy. All that's required is to choose components |
||||||
|
and supply settings for variations. Let's take a look at a typical |
||||||
|
command-line front-end tool, ``tools/rst2html.py``, from top to |
||||||
|
bottom. |
||||||
|
|
||||||
|
On Unixish systems, it's best to make the file executable (``chmod +x |
||||||
|
file``), and supply an interpreter on the first line, the "shebang" or |
||||||
|
"hash-bang" line:: |
||||||
|
|
||||||
|
#!/usr/bin/env python |
||||||
|
|
||||||
|
Windows systems can be set up to associate the Python interpreter with |
||||||
|
the ``.py`` extension. |
||||||
|
|
||||||
|
Next are some comments providing metadata:: |
||||||
|
|
||||||
|
# $Id: cmdline-tool.txt 7302 2012-01-03 19:23:53Z grubert $ |
||||||
|
# Author: David Goodger <goodger@python.org> |
||||||
|
# Copyright: This module has been placed in the public domain. |
||||||
|
|
||||||
|
The module docstring describes the purpose of the tool:: |
||||||
|
|
||||||
|
""" |
||||||
|
A minimal front end to the Docutils Publisher, producing HTML. |
||||||
|
""" |
||||||
|
|
||||||
|
This next block attempts to invoke locale support for |
||||||
|
internationalization services, specifically text encoding. It's not |
||||||
|
supported on all platforms though, so it's forgiving:: |
||||||
|
|
||||||
|
try: |
||||||
|
import locale |
||||||
|
locale.setlocale(locale.LC_ALL, '') |
||||||
|
except: |
||||||
|
pass |
||||||
|
|
||||||
|
The real work will be done by the code that's imported here:: |
||||||
|
|
||||||
|
from docutils.core import publish_cmdline, default_description |
||||||
|
|
||||||
|
We construct a description of the tool, for command-line help:: |
||||||
|
|
||||||
|
description = ('Generates (X)HTML documents from standalone ' |
||||||
|
'reStructuredText sources. ' + default_description) |
||||||
|
|
||||||
|
Now we call the Publisher convenience function, which takes over. |
||||||
|
Most of its defaults are used ("standalone" Reader, |
||||||
|
"reStructuredText" Parser, etc.). The HTML Writer is chosen by name, |
||||||
|
and a description for command-line help is passed in:: |
||||||
|
|
||||||
|
publish_cmdline(writer_name='html', description=description) |
||||||
|
|
||||||
|
That's it! `The Docutils Publisher`_ takes care of the rest. |
||||||
|
|
||||||
|
.. _The Docutils Publisher: ./publisher.html |
@ -0,0 +1,344 @@ |
|||||||
|
======================== |
||||||
|
The Docutils Publisher |
||||||
|
======================== |
||||||
|
|
||||||
|
:Author: David Goodger |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Date: $Date: 2012-01-03 20:23:53 +0100 (Di, 03 Jan 2012) $ |
||||||
|
:Revision: $Revision: 7302 $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
|
||||||
|
The ``docutils.core.Publisher`` class is the core of Docutils, |
||||||
|
managing all the processing and relationships between components. See |
||||||
|
`PEP 258`_ for an overview of Docutils components. |
||||||
|
|
||||||
|
The ``docutils.core.publish_*`` convenience functions are the normal |
||||||
|
entry points for using Docutils as a library. |
||||||
|
|
||||||
|
See `Inside A Docutils Command-Line Front-End Tool`_ for an overview |
||||||
|
of a typical Docutils front-end tool, including how the Publisher |
||||||
|
class is used. |
||||||
|
|
||||||
|
.. _PEP 258: ../peps/pep-0258.html |
||||||
|
.. _Inside A Docutils Command-Line Front-End Tool: ./cmdline-tool.html |
||||||
|
|
||||||
|
|
||||||
|
Publisher Convenience Functions |
||||||
|
=============================== |
||||||
|
|
||||||
|
Each of these functions set up a ``docutils.core.Publisher`` object, |
||||||
|
then call its ``publish`` method. ``docutils.core.Publisher.publish`` |
||||||
|
handles everything else. There are several convenience functions in |
||||||
|
the ``docutils.core`` module: |
||||||
|
|
||||||
|
:_`publish_cmdline`: for command-line front-end tools, like |
||||||
|
``rst2html.py``. There are several examples in the ``tools/`` |
||||||
|
directory. A detailed analysis of one such tool is in `Inside A |
||||||
|
Docutils Command-Line Front-End Tool`_ |
||||||
|
|
||||||
|
:_`publish_file`: for programmatic use with file-like I/O. In |
||||||
|
addition to writing the encoded output to a file, also returns the |
||||||
|
encoded output as a string. |
||||||
|
|
||||||
|
:_`publish_string`: for programmatic use with string I/O. Returns |
||||||
|
the encoded output as a string. |
||||||
|
|
||||||
|
:_`publish_parts`: for programmatic use with string input; returns a |
||||||
|
dictionary of document parts. Dictionary keys are the names of |
||||||
|
parts, and values are Unicode strings; encoding is up to the client. |
||||||
|
Useful when only portions of the processed document are desired. |
||||||
|
See `publish_parts Details`_ below. |
||||||
|
|
||||||
|
There are usage examples in the `docutils/examples.py`_ module. |
||||||
|
|
||||||
|
:_`publish_doctree`: for programmatic use with string input; returns a |
||||||
|
Docutils document tree data structure (doctree). The doctree can be |
||||||
|
modified, pickled & unpickled, etc., and then reprocessed with |
||||||
|
`publish_from_doctree`_. |
||||||
|
|
||||||
|
:_`publish_from_doctree`: for programmatic use to render from an |
||||||
|
existing document tree data structure (doctree); returns the encoded |
||||||
|
output as a string. |
||||||
|
|
||||||
|
:_`publish_programmatically`: for custom programmatic use. This |
||||||
|
function implements common code and is used by ``publish_file``, |
||||||
|
``publish_string``, and ``publish_parts``. It returns a 2-tuple: |
||||||
|
the encoded string output and the Publisher object. |
||||||
|
|
||||||
|
.. _Inside A Docutils Command-Line Front-End Tool: ./cmdline-tool.html |
||||||
|
.. _docutils/examples.py: ../../docutils/examples.py |
||||||
|
|
||||||
|
|
||||||
|
Configuration |
||||||
|
------------- |
||||||
|
|
||||||
|
To pass application-specific setting defaults to the Publisher |
||||||
|
convenience functions, use the ``settings_overrides`` parameter. Pass |
||||||
|
a dictionary of setting names & values, like this:: |
||||||
|
|
||||||
|
overrides = {'input_encoding': 'ascii', |
||||||
|
'output_encoding': 'latin-1'} |
||||||
|
output = publish_string(..., settings_overrides=overrides) |
||||||
|
|
||||||
|
Settings from command-line options override configuration file |
||||||
|
settings, and they override application defaults. For details, see |
||||||
|
`Docutils Runtime Settings`_. See `Docutils Configuration Files`_ for |
||||||
|
details about individual settings. |
||||||
|
|
||||||
|
.. _Docutils Runtime Settings: ./runtime-settings.html |
||||||
|
.. _Docutils Configuration Files: ../user/tools.html |
||||||
|
|
||||||
|
|
||||||
|
Encodings |
||||||
|
--------- |
||||||
|
|
||||||
|
The default output encoding of Docutils is UTF-8. If you have any |
||||||
|
non-ASCII in your input text, you may have to do a bit more setup. |
||||||
|
Docutils may introduce some non-ASCII text if you use |
||||||
|
`auto-symbol footnotes`_ or the `"contents" directive`_. |
||||||
|
|
||||||
|
.. _auto-symbol footnotes: |
||||||
|
../ref/rst/restructuredtext.html#auto-symbol-footnotes |
||||||
|
.. _"contents" directive: |
||||||
|
../ref/rst/directives.html#table-of-contents |
||||||
|
|
||||||
|
|
||||||
|
``publish_parts`` Details |
||||||
|
========================= |
||||||
|
|
||||||
|
The ``docutils.core.publish_parts`` convenience function returns a |
||||||
|
dictionary of document parts. Dictionary keys are the names of parts, |
||||||
|
and values are Unicode strings. |
||||||
|
|
||||||
|
Each Writer component may publish a different set of document parts, |
||||||
|
described below. Not all writers implement all parts. |
||||||
|
|
||||||
|
|
||||||
|
Parts Provided By All Writers |
||||||
|
----------------------------- |
||||||
|
|
||||||
|
_`encoding` |
||||||
|
The output encoding setting. |
||||||
|
|
||||||
|
_`version` |
||||||
|
The version of Docutils used. |
||||||
|
|
||||||
|
_`whole` |
||||||
|
``parts['whole']`` contains the entire formatted document. |
||||||
|
|
||||||
|
|
||||||
|
.. _HTML writer: |
||||||
|
|
||||||
|
Parts Provided By the HTML Writer |
||||||
|
--------------------------------- |
||||||
|
|
||||||
|
_`body` |
||||||
|
``parts['body']`` is equivalent to parts['fragment_']. It is |
||||||
|
*not* equivalent to parts['html_body_']. |
||||||
|
|
||||||
|
_`body_prefix` |
||||||
|
``parts['body_prefix']`` contains:: |
||||||
|
|
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<div class="document" ...> |
||||||
|
|
||||||
|
and, if applicable:: |
||||||
|
|
||||||
|
<div class="header"> |
||||||
|
... |
||||||
|
</div> |
||||||
|
|
||||||
|
_`body_pre_docinfo` |
||||||
|
``parts['body_pre_docinfo]`` contains (as applicable):: |
||||||
|
|
||||||
|
<h1 class="title">...</h1> |
||||||
|
<h2 class="subtitle" id="...">...</h2> |
||||||
|
|
||||||
|
_`body_suffix` |
||||||
|
``parts['body_suffix']`` contains:: |
||||||
|
|
||||||
|
</div> |
||||||
|
|
||||||
|
(the end-tag for ``<div class="document">``), the footer division |
||||||
|
if applicable:: |
||||||
|
|
||||||
|
<div class="footer"> |
||||||
|
... |
||||||
|
</div> |
||||||
|
|
||||||
|
and:: |
||||||
|
|
||||||
|
</body> |
||||||
|
</html> |
||||||
|
|
||||||
|
_`docinfo` |
||||||
|
``parts['docinfo']`` contains the document bibliographic data, the |
||||||
|
docinfo field list rendered as a table. |
||||||
|
|
||||||
|
_`footer` |
||||||
|
``parts['footer']`` contains the document footer content, meant to |
||||||
|
appear at the bottom of a web page, or repeated at the bottom of |
||||||
|
every printed page. |
||||||
|
|
||||||
|
_`fragment` |
||||||
|
``parts['fragment']`` contains the document body (*not* the HTML |
||||||
|
``<body>``). In other words, it contains the entire document, |
||||||
|
less the document title, subtitle, docinfo, header, and footer. |
||||||
|
|
||||||
|
_`head` |
||||||
|
``parts['head']`` contains ``<meta ... />`` tags and the document |
||||||
|
``<title>...</title>``. |
||||||
|
|
||||||
|
_`head_prefix` |
||||||
|
``parts['head_prefix']`` contains the XML declaration, the DOCTYPE |
||||||
|
declaration, the ``<html ...>`` start tag and the ``<head>`` start |
||||||
|
tag. |
||||||
|
|
||||||
|
_`header` |
||||||
|
``parts['header']`` contains the document header content, meant to |
||||||
|
appear at the top of a web page, or repeated at the top of every |
||||||
|
printed page. |
||||||
|
|
||||||
|
_`html_body` |
||||||
|
``parts['html_body']`` contains the HTML ``<body>`` content, less |
||||||
|
the ``<body>`` and ``</body>`` tags themselves. |
||||||
|
|
||||||
|
_`html_head` |
||||||
|
``parts['html_head']`` contains the HTML ``<head>`` content, less |
||||||
|
the stylesheet link and the ``<head>`` and ``</head>`` tags |
||||||
|
themselves. Since ``publish_parts`` returns Unicode strings and |
||||||
|
does not know about the output encoding, the "Content-Type" meta |
||||||
|
tag's "charset" value is left unresolved, as "%s":: |
||||||
|
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=%s" /> |
||||||
|
|
||||||
|
The interpolation should be done by client code. |
||||||
|
|
||||||
|
_`html_prolog` |
||||||
|
``parts['html_prolog]`` contains the XML declaration and the |
||||||
|
doctype declaration. The XML declaration's "encoding" attribute's |
||||||
|
value is left unresolved, as "%s":: |
||||||
|
|
||||||
|
<?xml version="1.0" encoding="%s" ?> |
||||||
|
|
||||||
|
The interpolation should be done by client code. |
||||||
|
|
||||||
|
_`html_subtitle` |
||||||
|
``parts['html_subtitle']`` contains the document subtitle, |
||||||
|
including the enclosing ``<h2 class="subtitle">`` & ``</h2>`` |
||||||
|
tags. |
||||||
|
|
||||||
|
_`html_title` |
||||||
|
``parts['html_title']`` contains the document title, including the |
||||||
|
enclosing ``<h1 class="title">`` & ``</h1>`` tags. |
||||||
|
|
||||||
|
_`meta` |
||||||
|
``parts['meta']`` contains all ``<meta ... />`` tags. |
||||||
|
|
||||||
|
_`stylesheet` |
||||||
|
``parts['stylesheet']`` contains the embedded stylesheet or |
||||||
|
stylesheet link. |
||||||
|
|
||||||
|
_`subtitle` |
||||||
|
``parts['subtitle']`` contains the document subtitle text and any |
||||||
|
inline markup. It does not include the enclosing ``<h2>`` & |
||||||
|
``</h2>`` tags. |
||||||
|
|
||||||
|
_`title` |
||||||
|
``parts['title']`` contains the document title text and any inline |
||||||
|
markup. It does not include the enclosing ``<h1>`` & ``</h1>`` |
||||||
|
tags. |
||||||
|
|
||||||
|
|
||||||
|
Parts Provided by the PEP/HTML Writer |
||||||
|
````````````````````````````````````` |
||||||
|
|
||||||
|
The PEP/HTML writer provides the same parts as the `HTML writer`_, |
||||||
|
plus the following: |
||||||
|
|
||||||
|
_`pepnum` |
||||||
|
``parts['pepnum']`` contains |
||||||
|
|
||||||
|
|
||||||
|
Parts Provided by the S5/HTML Writer |
||||||
|
```````````````````````````````````` |
||||||
|
|
||||||
|
The S5/HTML writer provides the same parts as the `HTML writer`_. |
||||||
|
|
||||||
|
|
||||||
|
Parts Provided by the LaTeX2e Writer |
||||||
|
------------------------------------ |
||||||
|
|
||||||
|
See the template files for examples how these parts can be combined |
||||||
|
into a valid LaTeX document. |
||||||
|
|
||||||
|
abstract |
||||||
|
``parts['abstract']`` contains the formatted content of the |
||||||
|
'abstract' docinfo field. |
||||||
|
|
||||||
|
body |
||||||
|
``parts['body']`` contains the document's content. In other words, it |
||||||
|
contains the entire document, except the document title, subtitle, and |
||||||
|
docinfo. |
||||||
|
|
||||||
|
This part can be included into another LaTeX document body using the |
||||||
|
``\input{}`` command. |
||||||
|
|
||||||
|
body_pre_docinfo |
||||||
|
``parts['body_pre_docinfo]`` contains the ``\maketitle`` command. |
||||||
|
|
||||||
|
dedication |
||||||
|
``parts['dedication']`` contains the formatted content of the |
||||||
|
'dedication' docinfo field. |
||||||
|
|
||||||
|
docinfo |
||||||
|
``parts['docinfo']`` contains the document bibliographic data, the |
||||||
|
docinfo field list rendered as a table. |
||||||
|
|
||||||
|
With ``--use-latex-docinfo`` 'author', 'organization', 'contact', |
||||||
|
'address' and 'date' info is moved to titledata. |
||||||
|
|
||||||
|
'dedication' and 'abstract' are always moved to separate parts. |
||||||
|
|
||||||
|
fallbacks |
||||||
|
``parts['fallbacks']`` contains fallback definitions for |
||||||
|
Docutils-specific commands and environments. |
||||||
|
|
||||||
|
head_prefix |
||||||
|
``parts['head_prefix']`` contains the declaration of |
||||||
|
documentclass and document options. |
||||||
|
|
||||||
|
latex_preamble |
||||||
|
``parts['latex_preamble']`` contains the argument of the |
||||||
|
``--latex-preamble`` option. |
||||||
|
|
||||||
|
pdfsetup |
||||||
|
``parts['pdfsetup']`` contains the PDF properties |
||||||
|
("hyperref" package setup). |
||||||
|
|
||||||
|
requirements |
||||||
|
``parts['requirements']`` contains required packages and setup |
||||||
|
before the stylesheet inclusion. |
||||||
|
|
||||||
|
stylesheet |
||||||
|
``parts['stylesheet']`` contains the embedded stylesheet(s) or |
||||||
|
stylesheet loading command(s). |
||||||
|
|
||||||
|
subtitle |
||||||
|
``parts['subtitle']`` contains the document subtitle text and any |
||||||
|
inline markup. |
||||||
|
|
||||||
|
title |
||||||
|
``parts['title']`` contains the document title text and any inline |
||||||
|
markup. |
||||||
|
|
||||||
|
titledata |
||||||
|
``parts['titledata]`` contains the combined title data in |
||||||
|
``\title``, ``\author``, and ``\data`` macros. |
||||||
|
|
||||||
|
With ``--use-latex-docinfo``, this includes the 'author', |
||||||
|
'organization', 'contact', 'address' and 'date' docinfo items. |
@ -0,0 +1,192 @@ |
|||||||
|
=========================== |
||||||
|
Docutils Runtime Settings |
||||||
|
=========================== |
||||||
|
|
||||||
|
:Author: David Goodger |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Date: $Date: 2012-01-03 20:23:53 +0100 (Di, 03 Jan 2012) $ |
||||||
|
:Revision: $Revision: 7302 $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
|
||||||
|
Introduction |
||||||
|
============ |
||||||
|
|
||||||
|
Docutils runtime settings are assembled from several sources: |
||||||
|
component settings specifications, application settings |
||||||
|
specifications, configuration files, and command-line options. |
||||||
|
Docutils overlays default and explicitly specified values from these |
||||||
|
sources such that settings behave the way we want and expect them to |
||||||
|
behave. |
||||||
|
|
||||||
|
To understand how Docutils deals with runtime settings, the attributes |
||||||
|
and parameters involved must first be understood. Begin with the the |
||||||
|
docstrings of the attributes of the ``docutils.SettingsSpec`` base |
||||||
|
class (in the ``docutils/__init__.py`` module): |
||||||
|
|
||||||
|
* ``settings_spec`` |
||||||
|
* ``settings_defaults`` |
||||||
|
* ``settings_default_overrides`` |
||||||
|
* ``relative_path_settings`` |
||||||
|
* ``config_section`` |
||||||
|
* ``config_section_dependencies`` |
||||||
|
|
||||||
|
Next, several _`convenience function parameters` are also significant |
||||||
|
(described in the ``docutils.core.publish_programmatically`` function |
||||||
|
docstring): |
||||||
|
|
||||||
|
* The ``settings`` parameter is a runtime settings |
||||||
|
(``docutils.frontend.Values``) object which, if present, is assumed |
||||||
|
to be complete (it must include all runtime settings). Also, if the |
||||||
|
``settings`` parameter is present, no further runtime settings |
||||||
|
processing is done. In other words, the other parameters, described |
||||||
|
below, will have no effect. |
||||||
|
|
||||||
|
* ``settings_spec``, a `docutils.SettingsSpec` subclass or object, is |
||||||
|
treated like a fourth component (after the Parser, Reader, and |
||||||
|
Writer). In other words, it's the settings specification for the |
||||||
|
"Application" itself. |
||||||
|
|
||||||
|
* ``settings_overrides`` is a dictionary which will override the |
||||||
|
defaults of the components (from their settings specs). |
||||||
|
|
||||||
|
* ``config_section`` specifies the name of an application-specific |
||||||
|
configuration file section. |
||||||
|
|
||||||
|
|
||||||
|
.. _command-line tools: |
||||||
|
|
||||||
|
Runtime Settings Processing for Command-Line Tools |
||||||
|
================================================== |
||||||
|
|
||||||
|
Following along with the actual code is recommended. The |
||||||
|
``docutils/__init__.py``, ``docutils/core.py``, and |
||||||
|
``docutils.frontend.py`` modules are described. |
||||||
|
|
||||||
|
1. A command-line front-end tool imports and calls |
||||||
|
``docutils.core.publish_cmdline``. The relevant `convenience |
||||||
|
function parameters`_ are described above. |
||||||
|
|
||||||
|
2. ``docutils.core.publish_cmdline`` initializes a |
||||||
|
``docutils.core.Publisher`` object, then calls its ``publish`` |
||||||
|
method. |
||||||
|
|
||||||
|
3. The ``docutils.core.Publisher`` object's ``publish`` method checks |
||||||
|
its ``settings`` attribute to see if it's defined. If it is, no |
||||||
|
further runtime settings processing is done. |
||||||
|
|
||||||
|
If ``settings`` is not defined, ``self.process_command_line`` is |
||||||
|
called with the following relevant arguments: |
||||||
|
|
||||||
|
* ``settings_spec`` |
||||||
|
* ``config_section`` |
||||||
|
* ``settings_overrides`` (in the form of excess keyword |
||||||
|
arguments, collected in the ``defaults`` parameter) |
||||||
|
|
||||||
|
4. ``self.process_command_line`` calls ``self.setup_option_parser``, |
||||||
|
passing ``settings_spec``, ``config_section``, and ``defaults``. |
||||||
|
|
||||||
|
5. ``self.setup_option_parser`` checks its ``config_section`` |
||||||
|
parameter; if defined, it adds that config file section to |
||||||
|
``settings_spec`` (or to a new, empty ``docutils.SettingsSpec`` |
||||||
|
object), replacing anything defined earlier. (See `Docutils |
||||||
|
Configuration Files`_ for details.) Then it instantiates a new |
||||||
|
``docutils.frontend.OptionParser`` object, passing the following |
||||||
|
relevant arguments: |
||||||
|
|
||||||
|
* ``components``: A tuple of ``docutils.SettingsSpec`` objects, |
||||||
|
``(self.parser, self.reader, self.writer, settings_spec)`` |
||||||
|
* ``defaults`` (originally from ``settings_overrides``) |
||||||
|
|
||||||
|
6. The ``docutils.frontend.OptionParser`` object's ``__init__`` method |
||||||
|
calls ``self.populate_from_components`` with ``self.components``, |
||||||
|
which consists of ``self`` prepended to the ``components`` tuple it |
||||||
|
received. ``self`` (``docutils.frontend.OptionParser``) defines |
||||||
|
general Docutils settings. |
||||||
|
|
||||||
|
7. In ``self.populate_from_components``, for each component passed, |
||||||
|
``component.settings_spec`` is processed and |
||||||
|
``component.settings_defaults`` is applied. Then, for each |
||||||
|
component, ``component.settings_default_overrides`` is applied. |
||||||
|
This two-loop process ensures that |
||||||
|
``component.settings_default_overrides`` can override the default |
||||||
|
settings of any other component. |
||||||
|
|
||||||
|
8. Back in ``docutils.frontend.OptionParser.__init__``, the |
||||||
|
``defaults`` parameter (derived from the ``settings_overrides`` |
||||||
|
parameter of ``docutils.core.Publisher.publish``) is overlaid over |
||||||
|
``self.defaults``. So ``settings_overrides`` has priority over all |
||||||
|
``SettingsSpec`` data. |
||||||
|
|
||||||
|
9. Next, ``docutils.frontend.OptionParser.__init__`` checks if |
||||||
|
configuration files are enabled (its ``read_config_files`` |
||||||
|
parameter is true, and ``self.defaults['_disable_config']`` is |
||||||
|
false). If they are enabled (and normally, they are), |
||||||
|
``self.get_standard_config_settings`` is called. This reads the |
||||||
|
`docutils configuration files`_, and returns a dictionary of |
||||||
|
settings. This is then overlaid on ``self.defaults``. So |
||||||
|
configuration file settings have priority over all software-defined |
||||||
|
defaults. |
||||||
|
|
||||||
|
10. Back in the ``docutils.core.Publisher`` object, |
||||||
|
``self.setup_option_parser`` returns the ``option_parser`` object |
||||||
|
to its caller, ``self.process_command_line``. |
||||||
|
|
||||||
|
11. ``self.process_command_line`` calls ``option_parser.parse_args``, |
||||||
|
which parses all command line options and returns a |
||||||
|
``docutils.frontend.Values`` object. This is assigned to the |
||||||
|
``docutils.core.Publisher`` object's ``self.settings``. So |
||||||
|
command-line options have priority over configuration file |
||||||
|
settings. |
||||||
|
|
||||||
|
When ``option_parser.parse_args`` is called, the source and |
||||||
|
destination command-line arguments are also parsed, and assigned |
||||||
|
to the ``_source`` and ``_destination`` attributes of what becomes |
||||||
|
the ``docutils.core.Publisher`` object's ``self.settings``. |
||||||
|
|
||||||
|
12. From ``docutils.core.Publisher.publish``, ``self.set_io`` is |
||||||
|
called with no arguments. If either ``self.source`` or |
||||||
|
``self.destination`` are not set, the corresponding |
||||||
|
``self.set_source`` and ``self.set_destination`` are called, |
||||||
|
effectively with no arguments. |
||||||
|
|
||||||
|
13. ``self.set_source`` checks for a ``source_path`` parameter, and if |
||||||
|
there is none (which is the case for command-line use), it is |
||||||
|
taken from ``self.settings._source``. ``self.source`` is set by |
||||||
|
instantiating a ``self.source_class`` object. For command-line |
||||||
|
front-end tools, the default ``self.source_class`` is used, |
||||||
|
``docutils.io.FileInput``. |
||||||
|
|
||||||
|
14. ``self.set_destination`` does the same job for the destination |
||||||
|
that ``self.set_source`` does for the source (the default |
||||||
|
``self.destination_class`` is ``docutils.io.FileOutput``). |
||||||
|
|
||||||
|
.. _Docutils Configuration Files: ../user/config.html |
||||||
|
|
||||||
|
|
||||||
|
Runtime Settings Processing From Applications |
||||||
|
============================================= |
||||||
|
|
||||||
|
Applications process runtime settings in a different way than |
||||||
|
`command-line tools`_ do. Instead of calling ``publish_cmdline``, the |
||||||
|
application calls one of ``publish_file``, ``publish_string``, or |
||||||
|
``publish_parts``. These in turn call ``publish_programmatically``, |
||||||
|
which implements a generic programmatic interface. Although an |
||||||
|
application may also call ``publish_programmatically`` directly, it is |
||||||
|
not recommended (if it does seem to be necessary, please write to the |
||||||
|
Docutils-develop_ mailing list). |
||||||
|
|
||||||
|
``publish_programmatically`` accepts the same `convenience function |
||||||
|
parameters`_ as ``publish_cmdline``. Where things differ is that |
||||||
|
programmatic use does no command-line processing. Instead of calling |
||||||
|
``docutils.Publisher.process_command_line`` (as ``publish_cmdline`` |
||||||
|
does, via ``docutils.Publisher.publish``), |
||||||
|
``docutils.Publisher.process_programmatic_settings`` is called to set |
||||||
|
up the runtime settings. |
||||||
|
|
||||||
|
.. copy & modify the list from command-line tools? |
||||||
|
|
||||||
|
|
||||||
|
.. _Docutils-develop: ../user/mailing-lists.html#docutils-develop |
@ -0,0 +1,143 @@ |
|||||||
|
=============================== |
||||||
|
Docutils_ Distributor's Guide |
||||||
|
=============================== |
||||||
|
|
||||||
|
:Author: Lea Wiemann |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Revision: $Revision: 7889 $ |
||||||
|
:Date: $Date: 2015-05-08 17:56:32 +0200 (Fr, 08 Mai 2015) $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
.. _Docutils: http://docutils.sourceforge.net/ |
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
This document describes how to create packages of Docutils (e.g. for |
||||||
|
shipping with a Linux distribution). If you have any questions, |
||||||
|
please direct them to the Docutils-develop_ mailing list. |
||||||
|
|
||||||
|
First, please download the most current `release tarball`_ and unpack |
||||||
|
it. |
||||||
|
|
||||||
|
.. _Docutils-develop: ../user/mailing-lists.html#docutils-develop |
||||||
|
.. _release tarball: http://docutils.sourceforge.net/#download |
||||||
|
|
||||||
|
|
||||||
|
Dependencies |
||||||
|
============ |
||||||
|
|
||||||
|
Docutils has the following dependencies: |
||||||
|
|
||||||
|
* Python 2.4 or later is required. Use ">= Python 2.4" in the |
||||||
|
dependencies. |
||||||
|
|
||||||
|
* Docutils may optionally make use of the PIL (`Python Imaging |
||||||
|
Library`_). If PIL is present, it is automatically detected by |
||||||
|
Docutils. |
||||||
|
|
||||||
|
* Docutils recommends the `Pygments`_ syntax hightlighter. If available, it |
||||||
|
is used for highlighting the content of `code directives`_ and roles as |
||||||
|
well as included source code files (with the "code" option to the include_ |
||||||
|
directive). |
||||||
|
|
||||||
|
.. _Python Imaging Library: http://www.pythonware.com/products/pil/ |
||||||
|
.. _Pygments: http://pygments.org/ |
||||||
|
.. _code directives: ../ref/rst/directives.html#code |
||||||
|
.. _include: ../ref/rst/directives.html#include |
||||||
|
|
||||||
|
|
||||||
|
Python Files |
||||||
|
============ |
||||||
|
|
||||||
|
The Docutils Python files must be installed into the |
||||||
|
``site-packages/`` directory of Python. Running ``python setup.py |
||||||
|
install`` should do the trick, but if you want to place the files |
||||||
|
yourself, you can just install the ``docutils/`` directory of the |
||||||
|
Docutils tarball to ``/usr/lib/python/site-packages/docutils/``. In |
||||||
|
this case you should also compile the Python files to ``.pyc`` and/or |
||||||
|
``.pyo`` files so that Docutils doesn't need to be recompiled every |
||||||
|
time it's executed. |
||||||
|
|
||||||
|
|
||||||
|
Executables |
||||||
|
=========== |
||||||
|
|
||||||
|
The executable front-end tools are located in the ``tools/`` directory |
||||||
|
of the Docutils tarball. |
||||||
|
|
||||||
|
The ``rst2*.py`` tools (except ``rst2newlatex.py``) are intended for |
||||||
|
end-users. You should install them to ``/usr/bin/``. You do not need |
||||||
|
to change the names (e.g. to ``docutils-rst2html.py``) because the |
||||||
|
``rst2`` prefix is unique. |
||||||
|
|
||||||
|
|
||||||
|
Documentation |
||||||
|
============= |
||||||
|
|
||||||
|
The documentation should be generated using ``buildhtml.py``. To |
||||||
|
generate HTML for all documentation files, go to the ``tools/`` |
||||||
|
directory and run:: |
||||||
|
|
||||||
|
# Place html4css1.css in base directory. |
||||||
|
cp ../docutils/writers/html4css1/html4css1.css .. |
||||||
|
./buildhtml.py --stylesheet-path=../html4css1.css .. |
||||||
|
|
||||||
|
Then install the following files to ``/usr/share/doc/docutils/`` (or |
||||||
|
wherever you install documentation): |
||||||
|
|
||||||
|
* All ``.html`` and ``.txt`` files in the base directory. |
||||||
|
|
||||||
|
* The ``docs/`` directory. |
||||||
|
|
||||||
|
Do not install the contents of the ``docs/`` directory directly to |
||||||
|
``/usr/share/doc/docutils/``; it's incomplete and would contain |
||||||
|
invalid references! |
||||||
|
|
||||||
|
* The ``licenses/`` directory. |
||||||
|
|
||||||
|
* ``html4css1.css`` in the base directory. |
||||||
|
|
||||||
|
|
||||||
|
Removing the ``.txt`` Files |
||||||
|
--------------------------- |
||||||
|
|
||||||
|
If you are tight with disk space, you can remove all ``.txt`` files in |
||||||
|
the tree except for: |
||||||
|
|
||||||
|
* those in the ``licenses/`` directory because they have not been |
||||||
|
processed to HTML and |
||||||
|
|
||||||
|
* ``user/rst/cheatsheet.txt`` and ``user/rst/demo.txt``, which should |
||||||
|
be readable in source form. |
||||||
|
|
||||||
|
Before you remove the ``.txt`` files you should rerun ``buildhtml.py`` |
||||||
|
with the ``--no-source-link`` switch to avoid broken references to the |
||||||
|
source files. |
||||||
|
|
||||||
|
|
||||||
|
Other Files |
||||||
|
=========== |
||||||
|
|
||||||
|
You may want to install the Emacs-Lisp files |
||||||
|
``tools/editors/emacs/*.el`` into the appropriate directory. |
||||||
|
|
||||||
|
|
||||||
|
Configuration File |
||||||
|
================== |
||||||
|
|
||||||
|
It is possible to have a system-wide configuration file at |
||||||
|
``/etc/docutils.conf``. However, this is usually not necessary. You |
||||||
|
should *not* install ``tools/docutils.conf`` into ``/etc/``. |
||||||
|
|
||||||
|
|
||||||
|
Tests |
||||||
|
===== |
||||||
|
|
||||||
|
While you probably do not need to ship the tests with your |
||||||
|
distribution, you can test your package by installing it and then |
||||||
|
running ``alltests.py`` from the ``tests/`` directory of the Docutils |
||||||
|
tarball. |
||||||
|
|
||||||
|
For more information on testing, view the `Docutils Testing`_ page. |
||||||
|
|
||||||
|
.. _Docutils Testing: http://docutils.sourceforge.net/docs/dev/testing.html |
@ -0,0 +1,480 @@ |
|||||||
|
=========================================== |
||||||
|
Plan for Enthought API Documentation Tool |
||||||
|
=========================================== |
||||||
|
|
||||||
|
:Author: David Goodger |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Date: $Date: 2012-01-03 20:23:53 +0100 (Di, 03 Jan 2012) $ |
||||||
|
:Revision: $Revision: 7302 $ |
||||||
|
:Copyright: 2004 by `Enthought, Inc. <http://www.enthought.com>`_ |
||||||
|
:License: `Enthought License`_ (BSD-style) |
||||||
|
|
||||||
|
.. _Enthought License: http://docutils.sf.net/licenses/enthought.txt |
||||||
|
|
||||||
|
This document should be read in conjunction with the `Enthought API |
||||||
|
Documentation Tool RFP`__ prepared by Janet Swisher. |
||||||
|
|
||||||
|
__ enthought-rfp.html |
||||||
|
|
||||||
|
.. contents:: |
||||||
|
.. sectnum:: |
||||||
|
|
||||||
|
|
||||||
|
Introduction |
||||||
|
============ |
||||||
|
|
||||||
|
In March 2004 at I met Eric Jones, president and CTO of `Enthought, |
||||||
|
Inc.`_, at `PyCon 2004`_ in Washington DC. He told me that Enthought |
||||||
|
was using reStructuredText_ for source code documentation, but they |
||||||
|
had some issues. He asked if I'd be interested in doing some work on |
||||||
|
a customized API documentation tool. Shortly after PyCon, Janet |
||||||
|
Swisher, Enthought's senior technical writer, contacted me to work out |
||||||
|
details. Some email, a trip to Austin in May, and plenty of Texas |
||||||
|
hospitality later, we had a project. This document will record the |
||||||
|
details, milestones, and evolution of the project. |
||||||
|
|
||||||
|
In a nutshell, Enthought is sponsoring the implementation of an open |
||||||
|
source API documentation tool that meets their needs. Fortuitously, |
||||||
|
their needs coincide well with the "Python Source Reader" description |
||||||
|
in `PEP 258`_. In other words, Enthought is funding some significant |
||||||
|
improvements to Docutils, improvements that were planned but never |
||||||
|
implemented due to time and other constraints. The implementation |
||||||
|
will take place gradually over several months, on a part-time basis. |
||||||
|
|
||||||
|
This is an ideal example of cooperation between a corporation and an |
||||||
|
open-source project. The corporation, the project, I personally, and |
||||||
|
the community all benefit. Enthought, whose commitment to open source |
||||||
|
is also evidenced by their sponsorship of SciPy_, benefits by |
||||||
|
obtaining a useful piece of software, much more quickly than would |
||||||
|
have been possible without their support. Docutils benefits directly |
||||||
|
from the implementation of one of its core subsystems. I benefit from |
||||||
|
the funding, which allows me to justify the long hours to my wife and |
||||||
|
family. All the corporations, projects, and individuals that make up |
||||||
|
the community will benefit from the end result, which will be great. |
||||||
|
|
||||||
|
All that's left now is to actually do the work! |
||||||
|
|
||||||
|
.. _PyCon 2004: http://pycon.org/dc2004/ |
||||||
|
.. _reStructuredText: http://docutils.sf.net/rst.html |
||||||
|
.. _SciPy: http://www.scipy.org/ |
||||||
|
|
||||||
|
|
||||||
|
Development Plan |
||||||
|
================ |
||||||
|
|
||||||
|
1. Analyze prior art, most notably Epydoc_ and HappyDoc_, to see how |
||||||
|
they do what they do. I have no desire to reinvent wheels |
||||||
|
unnecessarily. I want to take the best ideas from each tool, |
||||||
|
combined with the outline in `PEP 258`_ (which will evolve), and |
||||||
|
build at least the foundation of the definitive Python |
||||||
|
auto-documentation tool. |
||||||
|
|
||||||
|
.. _Epydoc: http://epydoc.sourceforge.net/ |
||||||
|
.. _HappyDoc: http://happydoc.sourceforge.net/ |
||||||
|
.. _PEP 258: |
||||||
|
http://docutils.sf.net/docs/peps/pep-0258.html#python-source-reader |
||||||
|
|
||||||
|
2. Decide on a base platform. The best way to achieve Enthought's |
||||||
|
goals in a reasonable time frame may be to extend Epydoc or |
||||||
|
HappyDoc. Or it may be necessary to start fresh. |
||||||
|
|
||||||
|
3. Extend the reStructuredText parser. See `Proposed Changes to |
||||||
|
reStructuredText`_ below. |
||||||
|
|
||||||
|
4. Depending on the base platform chosen, build or extend the |
||||||
|
docstring & doc comment extraction tool. This may be the biggest |
||||||
|
part of the project, but I won't be able to break it down into |
||||||
|
details until more is known. |
||||||
|
|
||||||
|
|
||||||
|
Repository |
||||||
|
========== |
||||||
|
|
||||||
|
If possible, all software and documentation files will be stored in |
||||||
|
the Subversion repository of Docutils and/or the base project, which |
||||||
|
are all publicly-available via anonymous pserver access. |
||||||
|
|
||||||
|
The Docutils project is very open about granting Subversion write |
||||||
|
access; so far, everyone who asked has been given access. Any |
||||||
|
Enthought staff member who would like Subversion write access will get |
||||||
|
it. |
||||||
|
|
||||||
|
If either Epydoc or HappyDoc is chosen as the base platform, I will |
||||||
|
ask the project's administrator for CVS access for myself and any |
||||||
|
Enthought staff member who wants it. If sufficient access is not |
||||||
|
granted -- although I doubt that there would be any problem -- we may |
||||||
|
have to begin a fork, which could be hosted on SourceForge, on |
||||||
|
Enthought's Subversion server, or anywhere else deemed appropriate. |
||||||
|
|
||||||
|
|
||||||
|
Copyright & License |
||||||
|
=================== |
||||||
|
|
||||||
|
Most existing Docutils files have been placed in the public domain, as |
||||||
|
follows:: |
||||||
|
|
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
This is in conjunction with the "Public Domain Dedication" section of |
||||||
|
COPYING.txt__. |
||||||
|
|
||||||
|
__ http://docutils.sourceforge.net/COPYING.html |
||||||
|
|
||||||
|
The code and documentation originating from Enthought funding will |
||||||
|
have Enthought's copyright and license declaration. While I will try |
||||||
|
to keep Enthought-specific code and documentation separate from the |
||||||
|
existing files, there will inevitably be cases where it makes the most |
||||||
|
sense to extend existing files. |
||||||
|
|
||||||
|
I propose the following: |
||||||
|
|
||||||
|
1. New files related to this Enthought-funded work will be identified |
||||||
|
with the following field-list headers:: |
||||||
|
|
||||||
|
:Copyright: 2004 by Enthought, Inc. |
||||||
|
:License: Enthought License (BSD Style) |
||||||
|
|
||||||
|
The license field text will be linked to the license file itself. |
||||||
|
|
||||||
|
2. For significant or major changes to an existing file (more than 10% |
||||||
|
change), the headers shall change as follows (for example):: |
||||||
|
|
||||||
|
:Copyright: 2001-2004 by David Goodger |
||||||
|
:Copyright: 2004 by Enthought, Inc. |
||||||
|
:License: BSD-style |
||||||
|
|
||||||
|
If the Enthought-funded portion becomes greater than the previously |
||||||
|
existing portion, Enthought's copyright line will be shown first. |
||||||
|
|
||||||
|
3. In cases of insignificant or minor changes to an existing file |
||||||
|
(less than 10% change), the public domain status shall remain |
||||||
|
unchanged. |
||||||
|
|
||||||
|
A section describing all of this will be added to the Docutils |
||||||
|
`COPYING`__ instructions file. |
||||||
|
|
||||||
|
If another project is chosen as the base project, similar changes |
||||||
|
would be made to their files, subject to negotiation. |
||||||
|
|
||||||
|
__ http://docutils.sf.net/COPYING.html |
||||||
|
|
||||||
|
|
||||||
|
Proposed Changes to reStructuredText |
||||||
|
==================================== |
||||||
|
|
||||||
|
Doc Comment Syntax |
||||||
|
------------------ |
||||||
|
|
||||||
|
The "traits" construct is implemented as dictionaries, where |
||||||
|
standalone strings would be Python syntax errors. Therefore traits |
||||||
|
require documentation in comments. We also need a way to |
||||||
|
differentiate between ordinary "internal" comments and documentation |
||||||
|
comments (doc comments). |
||||||
|
|
||||||
|
Javadoc uses the following syntax for doc comments:: |
||||||
|
|
||||||
|
/** |
||||||
|
* The first line of a multi-line doc comment begins with a slash |
||||||
|
* and *two* asterisks. The doc comment ends normally. |
||||||
|
*/ |
||||||
|
|
||||||
|
Python doesn't have multi-line comments; only single-line. A similar |
||||||
|
convention in Python might look like this:: |
||||||
|
|
||||||
|
## |
||||||
|
# The first line of a doc comment begins with *two* hash marks. |
||||||
|
# The doc comment ends with the first non-comment line. |
||||||
|
'data' : AnyValue, |
||||||
|
|
||||||
|
## The double-hash-marks could occur on the first line of text, |
||||||
|
# saving a line in the source. |
||||||
|
'data' : AnyValue, |
||||||
|
|
||||||
|
How to indicate the end of the doc comment? :: |
||||||
|
|
||||||
|
## |
||||||
|
# The first line of a doc comment begins with *two* hash marks. |
||||||
|
# The doc comment ends with the first non-comment line, or another |
||||||
|
# double-hash-mark. |
||||||
|
## |
||||||
|
# This is an ordinary, internal, non-doc comment. |
||||||
|
'data' : AnyValue, |
||||||
|
|
||||||
|
## First line of a doc comment, terse syntax. |
||||||
|
# Second (and last) line. Ends here: ## |
||||||
|
# This is an ordinary, internal, non-doc comment. |
||||||
|
'data' : AnyValue, |
||||||
|
|
||||||
|
Or do we even need to worry about this case? A simple blank line |
||||||
|
could be used:: |
||||||
|
|
||||||
|
## First line of a doc comment, terse syntax. |
||||||
|
# Second (and last) line. Ends with a blank line. |
||||||
|
|
||||||
|
# This is an ordinary, internal, non-doc comment. |
||||||
|
'data' : AnyValue, |
||||||
|
|
||||||
|
Other possibilities:: |
||||||
|
|
||||||
|
#" Instead of double-hash-marks, we could use a hash mark and a |
||||||
|
# quotation mark to begin the doc comment. |
||||||
|
'data' : AnyValue, |
||||||
|
|
||||||
|
## We could require double-hash-marks on every line. This has the |
||||||
|
## added benefit of delimiting the *end* of the doc comment, as |
||||||
|
## well as working well with line wrapping in Emacs |
||||||
|
## ("fill-paragraph" command). |
||||||
|
# Ordinary non-doc comment. |
||||||
|
'data' : AnyValue, |
||||||
|
|
||||||
|
#" A hash mark and a quotation mark on each line looks funny, and |
||||||
|
#" it doesn't work well with line wrapping in Emacs. |
||||||
|
'data' : AnyValue, |
||||||
|
|
||||||
|
These styles (repeated on each line) work well with line wrapping in |
||||||
|
Emacs:: |
||||||
|
|
||||||
|
## #> #| #- #% #! #* |
||||||
|
|
||||||
|
These styles do *not* work well with line wrapping in Emacs:: |
||||||
|
|
||||||
|
#" #' #: #) #. #/ #@ #$ #^ #= #+ #_ #~ |
||||||
|
|
||||||
|
The style of doc comment indicator used could be a runtime, global |
||||||
|
and/or per-module setting. That may add more complexity than it's |
||||||
|
worth though. |
||||||
|
|
||||||
|
|
||||||
|
Recommendation |
||||||
|
`````````````` |
||||||
|
|
||||||
|
I recommend adopting "#*" on every line:: |
||||||
|
|
||||||
|
# This is an ordinary non-doc comment. |
||||||
|
|
||||||
|
#* This is a documentation comment, with an asterisk after the |
||||||
|
#* hash marks on every line. |
||||||
|
'data' : AnyValue, |
||||||
|
|
||||||
|
I initially recommended adopting double-hash-marks:: |
||||||
|
|
||||||
|
# This is an ordinary non-doc comment. |
||||||
|
|
||||||
|
## This is a documentation comment, with double-hash-marks on |
||||||
|
## every line. |
||||||
|
'data' : AnyValue, |
||||||
|
|
||||||
|
But Janet Swisher rightly pointed out that this could collide with |
||||||
|
ordinary comments that are then block-commented. This applies to |
||||||
|
double-hash-marks on the first line only as well. So they're out. |
||||||
|
|
||||||
|
On the other hand, the JavaDoc-comment style ("##" on the first line |
||||||
|
only, "#" after that) is used in Fredrik Lundh's PythonDoc_. It may |
||||||
|
be worthwhile to conform to this syntax, reinforcing it as a standard. |
||||||
|
PythonDoc does not support terse doc comments (text after "##" on the |
||||||
|
first line). |
||||||
|
|
||||||
|
.. _PythonDoc: http://effbot.org/zone/pythondoc.htm |
||||||
|
|
||||||
|
|
||||||
|
Update |
||||||
|
`````` |
||||||
|
|
||||||
|
Enthought's Traits system has switched to a metaclass base, and traits |
||||||
|
are now defined via ordinary attributes. Therefore doc comments are |
||||||
|
no longer absolutely necessary; attribute docstrings will suffice. |
||||||
|
Doc comments may still be desirable though, since they allow |
||||||
|
documentation to precede the thing being documented. |
||||||
|
|
||||||
|
|
||||||
|
Docstring Density & Whitespace Minimization |
||||||
|
------------------------------------------- |
||||||
|
|
||||||
|
One problem with extensively documented classes & functions, is that |
||||||
|
there is a lot of screen space wasted on whitespace. Here's some |
||||||
|
current Enthought code (from lib/cp/fluids/gassmann.py):: |
||||||
|
|
||||||
|
def max_gas(temperature, pressure, api, specific_gravity=.56): |
||||||
|
""" |
||||||
|
Computes the maximum dissolved gas in oil using Batzle and |
||||||
|
Wang (1992). |
||||||
|
|
||||||
|
Parameters |
||||||
|
---------- |
||||||
|
temperature : sequence |
||||||
|
Temperature in degrees Celsius |
||||||
|
pressure : sequence |
||||||
|
Pressure in MPa |
||||||
|
api : sequence |
||||||
|
Stock tank oil API |
||||||
|
specific_gravity : sequence |
||||||
|
Specific gravity of gas at STP, default is .56 |
||||||
|
|
||||||
|
Returns |
||||||
|
------- |
||||||
|
max_gor : sequence |
||||||
|
Maximum dissolved gas in liters/liter |
||||||
|
|
||||||
|
Description |
||||||
|
----------- |
||||||
|
This estimate is based on equations given by Mavko, Mukerji, |
||||||
|
and Dvorkin, (1998, pp. 218-219, or 2003, p. 236) obtained |
||||||
|
originally from Batzle and Wang (1992). |
||||||
|
""" |
||||||
|
code... |
||||||
|
|
||||||
|
The docstring is 24 lines long. |
||||||
|
|
||||||
|
Rather than using subsections, field lists (which exist now) can save |
||||||
|
6 lines:: |
||||||
|
|
||||||
|
def max_gas(temperature, pressure, api, specific_gravity=.56): |
||||||
|
""" |
||||||
|
Computes the maximum dissolved gas in oil using Batzle and |
||||||
|
Wang (1992). |
||||||
|
|
||||||
|
:Parameters: |
||||||
|
temperature : sequence |
||||||
|
Temperature in degrees Celsius |
||||||
|
pressure : sequence |
||||||
|
Pressure in MPa |
||||||
|
api : sequence |
||||||
|
Stock tank oil API |
||||||
|
specific_gravity : sequence |
||||||
|
Specific gravity of gas at STP, default is .56 |
||||||
|
:Returns: |
||||||
|
max_gor : sequence |
||||||
|
Maximum dissolved gas in liters/liter |
||||||
|
:Description: This estimate is based on equations given by |
||||||
|
Mavko, Mukerji, and Dvorkin, (1998, pp. 218-219, or 2003, |
||||||
|
p. 236) obtained originally from Batzle and Wang (1992). |
||||||
|
""" |
||||||
|
code... |
||||||
|
|
||||||
|
As with the "Description" field above, field bodies may begin on the |
||||||
|
same line as the field name, which also saves space. |
||||||
|
|
||||||
|
The output for field lists is typically a table structure. For |
||||||
|
example: |
||||||
|
|
||||||
|
:Parameters: |
||||||
|
temperature : sequence |
||||||
|
Temperature in degrees Celsius |
||||||
|
pressure : sequence |
||||||
|
Pressure in MPa |
||||||
|
api : sequence |
||||||
|
Stock tank oil API |
||||||
|
specific_gravity : sequence |
||||||
|
Specific gravity of gas at STP, default is .56 |
||||||
|
:Returns: |
||||||
|
max_gor : sequence |
||||||
|
Maximum dissolved gas in liters/liter |
||||||
|
:Description: |
||||||
|
This estimate is based on equations given by Mavko, |
||||||
|
Mukerji, and Dvorkin, (1998, pp. 218-219, or 2003, p. 236) |
||||||
|
obtained originally from Batzle and Wang (1992). |
||||||
|
|
||||||
|
But the definition lists describing the parameters and return values |
||||||
|
are still wasteful of space. There are a lot of half-filled lines. |
||||||
|
|
||||||
|
Definition lists are currently defined as:: |
||||||
|
|
||||||
|
term : classifier |
||||||
|
definition |
||||||
|
|
||||||
|
Where the classifier part is optional. Ideas for improvements: |
||||||
|
|
||||||
|
1. We could allow multiple classifiers:: |
||||||
|
|
||||||
|
term : classifier one : two : three ... |
||||||
|
definition |
||||||
|
|
||||||
|
2. We could allow the definition on the same line as the term, using |
||||||
|
some embedded/inline markup: |
||||||
|
|
||||||
|
* "--" could be used, but only in limited and well-known contexts:: |
||||||
|
|
||||||
|
term -- definition |
||||||
|
|
||||||
|
This is the syntax used by StructuredText (one of |
||||||
|
reStructuredText's predecessors). It was not adopted for |
||||||
|
reStructuredText because it is ambiguous -- people often use "--" |
||||||
|
in their text, as I just did. But given a constrained context, |
||||||
|
the ambiguity would be acceptable (or would it?). That context |
||||||
|
would be: in docstrings, within a field list, perhaps only with |
||||||
|
certain well-defined field names (parameters, returns). |
||||||
|
|
||||||
|
* The "constrained context" above isn't really enough to make the |
||||||
|
ambiguity acceptable. Instead, a slightly more verbose but far |
||||||
|
less ambiguous syntax is possible:: |
||||||
|
|
||||||
|
term === definition |
||||||
|
|
||||||
|
This syntax has advantages. Equals signs lend themselves to the |
||||||
|
connotation of "definition". And whereas one or two equals signs |
||||||
|
are commonly used in program code, three equals signs in a row |
||||||
|
have no conflicting meanings that I know of. (Update: there |
||||||
|
*are* uses out there.) |
||||||
|
|
||||||
|
The problem with this approach is that using inline markup for |
||||||
|
structure is inherently ambiguous in reStructuredText. For |
||||||
|
example, writing *about* definition lists would be difficult:: |
||||||
|
|
||||||
|
``term === definition`` is an example of a compact definition list item |
||||||
|
|
||||||
|
The parser checks for structural markup before it does inline |
||||||
|
markup processing. But the "===" should be protected by its inline |
||||||
|
literal context. |
||||||
|
|
||||||
|
3. We could allow the definition on the same line as the term, using |
||||||
|
structural markup. A variation on bullet lists would work well:: |
||||||
|
|
||||||
|
: term :: definition |
||||||
|
: another term :: and a definition that |
||||||
|
wraps across lines |
||||||
|
|
||||||
|
Some ambiguity remains:: |
||||||
|
|
||||||
|
: term ``containing :: double colons`` :: definition |
||||||
|
|
||||||
|
But the likelihood of such cases is negligible, and they can be |
||||||
|
covered in the documentation. |
||||||
|
|
||||||
|
Other possibilities for the definition delimiter include:: |
||||||
|
|
||||||
|
: term : classifier -- definition |
||||||
|
: term : classifier --- definition |
||||||
|
: term : classifier : : definition |
||||||
|
: term : classifier === definition |
||||||
|
|
||||||
|
The third idea currently has the best chance of being adopted and |
||||||
|
implemented. |
||||||
|
|
||||||
|
|
||||||
|
Recommendation |
||||||
|
`````````````` |
||||||
|
|
||||||
|
Combining these ideas, the function definition becomes:: |
||||||
|
|
||||||
|
def max_gas(temperature, pressure, api, specific_gravity=.56): |
||||||
|
""" |
||||||
|
Computes the maximum dissolved gas in oil using Batzle and |
||||||
|
Wang (1992). |
||||||
|
|
||||||
|
:Parameters: |
||||||
|
: temperature : sequence :: Temperature in degrees Celsius |
||||||
|
: pressure : sequence :: Pressure in MPa |
||||||
|
: api : sequence :: Stock tank oil API |
||||||
|
: specific_gravity : sequence :: Specific gravity of gas at |
||||||
|
STP, default is .56 |
||||||
|
:Returns: |
||||||
|
: max_gor : sequence :: Maximum dissolved gas in liters/liter |
||||||
|
:Description: This estimate is based on equations given by |
||||||
|
Mavko, Mukerji, and Dvorkin, (1998, pp. 218-219, or 2003, |
||||||
|
p. 236) obtained originally from Batzle and Wang (1992). |
||||||
|
""" |
||||||
|
code... |
||||||
|
|
||||||
|
The docstring is reduced to 14 lines, from the original 24. For |
||||||
|
longer docstrings with many parameters and return values, the |
||||||
|
difference would be more significant. |
@ -0,0 +1,146 @@ |
|||||||
|
================================== |
||||||
|
Enthought API Documentation Tool |
||||||
|
================================== |
||||||
|
----------------------- |
||||||
|
Request for Proposals |
||||||
|
----------------------- |
||||||
|
|
||||||
|
:Author: Janet Swisher, Senior Technical Writer |
||||||
|
:Organization: `Enthought, Inc. <http://www.enthought.com>`_ |
||||||
|
:Copyright: 2004 by Enthought, Inc. |
||||||
|
:License: `Enthought License`_ (BSD Style) |
||||||
|
|
||||||
|
.. _Enthought License: http://docutils.sf.net/licenses/enthought.txt |
||||||
|
|
||||||
|
The following is excerpted from the full RFP, and is published here |
||||||
|
with permission from `Enthought, Inc.`_ See the `Plan for Enthought |
||||||
|
API Documentation Tool`__. |
||||||
|
|
||||||
|
__ enthought-plan.html |
||||||
|
|
||||||
|
.. contents:: |
||||||
|
.. sectnum:: |
||||||
|
|
||||||
|
|
||||||
|
Requirements |
||||||
|
============ |
||||||
|
|
||||||
|
The documentation tool will address the following high-level goals: |
||||||
|
|
||||||
|
|
||||||
|
Documentation Extraction |
||||||
|
------------------------ |
||||||
|
|
||||||
|
1. Documentation will be generated directly from Python source code, |
||||||
|
drawing from the code structure, docstrings, and possibly other |
||||||
|
comments. |
||||||
|
|
||||||
|
2. The tool will extract logical constructs as appropriate, minimizing |
||||||
|
the need for comments that are redundant with the code structure. |
||||||
|
The output should reflect both documented and undocumented |
||||||
|
elements. |
||||||
|
|
||||||
|
|
||||||
|
Source Format |
||||||
|
------------- |
||||||
|
|
||||||
|
1. The docstrings will be formatted in as terse syntax as possible. |
||||||
|
Required tags, syntax, and white space should be minimized. |
||||||
|
|
||||||
|
2. The tool must support the use of Traits. Special comment syntax |
||||||
|
for Traits may be necessary. Information about the Traits package |
||||||
|
is available at http://code.enthought.com/traits/. In the |
||||||
|
following example, each trait definition is prefaced by a plain |
||||||
|
comment:: |
||||||
|
|
||||||
|
__traits__ = { |
||||||
|
|
||||||
|
# The current selection within the frame. |
||||||
|
'selection' : Trait([], TraitInstance(list)), |
||||||
|
|
||||||
|
# The frame has been activated or deactivated. |
||||||
|
'activated' : TraitEvent(), |
||||||
|
|
||||||
|
'closing' : TraitEvent(), |
||||||
|
|
||||||
|
# The frame is closed. |
||||||
|
'closed' : TraitEvent(), |
||||||
|
} |
||||||
|
|
||||||
|
3. Support for ReStructuredText (ReST) format is desirable, because |
||||||
|
much of the existing docstrings uses ReST. However, the complete |
||||||
|
ReST specification need not be supported, if a subset can achieve |
||||||
|
the project goals. If the tool does not support ReST, the |
||||||
|
contractor should also provide a tool or path to convert existing |
||||||
|
docstrings. |
||||||
|
|
||||||
|
|
||||||
|
Output Format |
||||||
|
------------- |
||||||
|
|
||||||
|
1. Documentation will be output as a navigable suite of HTML |
||||||
|
files. |
||||||
|
|
||||||
|
2. The style of the HTML files will be customizable by a cascading |
||||||
|
style sheet and/or a customizable template. |
||||||
|
|
||||||
|
3. Page elements such as headers and footer should be customizable, to |
||||||
|
support differing requirements from one documentation project to |
||||||
|
the next. |
||||||
|
|
||||||
|
|
||||||
|
Output Structure and Navigation |
||||||
|
------------------------------- |
||||||
|
|
||||||
|
1. The navigation scheme for the HTML files should not rely on frames, |
||||||
|
and should harmonize with conversion to Microsoft HTML Help (.chm) |
||||||
|
format. |
||||||
|
|
||||||
|
2. The output should be structured to make navigable the architecture |
||||||
|
of the Python code. Packages, modules, classes, traits, and |
||||||
|
functions should be presented in clear, logical hierarchies. |
||||||
|
Diagrams or trees for inheritance, collaboration, sub-packaging, |
||||||
|
etc. are desirable but not required. |
||||||
|
|
||||||
|
3. The output must include indexes that provide a comprehensive view |
||||||
|
of all packages, modules, and classes. These indexes will provide |
||||||
|
readers with a clear and exhaustive view of the code base. These |
||||||
|
indexes should be presented in a way that is easily accessible and |
||||||
|
allows easy navigation. |
||||||
|
|
||||||
|
4. Cross-references to other documented elements will be used |
||||||
|
throughout the documentation, to enable the reader to move quickly |
||||||
|
relevant information. For example, where type information for an |
||||||
|
element is available, the type definition should be |
||||||
|
cross-referenced. |
||||||
|
|
||||||
|
5. The HTML suite should provide consistent navigation back to the |
||||||
|
home page, which will include the following information: |
||||||
|
|
||||||
|
* Bibliographic information |
||||||
|
|
||||||
|
- Author |
||||||
|
- Copyright |
||||||
|
- Release date |
||||||
|
- Version number |
||||||
|
|
||||||
|
* Abstract |
||||||
|
|
||||||
|
* References |
||||||
|
|
||||||
|
- Links to related internal docs (i.e., other docs for the same |
||||||
|
product) |
||||||
|
|
||||||
|
- Links to related external docs (e.g., supporting development |
||||||
|
docs, Python support docs, docs for included packages) |
||||||
|
|
||||||
|
It should be possible to specify similar information at the top |
||||||
|
level of each package, so that packages can be included as |
||||||
|
appropriate for a given application. |
||||||
|
|
||||||
|
|
||||||
|
License |
||||||
|
======= |
||||||
|
|
||||||
|
Enthought intends to release the software under an open-source |
||||||
|
("BSD-style") license. |
@ -0,0 +1,260 @@ |
|||||||
|
<!-- |
||||||
|
====================================================================== |
||||||
|
Docutils Python Source DTD |
||||||
|
====================================================================== |
||||||
|
:Author: David Goodger |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Revision: $Revision: 7302 $ |
||||||
|
:Date: $Date: 2012-01-03 20:23:53 +0100 (Di, 03 Jan 2012) $ |
||||||
|
:Copyright: This DTD has been placed in the public domain. |
||||||
|
:Filename: pysource.dtd |
||||||
|
|
||||||
|
This DTD (document type definition) extends the Generic DTD (see |
||||||
|
below). |
||||||
|
|
||||||
|
More information about this DTD and the Docutils project can be found |
||||||
|
at http://docutils.sourceforge.net/. The latest version of this DTD |
||||||
|
is available from |
||||||
|
http://docutils.sourceforge.net/docs/dev/pysource.dtd. |
||||||
|
|
||||||
|
The formal public identifier for this DTD is:: |
||||||
|
|
||||||
|
+//IDN docutils.sourceforge.net//DTD Docutils Python Source//EN//XML |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
Parameter Entity Overrides |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
--> |
||||||
|
|
||||||
|
<!ENTITY % additional.section.elements |
||||||
|
" | package_section | module_section | class_section |
||||||
|
| method_section | function_section |
||||||
|
| module_attribute_section | function_attribute_section |
||||||
|
| class_attribute_section | instance_attribute_section "> |
||||||
|
|
||||||
|
<!ENTITY % additional.inline.elements |
||||||
|
" | package | module | class | method | function |
||||||
|
| variable | parameter | type | attribute |
||||||
|
| module_attribute | class_attribute | instance_attribute |
||||||
|
| exception_class | warning_class "> |
||||||
|
|
||||||
|
<!-- |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
Generic DTD |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
|
||||||
|
This DTD extends the Docutils Generic DTD, available from |
||||||
|
http://docutils.sourceforge.net/docs/ref/docutils.dtd. |
||||||
|
--> |
||||||
|
|
||||||
|
<!ENTITY % docutils PUBLIC |
||||||
|
"+//IDN python.org//DTD Docutils Generic//EN//XML" |
||||||
|
"docutils.dtd"> |
||||||
|
%docutils; |
||||||
|
|
||||||
|
<!-- |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
Additional Section Elements |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- package's namespace == __init__.py module's namespace --> |
||||||
|
<!ELEMENT package_section |
||||||
|
(package, fullname?, import_list?, %structure.model;)> |
||||||
|
<!ATTLIST package_section %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT module_section |
||||||
|
(module, fullname?, import_list?, %structure.model;)> |
||||||
|
<!ATTLIST module_section %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT class_section |
||||||
|
(class, inheritance_list?, fullname?, subclasses?, |
||||||
|
%structure.model;)> |
||||||
|
<!ATTLIST class_section %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT method_section |
||||||
|
(method, parameter_list?, fullname?, overrides?, |
||||||
|
%structure.model;)> |
||||||
|
<!ATTLIST method_section %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT function_section |
||||||
|
(function, parameter_list?, fullname?, %structure.model;)> |
||||||
|
<!ATTLIST function_section %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT module_attribute_section |
||||||
|
(attribute, initial_value?, fullname?, %structure.model;)> |
||||||
|
<!ATTLIST module_attribute_section %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT function_attribute_section |
||||||
|
(attribute, initial_value?, fullname?, %structure.model;)> |
||||||
|
<!ATTLIST function_attribute_section %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT class_attribute_section |
||||||
|
(attribute, initial_value?, fullname?, overrides?, |
||||||
|
%structure.model;)> |
||||||
|
<!ATTLIST class_attribute_section %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT instance_attribute_section |
||||||
|
(attribute, initial_value?, fullname?, overrides?, |
||||||
|
%structure.model;)> |
||||||
|
<!ATTLIST instance_attribute_section %basic.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Section Subelements |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT fullname |
||||||
|
(package | module | class | method | function | attribute)+> |
||||||
|
<!ATTLIST fullname %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT import_list (import_item+)> |
||||||
|
<!ATTLIST import_list %basic.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Support ``import module``, ``import module as alias``, ``from module |
||||||
|
import identifier``, and ``from module import identifier as alias``. |
||||||
|
--> |
||||||
|
<!ELEMENT import_item (fullname, identifier?, alias?)> |
||||||
|
<!ATTLIST import_item %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT inheritance_list (class+)> |
||||||
|
<!ATTLIST inheritance_list %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT subclasses (class+)> |
||||||
|
<!ATTLIST subclasses %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT parameter_list |
||||||
|
((parameter_item+, optional_parameters*) | optional_parameters+)> |
||||||
|
<!ATTLIST parameter_list %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT parameter_item |
||||||
|
((parameter | parameter_tuple), parameter_default?)> |
||||||
|
<!ATTLIST parameter_item %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT optional_parameters (parameter_item+, optional_parameters*)> |
||||||
|
<!ATTLIST optional_parameters %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT parameter_tuple (parameter | parameter_tuple)+> |
||||||
|
<!ATTLIST parameter_tuple %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT parameter_default (#PCDATA)> |
||||||
|
<!ATTLIST parameter_default %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT overrides (fullname+)> |
||||||
|
<!ATTLIST overrides %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT initial_value (#PCDATA)> |
||||||
|
<!ATTLIST initial_value %basic.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
Additional Inline Elements |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- Also used as the `package_section` identifier/title. --> |
||||||
|
<!ELEMENT package (#PCDATA)> |
||||||
|
<!ATTLIST package |
||||||
|
%basic.atts; |
||||||
|
%reference.atts;> |
||||||
|
|
||||||
|
<!-- Also used as the `module_section` identifier/title. --> |
||||||
|
<!ELEMENT module (#PCDATA)> |
||||||
|
<!ATTLIST module |
||||||
|
%basic.atts; |
||||||
|
%reference.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Also used as the `class_section` identifier/title, and in the |
||||||
|
`inheritance` element. |
||||||
|
--> |
||||||
|
<!ELEMENT class (#PCDATA)> |
||||||
|
<!ATTLIST class |
||||||
|
%basic.atts; |
||||||
|
%reference.atts;> |
||||||
|
|
||||||
|
<!-- Also used as the `method_section` identifier/title. --> |
||||||
|
<!ELEMENT method (#PCDATA)> |
||||||
|
<!ATTLIST method |
||||||
|
%basic.atts; |
||||||
|
%reference.atts;> |
||||||
|
|
||||||
|
<!-- Also used as the `function_section` identifier/title. --> |
||||||
|
<!ELEMENT function (#PCDATA)> |
||||||
|
<!ATTLIST function |
||||||
|
%basic.atts; |
||||||
|
%reference.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
??? Use this instead of the ``*_attribute`` elements below? Add a |
||||||
|
"type" attribute to differentiate? |
||||||
|
|
||||||
|
Also used as the identifier/title for `module_attribute_section`, |
||||||
|
`class_attribute_section`, and `instance_attribute_section`. |
||||||
|
--> |
||||||
|
<!ELEMENT attribute (#PCDATA)> |
||||||
|
<!ATTLIST attribute |
||||||
|
%basic.atts; |
||||||
|
%reference.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Also used as the `module_attribute_section` identifier/title. A module |
||||||
|
attribute is an exported module-level global variable. |
||||||
|
--> |
||||||
|
<!ELEMENT module_attribute (#PCDATA)> |
||||||
|
<!ATTLIST module_attribute |
||||||
|
%basic.atts; |
||||||
|
%reference.atts;> |
||||||
|
|
||||||
|
<!-- Also used as the `class_attribute_section` identifier/title. --> |
||||||
|
<!ELEMENT class_attribute (#PCDATA)> |
||||||
|
<!ATTLIST class_attribute |
||||||
|
%basic.atts; |
||||||
|
%reference.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Also used as the `instance_attribute_section` identifier/title. |
||||||
|
--> |
||||||
|
<!ELEMENT instance_attribute (#PCDATA)> |
||||||
|
<!ATTLIST instance_attribute |
||||||
|
%basic.atts; |
||||||
|
%reference.atts;> |
||||||
|
|
||||||
|
<!ELEMENT variable (#PCDATA)> |
||||||
|
<!ATTLIST variable |
||||||
|
%basic.atts; |
||||||
|
%reference.atts;> |
||||||
|
|
||||||
|
<!-- Also used in `parameter_list`. --> |
||||||
|
<!ELEMENT parameter (#PCDATA)> |
||||||
|
<!ATTLIST parameter |
||||||
|
%basic.atts; |
||||||
|
%reference.atts; |
||||||
|
excess_positional %yesorno; #IMPLIED |
||||||
|
excess_keyword %yesorno; #IMPLIED> |
||||||
|
|
||||||
|
<!ELEMENT type (#PCDATA)> |
||||||
|
<!ATTLIST type |
||||||
|
%basic.atts; |
||||||
|
%reference.atts;> |
||||||
|
|
||||||
|
<!ELEMENT exception_class (#PCDATA)> |
||||||
|
<!ATTLIST exception_class |
||||||
|
%basic.atts; |
||||||
|
%reference.atts;> |
||||||
|
|
||||||
|
<!ELEMENT warning_class (#PCDATA)> |
||||||
|
<!ATTLIST warning_class |
||||||
|
%basic.atts; |
||||||
|
%reference.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Local Variables: |
||||||
|
mode: sgml |
||||||
|
indent-tabs-mode: nil |
||||||
|
fill-column: 70 |
||||||
|
End: |
||||||
|
--> |
@ -0,0 +1,208 @@ |
|||||||
|
===================================== |
||||||
|
The Docutils_ Subversion Repository |
||||||
|
===================================== |
||||||
|
|
||||||
|
:Author: Lea Wiemann |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Revision: $Revision: 7800 $ |
||||||
|
:Date: $Date: 2015-02-24 14:01:43 +0100 (Di, 24 Feb 2015) $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
.. _Docutils: http://docutils.sourceforge.net/ |
||||||
|
|
||||||
|
.. admonition:: Quick Instructions |
||||||
|
|
||||||
|
To get a checkout of the Docutils source tree (with the |
||||||
|
sandboxes), type :: |
||||||
|
|
||||||
|
svn checkout http://svn.code.sf.net/p/docutils/code/trunk docutils-code |
||||||
|
|
||||||
|
|
||||||
|
If you are going to commit changes to the repository, please read |
||||||
|
the **whole document**, especially the section "`Information for |
||||||
|
Developers`_"! |
||||||
|
|
||||||
|
.. important:: |
||||||
|
As of 2013-03-13 the subversion urls have changed. |
||||||
|
|
||||||
|
Docutils uses a Subversion_ repository located at |
||||||
|
``docutils.svn.sourceforge.net``. |
||||||
|
Subversion is exhaustively documented in the `Subversion Book`_ (svnbook). |
||||||
|
|
||||||
|
While Unix and Mac OS X users will probably prefer the standard |
||||||
|
Subversion command line interface, Windows user may want to try |
||||||
|
TortoiseSVN_, a convenient explorer extension. The instructions apply |
||||||
|
analogously. |
||||||
|
|
||||||
|
There is a git_ mirror at http://repo.or.cz/docutils.git providing |
||||||
|
`web access`_ and the base for `creating a local git clone`_. |
||||||
|
|
||||||
|
For the project policy on repository use (check-in requirements, |
||||||
|
branching, etc.), please see the `Docutils Project Policies`__. |
||||||
|
|
||||||
|
__ policies.html#subversion-repository |
||||||
|
|
||||||
|
.. _Subversion: http://subversion.tigris.org/ |
||||||
|
.. _Subversion Book: http://svnbook.red-bean.com/ |
||||||
|
.. _TortoiseSVN: http://tortoisesvn.tigris.org/ |
||||||
|
.. _SourceForge.net: http://sourceforge.net/ |
||||||
|
.. _git: http://git-scm.com/ |
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
|
||||||
|
Accessing the Repository |
||||||
|
======================== |
||||||
|
|
||||||
|
General Information |
||||||
|
------------------- |
||||||
|
|
||||||
|
Web Access |
||||||
|
~~~~~~~~~~ |
||||||
|
|
||||||
|
The repository can be browsed and examined via the web at |
||||||
|
http://sourceforge.net/p/docutils/code |
||||||
|
|
||||||
|
Alternatively, use the web interface of the git mirror at |
||||||
|
http://repo.or.cz/w/docutils.git. |
||||||
|
|
||||||
|
|
||||||
|
Repository Access Methods |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
|
||||||
|
To get a checkout of the Docutils repository, first determine the root |
||||||
|
of the repository depending on your preferred protocol: |
||||||
|
|
||||||
|
anonymous access: (read only) |
||||||
|
``http://svn.code.sf.net/p/docutils/code`` |
||||||
|
|
||||||
|
`developer access`_: (read and write) |
||||||
|
``svn+ssh://<USERNAME>@svn.code.sf.net/p/docutils/code`` |
||||||
|
|
||||||
|
.. git clone: (read only) |
||||||
|
``git clone git://repo.or.cz/docutils.git`` |
||||||
|
|
||||||
|
Checking Out the Repository |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
|
||||||
|
To check out only the current main source tree of Docutils, type :: |
||||||
|
|
||||||
|
svn checkout ROOT/trunk/docutils |
||||||
|
|
||||||
|
(Substitute your preferred repository root for ROOT.) To check out |
||||||
|
everything (main tree, sandboxes, web site, and parallel projects), |
||||||
|
type :: |
||||||
|
|
||||||
|
svn checkout ROOT/trunk docutils |
||||||
|
|
||||||
|
This will create a working copy of the whole trunk in a new directory |
||||||
|
called ``docutils``. |
||||||
|
|
||||||
|
Note that you probably do *not* want to check out the ROOT itself |
||||||
|
(without "/trunk"), because then you'd end up fetching the whole |
||||||
|
Docutils tree for every branch and tag over and over again. |
||||||
|
|
||||||
|
To update your working copy later on, ``cd`` into the working copy and |
||||||
|
type :: |
||||||
|
|
||||||
|
svn update |
||||||
|
|
||||||
|
Creating a local git clone |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
|
||||||
|
Users of git_ can clone a mirror of the docutils repository with :: |
||||||
|
|
||||||
|
git clone git://repo.or.cz/docutils.git |
||||||
|
|
||||||
|
and proceed according to the `git documentation`_. |
||||||
|
|
||||||
|
.. _git documentation: http://git-scm.com/documentation |
||||||
|
|
||||||
|
Switching the Repository Root |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
|
||||||
|
If you changed your mind and want to use a different repository root, |
||||||
|
``cd`` into your working copy and type:: |
||||||
|
|
||||||
|
svn switch --relocate OLDROOT NEWROOT |
||||||
|
|
||||||
|
.. _developer access: |
||||||
|
|
||||||
|
Information for Developers |
||||||
|
-------------------------- |
||||||
|
|
||||||
|
If you would like to have write access to the repository, register |
||||||
|
with SourceForge.net_ and send your SourceForge.net |
||||||
|
user names to docutils-develop@lists.sourceforge.net. |
||||||
|
(Note that there may be a delay of several hours until you can commit |
||||||
|
changes to the repository.) |
||||||
|
|
||||||
|
Sourceforge subversion access is documented `here`__ |
||||||
|
|
||||||
|
__ http://sourceforge.net/p/forge/documentation/svn/ |
||||||
|
|
||||||
|
|
||||||
|
Setting Up Your Subversion Client For Development |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
|
||||||
|
Before commiting changes to the repository, please ensure that the |
||||||
|
following lines are contained (and uncommented) in your local |
||||||
|
~/.subversion/config file, so that new files are added with the |
||||||
|
correct properties set:: |
||||||
|
|
||||||
|
[miscellany] |
||||||
|
# For your convenience: |
||||||
|
global-ignores = ... *.pyc ... |
||||||
|
# For correct properties: |
||||||
|
enable-auto-props = yes |
||||||
|
|
||||||
|
[auto-props] |
||||||
|
*.py = svn:eol-style=native;svn:keywords=Author Date Id Revision |
||||||
|
*.txt = svn:eol-style=native;svn:keywords=Author Date Id Revision |
||||||
|
*.html = svn:eol-style=native;svn:keywords=Author Date Id Revision |
||||||
|
*.xml = svn:eol-style=native;svn:keywords=Author Date Id Revision |
||||||
|
*.tex = svn:eol-style=native;svn:keywords=Author Date Id Revision |
||||||
|
*.css = svn:eol-style=native;svn:keywords=Author Date Id Revision |
||||||
|
*.patch = svn:eol-style=native |
||||||
|
*.sh = svn:eol-style=native;svn:executable;svn:keywords=Author Date Id Revision |
||||||
|
*.png = svn:mime-type=image/png |
||||||
|
*.jpg = svn:mime-type=image/jpeg |
||||||
|
*.gif = svn:mime-type=image/gif |
||||||
|
|
||||||
|
|
||||||
|
Repository Layout |
||||||
|
================= |
||||||
|
|
||||||
|
The following tree shows the repository layout:: |
||||||
|
|
||||||
|
docutils/ |
||||||
|
|-- branches/ |
||||||
|
| |-- branch1/ |
||||||
|
| | |-- docutils/ |
||||||
|
| | |-- sandbox/ |
||||||
|
| | `-- web/ |
||||||
|
| `-- branch2/ |
||||||
|
| |-- docutils/ |
||||||
|
| |-- sandbox/ |
||||||
|
| `-- web/ |
||||||
|
|-- tags/ |
||||||
|
| |-- tag1/ |
||||||
|
| | |-- docutils/ |
||||||
|
| | |-- sandbox/ |
||||||
|
| | `-- web/ |
||||||
|
| `-- tag2/ |
||||||
|
| |-- docutils/ |
||||||
|
| |-- sandbox/ |
||||||
|
| `-- web/ |
||||||
|
`-- trunk/ |
||||||
|
|-- docutils/ |
||||||
|
|-- sandbox/ |
||||||
|
`-- web/ |
||||||
|
|
||||||
|
The main source tree lives at ``docutils/trunk/docutils/``, next to |
||||||
|
the sandboxes (``docutils/trunk/sandbox/``) and the web site files |
||||||
|
(``docutils/trunk/web/``). |
||||||
|
|
||||||
|
``docutils/branches/`` and ``docutils/tags/`` contain (shallow) copies |
||||||
|
of either the whole trunk or only the main source tree |
||||||
|
(``docutils/trunk/docutils``). |
@ -0,0 +1,196 @@ |
|||||||
|
================================ |
||||||
|
Docutils_ Internationalization |
||||||
|
================================ |
||||||
|
|
||||||
|
:Author: David Goodger |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Date: $Date: 2014-07-07 05:12:02 +0200 (Mo, 07 Jul 2014) $ |
||||||
|
:Revision: $Revision: 7769 $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
|
||||||
|
This document describes the internationalization facilities of the |
||||||
|
Docutils_ project. `Introduction to i18n`_ by Tomohiro KUBOTA is a |
||||||
|
good general reference. "Internationalization" is often abbreviated |
||||||
|
as "i18n": "i" + 18 letters + "n". |
||||||
|
|
||||||
|
.. Note:: |
||||||
|
|
||||||
|
The i18n facilities of Docutils should be considered a "first |
||||||
|
draft". They work so far, but improvements are welcome. |
||||||
|
Specifically, standard i18n facilities like "gettext" have yet to |
||||||
|
be explored. |
||||||
|
|
||||||
|
Docutils is designed to work flexibly with text in multiple languages |
||||||
|
(one language at a time). Language-specific features are (or should |
||||||
|
be [#]_) fully parameterized. To enable a new language, two modules |
||||||
|
have to be added to the project: one for Docutils itself (the |
||||||
|
`Docutils Language Module`_) and one for the reStructuredText parser |
||||||
|
(the `reStructuredText Language Module`_). |
||||||
|
|
||||||
|
.. [#] If anything in Docutils is insufficiently parameterized, it |
||||||
|
should be considered a bug. Please report bugs to the Docutils |
||||||
|
project bug tracker on SourceForge at |
||||||
|
http://sourceforge.net/p/docutils/bugs/ |
||||||
|
|
||||||
|
.. _Docutils: http://docutils.sourceforge.net/ |
||||||
|
.. _Introduction to i18n: |
||||||
|
http://www.debian.org/doc/manuals/intro-i18n/ |
||||||
|
|
||||||
|
|
||||||
|
Language Module Names |
||||||
|
===================== |
||||||
|
|
||||||
|
Language modules are named using `language tags`_ as defined in |
||||||
|
`BCP 47`_. [#]_ in lowercase, converting hyphens to underscores [#]_. |
||||||
|
|
||||||
|
A typical language identifier consists of a 2-letter language code |
||||||
|
from `ISO 639`_ (3-letter codes can be used if no 2-letter code |
||||||
|
exists). The language identifier can have an optional subtag, |
||||||
|
typically for variations based on country (from `ISO 3166`_ 2-letter |
||||||
|
country codes). If no language identifier is specified, the default |
||||||
|
is "en" for English. Examples of module names include ``en.py``, |
||||||
|
``fr.py``, ``ja.py``, and ``pt_br.py``. |
||||||
|
|
||||||
|
.. [#] BCP stands for 'Best Current Practice', and is a persistent |
||||||
|
name for a series of RFCs whose numbers change as they are updated. |
||||||
|
The latest RFC describing language tag syntax is RFC 5646, Tags for |
||||||
|
the Identification of Languages, and it obsoletes the older RFCs |
||||||
|
4646, 3066 and 1766. |
||||||
|
|
||||||
|
.. [#] Subtags are separated from primary tags by underscores instead |
||||||
|
of hyphens, to conform to Python naming rules. |
||||||
|
|
||||||
|
.. _language tags: http://www.w3.org/International/articles/language-tags/ |
||||||
|
.. _BCP 47: http://www.rfc-editor.org/rfc/bcp/bcp47.txt |
||||||
|
.. _ISO 639: http://www.loc.gov/standards/iso639-2/php/English_list.php |
||||||
|
.. _ISO 3166: http://www.iso.ch/iso/en/prods-services/iso3166ma/ |
||||||
|
02iso-3166-code-lists/index.html |
||||||
|
|
||||||
|
|
||||||
|
Python Code |
||||||
|
=========== |
||||||
|
|
||||||
|
Generally Python code in Docutils is ASCII-only. In language modules, |
||||||
|
Unicode-escapes can be used for non-ASCII characters. |
||||||
|
|
||||||
|
`PEP 263`_ introduces source code encodings to Python modules, |
||||||
|
implemented beginning in Python 2.3. Especially for languages with |
||||||
|
non-Latin scripts, using UTF-8 encoded literal Unicode strings increases the |
||||||
|
readability. Start the source code file with the magic comment:: |
||||||
|
|
||||||
|
# -*- coding: utf-8 -*- |
||||||
|
|
||||||
|
As mentioned in the note above, developers are invited to explore |
||||||
|
"gettext" and other i18n technologies. |
||||||
|
|
||||||
|
.. _PEP 263: http://www.python.org/peps/pep-0263.html |
||||||
|
|
||||||
|
|
||||||
|
Docutils Language Module |
||||||
|
======================== |
||||||
|
|
||||||
|
Modules in ``docutils/languages`` contain language mappings for |
||||||
|
markup-independent language-specific features of Docutils. To make a |
||||||
|
new language module, just copy the ``en.py`` file, rename it with the |
||||||
|
code for your language (see `Language Module Names`_ above), and |
||||||
|
translate the terms as described below. |
||||||
|
|
||||||
|
Each Docutils language module contains three module attributes: |
||||||
|
|
||||||
|
``labels`` |
||||||
|
This is a mapping of node class names to language-dependent |
||||||
|
boilerplate label text. The label text is used by Writer |
||||||
|
components when they encounter document tree elements whose class |
||||||
|
names are the mapping keys. |
||||||
|
|
||||||
|
The entry values (*not* the keys) should be translated to the |
||||||
|
target language. |
||||||
|
|
||||||
|
``bibliographic_fields`` |
||||||
|
This is a mapping of language-dependent field names (converted to |
||||||
|
lower case) to canonical field names (keys of |
||||||
|
``DocInfo.biblio_notes`` in ``docutils.transforms.frontmatter``). |
||||||
|
It is used when transforming bibliographic fields. |
||||||
|
|
||||||
|
The keys should be translated to the target language. |
||||||
|
|
||||||
|
``author_separators`` |
||||||
|
This is a list of strings used to parse the 'Authors' |
||||||
|
bibliographic field. They separate individual authors' names, and |
||||||
|
are tried in order (i.e., earlier items take priority, and the |
||||||
|
first item that matches wins). The English-language module |
||||||
|
defines them as ``[';', ',']``; semi-colons can be used to |
||||||
|
separate names like "Arthur Pewtie, Esq.". |
||||||
|
|
||||||
|
Most languages won't have to "translate" this list. |
||||||
|
|
||||||
|
|
||||||
|
reStructuredText Language Module |
||||||
|
================================ |
||||||
|
|
||||||
|
Modules in ``docutils/parsers/rst/languages`` contain language |
||||||
|
mappings for language-specific features of the reStructuredText |
||||||
|
parser. To make a new language module, just copy the ``en.py`` file, |
||||||
|
rename it with the code for your language (see `Language Module |
||||||
|
Names`_ above), and translate the terms as described below. |
||||||
|
|
||||||
|
Each reStructuredText language module contains two module attributes: |
||||||
|
|
||||||
|
``directives`` |
||||||
|
This is a mapping from language-dependent directive names to |
||||||
|
canonical directive names. The canonical directive names are |
||||||
|
registered in ``docutils/parsers/rst/directives/__init__.py``, in |
||||||
|
``_directive_registry``. |
||||||
|
|
||||||
|
The keys should be translated to the target language. Synonyms |
||||||
|
(multiple keys with the same values) are allowed; this is useful |
||||||
|
for abbreviations. |
||||||
|
|
||||||
|
``roles`` |
||||||
|
This is a mapping language-dependent role names to canonical role |
||||||
|
names for interpreted text. The canonical directive names are |
||||||
|
registered in ``docutils/parsers/rst/states.py``, in |
||||||
|
``Inliner._interpreted_roles`` (this may change). |
||||||
|
|
||||||
|
The keys should be translated to the target language. Synonyms |
||||||
|
(multiple keys with the same values) are allowed; this is useful |
||||||
|
for abbreviations. |
||||||
|
|
||||||
|
|
||||||
|
Testing the Language Modules |
||||||
|
============================ |
||||||
|
|
||||||
|
Whenever a new language module is added or an existing one modified, |
||||||
|
the unit tests should be run. The test modules can be found in the |
||||||
|
docutils/test directory from code_ or from the `latest snapshot`_. |
||||||
|
|
||||||
|
The ``test_language.py`` module can be run as a script. With no |
||||||
|
arguments, it will test all language modules. With one or more |
||||||
|
language codes, it will test just those languages. For example:: |
||||||
|
|
||||||
|
$ python test_language.py en |
||||||
|
.. |
||||||
|
---------------------------------------- |
||||||
|
Ran 2 tests in 0.095s |
||||||
|
|
||||||
|
OK |
||||||
|
|
||||||
|
Use the "alltests.py" script to run all test modules, exhaustively |
||||||
|
testing the parser and other parts of the Docutils system. |
||||||
|
|
||||||
|
.. _code: https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/ |
||||||
|
.. _latest snapshot: https://sourceforge.net/p/docutils/code/HEAD/tarball |
||||||
|
|
||||||
|
|
||||||
|
Submitting the Language Modules |
||||||
|
=============================== |
||||||
|
|
||||||
|
If you do not have repository write access and want to contribute your |
||||||
|
language modules, feel free to submit them via the `SourceForge patch |
||||||
|
tracker`__. |
||||||
|
|
||||||
|
__ http://sourceforge.net/p/docutils/patches/ |
@ -0,0 +1,430 @@ |
|||||||
|
======================================= |
||||||
|
Creating reStructuredText_ Directives |
||||||
|
======================================= |
||||||
|
|
||||||
|
:Authors: Dethe Elza, David Goodger, Lea Wiemann |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Date: $Date: 2012-01-03 20:23:53 +0100 (Di, 03 Jan 2012) $ |
||||||
|
:Revision: $Revision: 7302 $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
.. _reStructuredText: http://docutils.sourceforge.net/rst.html |
||||||
|
|
||||||
|
|
||||||
|
Directives are the primary extension mechanism of reStructuredText. |
||||||
|
This document aims to make the creation of new directives as easy and |
||||||
|
understandable as possible. There are only a couple of |
||||||
|
reStructuredText-specific features the developer needs to know to |
||||||
|
create a basic directive. |
||||||
|
|
||||||
|
The syntax of directives is detailed in the `reStructuredText Markup |
||||||
|
Specification`_, and standard directives are described in |
||||||
|
`reStructuredText Directives`_. |
||||||
|
|
||||||
|
Directives are a reStructuredText markup/parser concept. There is no |
||||||
|
"directive" document tree element, no single element that corresponds |
||||||
|
exactly to the concept of directives. Instead, choose the most |
||||||
|
appropriate elements from the existing Docutils elements. Directives |
||||||
|
build structures using the existing building blocks. See `The |
||||||
|
Docutils Document Tree`_ and the ``docutils.nodes`` module for more |
||||||
|
about the building blocks of Docutils documents. |
||||||
|
|
||||||
|
.. _reStructuredText Markup Specification: |
||||||
|
../ref/rst/restructuredtext.html#directives |
||||||
|
.. _reStructuredText Directives: ../ref/rst/directives.html |
||||||
|
.. _The Docutils Document Tree: ../ref/doctree.html |
||||||
|
|
||||||
|
|
||||||
|
.. contents:: Table of Contents |
||||||
|
|
||||||
|
|
||||||
|
The Directive Class |
||||||
|
=================== |
||||||
|
|
||||||
|
Directives are created by defining a directive class that inherits |
||||||
|
from ``docutils.parsers.rst.Directive``:: |
||||||
|
|
||||||
|
from docutils.parsers import rst |
||||||
|
|
||||||
|
class MyDirective(rst.Directive): |
||||||
|
|
||||||
|
... |
||||||
|
|
||||||
|
To understand how to implement the directive, let's have a look at the |
||||||
|
docstring of the ``Directive`` base class:: |
||||||
|
|
||||||
|
>>> from docutils.parsers import rst |
||||||
|
>>> print rst.Directive.__doc__ |
||||||
|
|
||||||
|
Base class for reStructuredText directives. |
||||||
|
|
||||||
|
The following attributes may be set by subclasses. They are |
||||||
|
interpreted by the directive parser (which runs the directive |
||||||
|
class): |
||||||
|
|
||||||
|
- `required_arguments`: The number of required arguments (default: |
||||||
|
0). |
||||||
|
|
||||||
|
- `optional_arguments`: The number of optional arguments (default: |
||||||
|
0). |
||||||
|
|
||||||
|
- `final_argument_whitespace`: A boolean, indicating if the final |
||||||
|
argument may contain whitespace (default: False). |
||||||
|
|
||||||
|
- `option_spec`: A dictionary, mapping known option names to |
||||||
|
conversion functions such as `int` or `float` (default: {}, no |
||||||
|
options). Several conversion functions are defined in the |
||||||
|
directives/__init__.py module. |
||||||
|
|
||||||
|
Option conversion functions take a single parameter, the option |
||||||
|
argument (a string or ``None``), validate it and/or convert it |
||||||
|
to the appropriate form. Conversion functions may raise |
||||||
|
`ValueError` and `TypeError` exceptions. |
||||||
|
|
||||||
|
- `has_content`: A boolean; True if content is allowed. Client |
||||||
|
code must handle the case where content is required but not |
||||||
|
supplied (an empty content list will be supplied). |
||||||
|
|
||||||
|
Arguments are normally single whitespace-separated words. The |
||||||
|
final argument may contain whitespace and/or newlines if |
||||||
|
`final_argument_whitespace` is True. |
||||||
|
|
||||||
|
If the form of the arguments is more complex, specify only one |
||||||
|
argument (either required or optional) and set |
||||||
|
`final_argument_whitespace` to True; the client code must do any |
||||||
|
context-sensitive parsing. |
||||||
|
|
||||||
|
When a directive implementation is being run, the directive class |
||||||
|
is instantiated, and the `run()` method is executed. During |
||||||
|
instantiation, the following instance variables are set: |
||||||
|
|
||||||
|
- ``name`` is the directive type or name (string). |
||||||
|
|
||||||
|
- ``arguments`` is the list of positional arguments (strings). |
||||||
|
|
||||||
|
- ``options`` is a dictionary mapping option names (strings) to |
||||||
|
values (type depends on option conversion functions; see |
||||||
|
`option_spec` above). |
||||||
|
|
||||||
|
- ``content`` is a list of strings, the directive content line by line. |
||||||
|
|
||||||
|
- ``lineno`` is the line number of the first line of the directive. |
||||||
|
|
||||||
|
- ``content_offset`` is the line offset of the first line of the content from |
||||||
|
the beginning of the current input. Used when initiating a nested parse. |
||||||
|
|
||||||
|
- ``block_text`` is a string containing the entire directive. |
||||||
|
|
||||||
|
- ``state`` is the state which called the directive function. |
||||||
|
|
||||||
|
- ``state_machine`` is the state machine which controls the state which called |
||||||
|
the directive function. |
||||||
|
|
||||||
|
Directive functions return a list of nodes which will be inserted |
||||||
|
into the document tree at the point where the directive was |
||||||
|
encountered. This can be an empty list if there is nothing to |
||||||
|
insert. |
||||||
|
|
||||||
|
For ordinary directives, the list must contain body elements or |
||||||
|
structural elements. Some directives are intended specifically |
||||||
|
for substitution definitions, and must return a list of `Text` |
||||||
|
nodes and/or inline elements (suitable for inline insertion, in |
||||||
|
place of the substitution reference). Such directives must verify |
||||||
|
substitution definition context, typically using code like this:: |
||||||
|
|
||||||
|
if not isinstance(state, states.SubstitutionDef): |
||||||
|
error = state_machine.reporter.error( |
||||||
|
'Invalid context: the "%s" directive can only be used ' |
||||||
|
'within a substitution definition.' % (name), |
||||||
|
nodes.literal_block(block_text, block_text), line=lineno) |
||||||
|
return [error] |
||||||
|
|
||||||
|
>>> |
||||||
|
|
||||||
|
|
||||||
|
Option Conversion Functions |
||||||
|
=========================== |
||||||
|
|
||||||
|
An option specification (``Directive.option_spec``) must be defined |
||||||
|
detailing the options available to the directive. An option spec is a |
||||||
|
mapping of option name to conversion function; conversion functions |
||||||
|
are applied to each option value to check validity and convert them to |
||||||
|
the expected type. Python's built-in conversion functions are often |
||||||
|
usable for this, such as ``int``, ``float``. Other useful conversion |
||||||
|
functions are included in the ``docutils.parsers.rst.directives`` |
||||||
|
package (in the ``__init__.py`` module): |
||||||
|
|
||||||
|
- ``flag``: For options with no option arguments. Checks for an |
||||||
|
argument (raises ``ValueError`` if found), returns ``None`` for |
||||||
|
valid flag options. |
||||||
|
|
||||||
|
- ``unchanged_required``: Returns the text argument, unchanged. |
||||||
|
Raises ``ValueError`` if no argument is found. |
||||||
|
|
||||||
|
- ``unchanged``: Returns the text argument, unchanged. Returns an |
||||||
|
empty string ("") if no argument is found. |
||||||
|
|
||||||
|
- ``path``: Returns the path argument unwrapped (with newlines |
||||||
|
removed). Raises ``ValueError`` if no argument is found. |
||||||
|
|
||||||
|
- ``uri``: Returns the URI argument with whitespace removed. Raises |
||||||
|
``ValueError`` if no argument is found. |
||||||
|
|
||||||
|
- ``nonnegative_int``: Checks for a nonnegative integer argument, |
||||||
|
and raises ``ValueError`` if not. |
||||||
|
|
||||||
|
- ``class_option``: Converts the argument into an ID-compatible |
||||||
|
string and returns it. Raises ``ValueError`` if no argument is |
||||||
|
found. |
||||||
|
|
||||||
|
- ``unicode_code``: Convert a Unicode character code to a Unicode |
||||||
|
character. |
||||||
|
|
||||||
|
- ``single_char_or_unicode``: A single character is returned as-is. |
||||||
|
Unicode characters codes are converted as in ``unicode_code``. |
||||||
|
|
||||||
|
- ``single_char_or_whitespace_or_unicode``: As with |
||||||
|
``single_char_or_unicode``, but "tab" and "space" are also |
||||||
|
supported. |
||||||
|
|
||||||
|
- ``positive_int``: Converts the argument into an integer. Raises |
||||||
|
ValueError for negative, zero, or non-integer values. |
||||||
|
|
||||||
|
- ``positive_int_list``: Converts a space- or comma-separated list |
||||||
|
of integers into a Python list of integers. Raises ValueError for |
||||||
|
non-positive-integer values. |
||||||
|
|
||||||
|
- ``encoding``: Verfies the encoding argument by lookup. Raises |
||||||
|
ValueError for unknown encodings. |
||||||
|
|
||||||
|
A further utility function, ``choice``, is supplied to enable |
||||||
|
options whose argument must be a member of a finite set of possible |
||||||
|
values. A custom conversion function must be written to use it. |
||||||
|
For example:: |
||||||
|
|
||||||
|
from docutils.parsers.rst import directives |
||||||
|
|
||||||
|
def yesno(argument): |
||||||
|
return directives.choice(argument, ('yes', 'no')) |
||||||
|
|
||||||
|
For example, here is an option spec for a directive which allows two |
||||||
|
options, "name" and "value", each with an option argument:: |
||||||
|
|
||||||
|
option_spec = {'name': unchanged, 'value': int} |
||||||
|
|
||||||
|
|
||||||
|
Error Handling |
||||||
|
============== |
||||||
|
|
||||||
|
If your directive implementation encounters an error during |
||||||
|
processing, you should call ``self.error()`` inside the ``run()`` |
||||||
|
method:: |
||||||
|
|
||||||
|
if error_condition: |
||||||
|
raise self.error('Error message.') |
||||||
|
|
||||||
|
The ``self.error()`` method will immediately raise an exception that |
||||||
|
will be caught by the reStructuredText directive handler. The |
||||||
|
directive handler will then insert an error-level system message in |
||||||
|
the document at the place where the directive occurred. |
||||||
|
|
||||||
|
Instead of ``self.error``, you can also use ``self.severe`` and |
||||||
|
``self.warning`` for more or less severe problems. |
||||||
|
|
||||||
|
If you want to return a system message *and* document contents, you need to |
||||||
|
create the system message yourself instead of using the ``self.error`` |
||||||
|
convenience method:: |
||||||
|
|
||||||
|
def run(self): |
||||||
|
# Create node(s). |
||||||
|
node = nodes.paragraph(...) |
||||||
|
# Node list to return. |
||||||
|
node_list = [node] |
||||||
|
if error_condition: |
||||||
|
# Create system message. |
||||||
|
error = self.reporter.error( |
||||||
|
'Error in "%s" directive: Your error message.' % self.name, |
||||||
|
nodes.literal_block(block_text, block_text), line=lineno) |
||||||
|
node_list.append(error) |
||||||
|
return node_list |
||||||
|
|
||||||
|
|
||||||
|
Register the Directive |
||||||
|
====================== |
||||||
|
|
||||||
|
* If the directive is a general-use **addition to the Docutils core**, |
||||||
|
it must be registered with the parser and language mappings added: |
||||||
|
|
||||||
|
1. Register the new directive using its canonical name in |
||||||
|
``docutils/parsers/rst/directives/__init__.py``, in the |
||||||
|
``_directive_registry`` dictionary. This allows the |
||||||
|
reStructuredText parser to find and use the directive. |
||||||
|
|
||||||
|
2. Add an entry to the ``directives`` dictionary in |
||||||
|
``docutils/parsers/rst/languages/en.py`` for the directive, mapping |
||||||
|
the English name to the canonical name (both lowercase). Usually |
||||||
|
the English name and the canonical name are the same. |
||||||
|
|
||||||
|
3. Update all the other language modules as well. For languages in |
||||||
|
which you are proficient, please add translations. For other |
||||||
|
languages, add the English directive name plus "(translation |
||||||
|
required)". |
||||||
|
|
||||||
|
* If the directive is **application-specific**, use the |
||||||
|
``register_directive`` function:: |
||||||
|
|
||||||
|
from docutils.parsers.rst import directives |
||||||
|
directives.register_directive(directive_name, directive_class) |
||||||
|
|
||||||
|
|
||||||
|
Examples |
||||||
|
======== |
||||||
|
|
||||||
|
For the most direct and accurate information, "Use the Source, Luke!". |
||||||
|
All standard directives are documented in `reStructuredText |
||||||
|
Directives`_, and the source code implementing them is located in the |
||||||
|
``docutils/parsers/rst/directives`` package. The ``__init__.py`` |
||||||
|
module contains a mapping of directive name to module and function |
||||||
|
name. Several representative directives are described below. |
||||||
|
|
||||||
|
|
||||||
|
Admonitions |
||||||
|
----------- |
||||||
|
|
||||||
|
`Admonition directives`__, such as "note" and "caution", are quite |
||||||
|
simple. They have no directive arguments or options. Admonition |
||||||
|
directive content is interpreted as ordinary reStructuredText. |
||||||
|
|
||||||
|
__ ../ref/rst/directives.html#specific-admonitions |
||||||
|
|
||||||
|
The resulting document tree for a simple reStructuredText line |
||||||
|
"``.. note:: This is a note.``" looks as follows: |
||||||
|
|
||||||
|
<note> |
||||||
|
<paragraph> |
||||||
|
This is a note. |
||||||
|
|
||||||
|
The directive class for the "note" directive simply derives from a |
||||||
|
generic admonition directive class:: |
||||||
|
|
||||||
|
class Note(BaseAdmonition): |
||||||
|
|
||||||
|
node_class = nodes.note |
||||||
|
|
||||||
|
Note that the only thing distinguishing the various admonition |
||||||
|
directives is the element (node class) generated. In the code above, |
||||||
|
the node class is set as a class attribute and is read by the |
||||||
|
``run()`` method of ``BaseAdmonition``, where the actual processing |
||||||
|
takes place:: |
||||||
|
|
||||||
|
# Import Docutils document tree nodes module. |
||||||
|
from docutils import nodes |
||||||
|
# Import Directive base class. |
||||||
|
from docutils.parsers.rst import Directive |
||||||
|
|
||||||
|
class BaseAdmonition(Directive): |
||||||
|
|
||||||
|
required_arguments = 0 |
||||||
|
optional_arguments = 0 |
||||||
|
final_argument_whitespace = True |
||||||
|
option_spec = {} |
||||||
|
has_content = True |
||||||
|
|
||||||
|
node_class = None |
||||||
|
"""Subclasses must set this to the appropriate admonition node class.""" |
||||||
|
|
||||||
|
def run(self): |
||||||
|
# Raise an error if the directive does not have contents. |
||||||
|
self.assert_has_content() |
||||||
|
text = '\n'.join(self.content) |
||||||
|
# Create the admonition node, to be populated by `nested_parse`. |
||||||
|
admonition_node = self.node_class(rawsource=text) |
||||||
|
# Parse the directive contents. |
||||||
|
self.state.nested_parse(self.content, self.content_offset, |
||||||
|
admonition_node) |
||||||
|
return [admonition_node] |
||||||
|
|
||||||
|
Three things are noteworthy in the ``run()`` method above: |
||||||
|
|
||||||
|
* The ``admonition_node = self.node_class(text)`` line creates the |
||||||
|
wrapper element, using the class set by the specific admonition |
||||||
|
subclasses (as in note, ``node_class = nodes.note``). |
||||||
|
|
||||||
|
* The call to ``state.nested_parse()`` is what does the actual |
||||||
|
processing. It parses the directive content and adds any generated |
||||||
|
elements as child elements of ``admonition_node``. |
||||||
|
|
||||||
|
* If there was no directive content, the ``assert_has_content()`` |
||||||
|
convenience method raises an error exception by calling |
||||||
|
``self.error()`` (see `Error Handling`_ above). |
||||||
|
|
||||||
|
|
||||||
|
"image" |
||||||
|
------- |
||||||
|
|
||||||
|
.. _image: ../ref/rst/directives.html#image |
||||||
|
|
||||||
|
The "image_" directive is used to insert a picture into a document. |
||||||
|
This directive has one argument, the path to the image file, and |
||||||
|
supports several options. There is no directive content. Here's an |
||||||
|
early version of the image directive class:: |
||||||
|
|
||||||
|
# Import Docutils document tree nodes module. |
||||||
|
from docutils import nodes |
||||||
|
# Import ``directives`` module (contains conversion functions). |
||||||
|
from docutils.parsers.rst import directives |
||||||
|
# Import Directive base class. |
||||||
|
from docutils.parsers.rst import Directive |
||||||
|
|
||||||
|
def align(argument): |
||||||
|
"""Conversion function for the "align" option.""" |
||||||
|
return directives.choice(argument, ('left', 'center', 'right')) |
||||||
|
|
||||||
|
class Image(Directive): |
||||||
|
|
||||||
|
required_arguments = 1 |
||||||
|
optional_arguments = 0 |
||||||
|
final_argument_whitespace = True |
||||||
|
option_spec = {'alt': directives.unchanged, |
||||||
|
'height': directives.nonnegative_int, |
||||||
|
'width': directives.nonnegative_int, |
||||||
|
'scale': directives.nonnegative_int, |
||||||
|
'align': align, |
||||||
|
} |
||||||
|
has_content = False |
||||||
|
|
||||||
|
def run(self): |
||||||
|
reference = directives.uri(self.arguments[0]) |
||||||
|
self.options['uri'] = reference |
||||||
|
image_node = nodes.image(rawsource=self.block_text, |
||||||
|
**self.options) |
||||||
|
return [image_node] |
||||||
|
|
||||||
|
Several things are noteworthy in the code above: |
||||||
|
|
||||||
|
* The "image" directive requires a single argument, which is allowed |
||||||
|
to contain whitespace (``final_argument_whitespace = True``). This |
||||||
|
is to allow for long URLs which may span multiple lines. The first |
||||||
|
line of the ``run()`` method joins the URL, discarding any embedded |
||||||
|
whitespace. |
||||||
|
|
||||||
|
* The reference is added to the ``options`` dictionary under the |
||||||
|
"uri" key; this becomes an attribute of the ``nodes.image`` element |
||||||
|
object. Any other attributes have already been set explicitly in |
||||||
|
the reStructuredText source text. |
||||||
|
|
||||||
|
|
||||||
|
The Pending Element |
||||||
|
------------------- |
||||||
|
|
||||||
|
Directives that cause actions to be performed *after* the complete |
||||||
|
document tree has been generated can be implemented using a |
||||||
|
``pending`` node. The ``pending`` node causes a transform_ to be run |
||||||
|
after the document has been parsed. |
||||||
|
|
||||||
|
For an example usage of the ``pending`` node, see the implementation |
||||||
|
of the ``contents`` directive in |
||||||
|
docutils.parsers.rst.directives.parts__. |
||||||
|
|
||||||
|
.. _transform: ../ref/transforms.html |
||||||
|
__ http://docutils.sf.net/docutils/parsers/rst/directives/parts.py |
@ -0,0 +1,228 @@ |
|||||||
|
================================================== |
||||||
|
Creating reStructuredText Interpreted Text Roles |
||||||
|
================================================== |
||||||
|
|
||||||
|
:Authors: David Goodger |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Date: $Date: 2012-01-03 20:23:53 +0100 (Di, 03 Jan 2012) $ |
||||||
|
:Revision: $Revision: 7302 $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
Interpreted text roles are an extension mechanism for inline markup in |
||||||
|
reStructuredText. This document aims to make the creation of new |
||||||
|
roles as easy and understandable as possible. |
||||||
|
|
||||||
|
Standard roles are described in `reStructuredText Interpreted Text |
||||||
|
Roles`_. See the `Interpreted Text`_ section in the `reStructuredText |
||||||
|
Markup Specification`_ for syntax details. |
||||||
|
|
||||||
|
.. _reStructuredText Interpreted Text Roles: ../ref/rst/roles.html |
||||||
|
.. _Interpreted Text: |
||||||
|
../ref/rst/restructuredtext.html#interpreted-text |
||||||
|
.. _reStructuredText Markup Specification: |
||||||
|
../ref/rst/restructuredtext.html |
||||||
|
|
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
|
||||||
|
Define the Role Function |
||||||
|
======================== |
||||||
|
|
||||||
|
The role function creates and returns inline elements (nodes) and does |
||||||
|
any additional processing required. Its signature is as follows:: |
||||||
|
|
||||||
|
def role_fn(name, rawtext, text, lineno, inliner, |
||||||
|
options={}, content=[]): |
||||||
|
code... |
||||||
|
|
||||||
|
# Set function attributes for customization: |
||||||
|
role_fn.options = ... |
||||||
|
role_fn.content = ... |
||||||
|
|
||||||
|
Function attributes are described below (see `Specify Role Function |
||||||
|
Options and Content`_). The role function parameters are as follows: |
||||||
|
|
||||||
|
* ``name``: The local name of the interpreted role, the role name |
||||||
|
actually used in the document. |
||||||
|
|
||||||
|
* ``rawtext``: A string containing the enitre interpreted text input, |
||||||
|
including the role and markup. Return it as a ``problematic`` node |
||||||
|
linked to a system message if a problem is encountered. |
||||||
|
|
||||||
|
* ``text``: The interpreted text content. |
||||||
|
|
||||||
|
* ``lineno``: The line number where the interpreted text begins. |
||||||
|
|
||||||
|
* ``inliner``: The ``docutils.parsers.rst.states.Inliner`` object that |
||||||
|
called role_fn. It contains the several attributes useful for error |
||||||
|
reporting and document tree access. |
||||||
|
|
||||||
|
* ``options``: A dictionary of directive options for customization |
||||||
|
(from the `"role" directive`_), to be interpreted by the role |
||||||
|
function. Used for additional attributes for the generated elements |
||||||
|
and other functionality. |
||||||
|
|
||||||
|
* ``content``: A list of strings, the directive content for |
||||||
|
customization (from the `"role" directive`_). To be interpreted by |
||||||
|
the role function. |
||||||
|
|
||||||
|
Role functions return a tuple of two values: |
||||||
|
|
||||||
|
* A list of nodes which will be inserted into the document tree at the |
||||||
|
point where the interpreted role was encountered (can be an empty |
||||||
|
list). |
||||||
|
|
||||||
|
* A list of system messages, which will be inserted into the document tree |
||||||
|
immediately after the end of the current block (can also be empty). |
||||||
|
|
||||||
|
|
||||||
|
Specify Role Function Options and Content |
||||||
|
========================================= |
||||||
|
|
||||||
|
Function attributes are for customization, and are interpreted by the |
||||||
|
`"role" directive`_. If unspecified, role function attributes are |
||||||
|
assumed to have the value ``None``. Two function attributes are |
||||||
|
recognized: |
||||||
|
|
||||||
|
- ``options``: The option specification. All role functions |
||||||
|
implicitly support the "class" option, unless disabled with an |
||||||
|
explicit ``{'class': None}``. |
||||||
|
|
||||||
|
An option specification must be defined detailing the options |
||||||
|
available to the "role" directive. An option spec is a mapping of |
||||||
|
option name to conversion function; conversion functions are applied |
||||||
|
to each option value to check validity and convert them to the |
||||||
|
expected type. Python's built-in conversion functions are often |
||||||
|
usable for this, such as ``int``, ``float``, and ``bool`` (included |
||||||
|
in Python from version 2.2.1). Other useful conversion functions |
||||||
|
are included in the ``docutils.parsers.rst.directives`` package. |
||||||
|
For further details, see `Creating reStructuredText Directives`_. |
||||||
|
|
||||||
|
- ``content``: A boolean; true if "role" directive content is allowed. |
||||||
|
Role functions must handle the case where content is required but |
||||||
|
not supplied (an empty content list will be supplied). |
||||||
|
|
||||||
|
As of this writing, no roles accept directive content. |
||||||
|
|
||||||
|
Note that unlike directives, the "arguments" function attribute is not |
||||||
|
supported for role customization. Directive arguments are handled by |
||||||
|
the "role" directive itself. |
||||||
|
|
||||||
|
.. _"role" directive: ../ref/rst/directives.html#role |
||||||
|
.. _Creating reStructuredText Directives: |
||||||
|
rst-directives.html#specify-directive-arguments-options-and-content |
||||||
|
|
||||||
|
|
||||||
|
Register the Role |
||||||
|
================= |
||||||
|
|
||||||
|
If the role is a general-use addition to the Docutils core, it must be |
||||||
|
registered with the parser and language mappings added: |
||||||
|
|
||||||
|
1. Register the new role using the canonical name:: |
||||||
|
|
||||||
|
from docutils.parsers.rst import roles |
||||||
|
roles.register_canonical_role(name, role_function) |
||||||
|
|
||||||
|
This code is normally placed immediately after the definition of |
||||||
|
the role funtion. |
||||||
|
|
||||||
|
2. Add an entry to the ``roles`` dictionary in |
||||||
|
``docutils/parsers/rst/languages/en.py`` for the role, mapping the |
||||||
|
English name to the canonical name (both lowercase). Usually the |
||||||
|
English name and the canonical name are the same. Abbreviations |
||||||
|
and other aliases may also be added here. |
||||||
|
|
||||||
|
3. Update all the other language modules as well. For languages in |
||||||
|
which you are proficient, please add translations. For other |
||||||
|
languages, add the English role name plus "(translation required)". |
||||||
|
|
||||||
|
If the role is application-specific, use the ``register_local_role`` |
||||||
|
function:: |
||||||
|
|
||||||
|
from docutils.parsers.rst import roles |
||||||
|
roles.register_local_role(name, role_function) |
||||||
|
|
||||||
|
|
||||||
|
Examples |
||||||
|
======== |
||||||
|
|
||||||
|
For the most direct and accurate information, "Use the Source, Luke!". |
||||||
|
All standard roles are documented in `reStructuredText Interpreted |
||||||
|
Text Roles`_, and the source code implementing them is located in the |
||||||
|
``docutils/parsers/rst/roles.py`` module. Several representative |
||||||
|
roles are described below. |
||||||
|
|
||||||
|
|
||||||
|
Generic Roles |
||||||
|
------------- |
||||||
|
|
||||||
|
Many roles simply wrap a given element around the text. There's a |
||||||
|
special helper function, ``register_generic_role``, which generates a |
||||||
|
role function from the canonical role name and node class:: |
||||||
|
|
||||||
|
register_generic_role('emphasis', nodes.emphasis) |
||||||
|
|
||||||
|
For the implementation of ``register_generic_role``, see the |
||||||
|
``docutils.parsers.rst.roles`` module. |
||||||
|
|
||||||
|
|
||||||
|
RFC Reference Role |
||||||
|
------------------ |
||||||
|
|
||||||
|
This role allows easy references to RFCs_ (Request For Comments |
||||||
|
documents) by automatically providing the base URL, |
||||||
|
http://www.faqs.org/rfcs/, and appending the RFC document itself |
||||||
|
(rfcXXXX.html, where XXXX is the RFC number). For example:: |
||||||
|
|
||||||
|
See :RFC:`2822` for information about email headers. |
||||||
|
|
||||||
|
This is equivalent to:: |
||||||
|
|
||||||
|
See `RFC 2822`__ for information about email headers. |
||||||
|
|
||||||
|
__ http://www.faqs.org/rfcs/rfc2822.html |
||||||
|
|
||||||
|
Here is the implementation of the role:: |
||||||
|
|
||||||
|
def rfc_reference_role(role, rawtext, text, lineno, inliner, |
||||||
|
options={}, content=[]): |
||||||
|
try: |
||||||
|
rfcnum = int(text) |
||||||
|
if rfcnum <= 0: |
||||||
|
raise ValueError |
||||||
|
except ValueError: |
||||||
|
msg = inliner.reporter.error( |
||||||
|
'RFC number must be a number greater than or equal to 1; ' |
||||||
|
'"%s" is invalid.' % text, line=lineno) |
||||||
|
prb = inliner.problematic(rawtext, rawtext, msg) |
||||||
|
return [prb], [msg] |
||||||
|
# Base URL mainly used by inliner.rfc_reference, so this is correct: |
||||||
|
ref = inliner.document.settings.rfc_base_url + inliner.rfc_url % rfcnum |
||||||
|
set_classes(options) |
||||||
|
node = nodes.reference(rawtext, 'RFC ' + utils.unescape(text), refuri=ref, |
||||||
|
**options) |
||||||
|
return [node], [] |
||||||
|
|
||||||
|
register_canonical_role('rfc-reference', rfc_reference_role) |
||||||
|
|
||||||
|
Noteworthy in the code above are: |
||||||
|
|
||||||
|
1. The interpreted text itself should contain the RFC number. The |
||||||
|
``try`` clause verifies by converting it to an integer. If the |
||||||
|
conversion fails, the ``except`` clause is executed: a system |
||||||
|
message is generated, the entire interpreted text construct (in |
||||||
|
``rawtext``) is wrapped in a ``problematic`` node (linked to the |
||||||
|
system message), and the two are returned. |
||||||
|
|
||||||
|
2. The RFC reference itself is constructed from a stock URI, set as |
||||||
|
the "refuri" attribute of a "reference" element. |
||||||
|
|
||||||
|
3. The ``options`` function parameter, a dictionary, may contain a |
||||||
|
"class" customization attribute; it is interpreted and replaced |
||||||
|
with a "classes" attribute by the ``set_classes()`` function. The |
||||||
|
resulting "classes" attribute is passed through to the "reference" |
||||||
|
element node constructor. |
||||||
|
|
||||||
|
.. _RFCs: http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query=rfc&action=Search&sourceid=Mozilla-search |
@ -0,0 +1,168 @@ |
|||||||
|
============================= |
||||||
|
Deploying Docutils Securely |
||||||
|
============================= |
||||||
|
|
||||||
|
:Author: David Goodger |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Date: $Date: 2012-01-03 20:23:53 +0100 (Di, 03 Jan 2012) $ |
||||||
|
:Revision: $Revision: 7302 $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
Introduction |
||||||
|
============ |
||||||
|
|
||||||
|
Initially, Docutils was intended for command-line tools and |
||||||
|
single-user applications. Through-the-web editing and processing was |
||||||
|
not envisaged, therefore web security was not a consideration. Once |
||||||
|
Docutils/reStructuredText started being incorporated into an |
||||||
|
ever-increasing number of web applications (blogs__, wikis__, content |
||||||
|
management systems, and others), several security issues arose and |
||||||
|
have been addressed. This document provides instructions to help you |
||||||
|
secure the Docutils software in your applications. |
||||||
|
|
||||||
|
Docutils does not come in a through-the-web secure state, because this |
||||||
|
would inconvenience ordinary users |
||||||
|
|
||||||
|
__ ../../FAQ.html#are-there-any-weblog-blog-projects-that-use-restructuredtext-syntax |
||||||
|
__ ../../FAQ.html#are-there-any-wikis-that-use-restructuredtext-syntax |
||||||
|
|
||||||
|
|
||||||
|
The Issues |
||||||
|
========== |
||||||
|
|
||||||
|
External Data Insertion |
||||||
|
----------------------- |
||||||
|
|
||||||
|
There are several `reStructuredText directives`_ that can insert |
||||||
|
external data (files and URLs) into the immediate document. These |
||||||
|
directives are: |
||||||
|
|
||||||
|
* "include_", by its very nature |
||||||
|
* "raw_", through its ``:file:`` and ``:url:`` options |
||||||
|
* "csv-table_", through its ``:file:`` and ``:url:`` options |
||||||
|
|
||||||
|
The "include_" directive and the other directives' file insertion |
||||||
|
features can be disabled by setting "file_insertion_enabled_" to |
||||||
|
0/false. |
||||||
|
|
||||||
|
.. _reStructuredText directives: ../ref/rst/directives.html |
||||||
|
.. _include: ../ref/rst/directives.html#include |
||||||
|
.. _raw: ../ref/rst/directives.html#raw-directive |
||||||
|
.. _csv-table: ../ref/rst/directives.html#csv-table |
||||||
|
.. _file_insertion_enabled: ../user/config.html#file-insertion-enabled |
||||||
|
|
||||||
|
|
||||||
|
Raw HTML Insertion |
||||||
|
------------------ |
||||||
|
|
||||||
|
The "raw_" directive is intended for the insertion of |
||||||
|
non-reStructuredText data that is passed untouched to the Writer. |
||||||
|
This directive can be abused to bypass site features or insert |
||||||
|
malicious JavaScript code into a web page. The "raw_" directive can |
||||||
|
be disabled by setting "raw_enabled_" to 0/false. |
||||||
|
|
||||||
|
.. _raw_enabled: ../user/config.html#raw-enabled |
||||||
|
|
||||||
|
|
||||||
|
Securing Docutils |
||||||
|
================= |
||||||
|
|
||||||
|
Programmatically Via Application Default Settings |
||||||
|
------------------------------------------------- |
||||||
|
|
||||||
|
If your application calls Docutils via one of the `convenience |
||||||
|
functions`_, you can pass a dictionary of default settings that |
||||||
|
override the component defaults:: |
||||||
|
|
||||||
|
defaults = {'file_insertion_enabled': 0, |
||||||
|
'raw_enabled': 0} |
||||||
|
output = docutils.core.publish_string( |
||||||
|
..., settings_overrides=defaults) |
||||||
|
|
||||||
|
Note that these defaults can be overridden by configuration files (and |
||||||
|
command-line options if applicable). If this is not desired, you can |
||||||
|
disable configuration file processing with the ``_disable_config`` |
||||||
|
setting:: |
||||||
|
|
||||||
|
defaults = {'file_insertion_enabled': 0, |
||||||
|
'raw_enabled': 0, |
||||||
|
'_disable_config': 1} |
||||||
|
output = docutils.core.publish_string( |
||||||
|
..., settings_overrides=defaults) |
||||||
|
|
||||||
|
.. _convenience functions: ../api/publisher.html |
||||||
|
|
||||||
|
|
||||||
|
Via a Configuration File |
||||||
|
------------------------ |
||||||
|
|
||||||
|
You should secure Docutils via a configuration file: |
||||||
|
|
||||||
|
* if your application executes one of the `Docutils front-end tools`_ |
||||||
|
as a separate process; |
||||||
|
* if you cannot or choose not to alter the source code of your |
||||||
|
application or the component that calls Docutils; or |
||||||
|
* if you want to secure all Docutils deployments system-wide. |
||||||
|
|
||||||
|
If you call Docutils programmatically, it may be preferable to use the |
||||||
|
methods described in section below. |
||||||
|
|
||||||
|
Docutils automatically looks in three places for a configuration file: |
||||||
|
|
||||||
|
* ``/etc/docutils.conf``, for system-wide configuration, |
||||||
|
* ``./docutils.conf`` (in the current working directory), for |
||||||
|
project-specific configuration, and |
||||||
|
* ``~/.docutils`` (in the user's home directory), for user-specific |
||||||
|
configuration. |
||||||
|
|
||||||
|
These locations can be overridden by the ``DOCUTILSCONFIG`` |
||||||
|
environment variable. Details about configuration files, the purpose |
||||||
|
of the various locations, and ``DOCUTILSCONFIG`` are available in the |
||||||
|
`"Configuration Files"`_ section of `Docutils Configuration`_. |
||||||
|
|
||||||
|
To fully secure your Docutils installation, the configuration file |
||||||
|
should contain the following lines:: |
||||||
|
|
||||||
|
[general] |
||||||
|
file-insertion-enabled: |
||||||
|
raw-enabled: |
||||||
|
|
||||||
|
.. Note:: Due to a bug in the definitions of these security-related |
||||||
|
settings, the right-hand-side of the above lines (the values) |
||||||
|
should be left blank, as shown. The bug was corrected on |
||||||
|
2006-11-12 and is reflected in Docutils releases 0.4.1 and higher. |
||||||
|
In these versions, more verbose forms may be used, such as:: |
||||||
|
|
||||||
|
[general] |
||||||
|
file-insertion-enabled: off |
||||||
|
raw-enabled: no |
||||||
|
|
||||||
|
.. _Docutils front-end tools: ../user/tools.html |
||||||
|
.. _"Configuration Files": ../user/config.html#configuration-files |
||||||
|
.. _Docutils Configuration: ../user/config.html |
||||||
|
|
||||||
|
|
||||||
|
Version Applicability |
||||||
|
===================== |
||||||
|
|
||||||
|
The ``file_insertion_enabled`` & ``raw_enabled`` settings were added |
||||||
|
to Docutils 0.3.9; previous versions will ignore these settings. A |
||||||
|
bug existed in the configuration file handling of these settings in |
||||||
|
Docutils 0.4 and earlier. The bug was fixed with the 0.4.1 release on |
||||||
|
2006-11-12. |
||||||
|
|
||||||
|
|
||||||
|
Related Documents |
||||||
|
================= |
||||||
|
|
||||||
|
`Docutils Runtime Settings`_ explains the relationship between |
||||||
|
component settings specifications, application settings |
||||||
|
specifications, configuration files, and command-line options |
||||||
|
|
||||||
|
`Docutils Configuration`_ describes configuration files (locations, |
||||||
|
structure, and syntax), and lists all settings and command-line |
||||||
|
options. |
||||||
|
|
||||||
|
.. _Docutils Runtime Settings: ../api/runtime-settings.html |
@ -0,0 +1,632 @@ |
|||||||
|
<!-- |
||||||
|
====================================================================== |
||||||
|
Docutils Generic DTD |
||||||
|
====================================================================== |
||||||
|
:Author: David Goodger |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Revision: $Revision: 8031 $ |
||||||
|
:Date: $Date: 2017-02-13 10:36:13 +0100 (Mo, 13 Feb 2017) $ |
||||||
|
:Copyright: This DTD has been placed in the public domain. |
||||||
|
:Filename: docutils.dtd |
||||||
|
|
||||||
|
More information about this DTD (document type definition) and the |
||||||
|
Docutils project can be found at http://docutils.sourceforge.net/. |
||||||
|
The latest version of this DTD is available from |
||||||
|
http://docutils.sourceforge.net/docs/ref/docutils.dtd. |
||||||
|
|
||||||
|
The formal public identifier for this DTD is:: |
||||||
|
|
||||||
|
+//IDN docutils.sourceforge.net//DTD Docutils Generic//EN//XML |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
Parameter Entities |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
|
||||||
|
Parameter entities are used to simplify the DTD (reduce duplication) |
||||||
|
and to allow the DTD to be customized by wrapper DTDs. Parameter |
||||||
|
entities beginning with "additional" are meant to allow easy extension |
||||||
|
by wrapper DTDs. |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- Attributes |
||||||
|
================================================================== --> |
||||||
|
|
||||||
|
<!-- Boolean: no if zero(s), yes if any other value. --> |
||||||
|
<!ENTITY % yesorno "NMTOKEN"> |
||||||
|
|
||||||
|
<!-- Emphasize that the attribute value must be a number. --> |
||||||
|
<!ENTITY % number "NMTOKEN"> |
||||||
|
|
||||||
|
<!-- A number which may be immediately followed by a unit or percent sign. --> |
||||||
|
<!ENTITY % measure "CDATA"> |
||||||
|
|
||||||
|
<!ENTITY % additional.basic.atts ""> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Attributes shared by all elements in this DTD: |
||||||
|
|
||||||
|
- `ids` are unique identifiers, typically assigned by the system. The NMTOKENS |
||||||
|
attribute type is used because XML doesn't support a multiple-ID "IDS" type. |
||||||
|
- `names` are identifiers assigned in the markup. |
||||||
|
- `dupnames` is the same as `name`, used when it's a duplicate. |
||||||
|
- `source` is the name of the source of this document or fragment. |
||||||
|
- `classes` is used to transmit individuality information forward. |
||||||
|
--> |
||||||
|
<!ENTITY % basic.atts |
||||||
|
" ids NMTOKENS #IMPLIED |
||||||
|
names CDATA #IMPLIED |
||||||
|
dupnames CDATA #IMPLIED |
||||||
|
source CDATA #IMPLIED |
||||||
|
classes NMTOKENS #IMPLIED |
||||||
|
%additional.basic.atts; "> |
||||||
|
|
||||||
|
<!-- External reference to a URI/URL. --> |
||||||
|
<!ENTITY % refuri.att |
||||||
|
" refuri CDATA #IMPLIED "> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Internal reference to the `ids` attribute of an element. The NMTOKENS |
||||||
|
type is used instead of IDREF, because XML doesn't support a multiple-ID |
||||||
|
"IDS" type. |
||||||
|
--> |
||||||
|
<!ENTITY % refid.att |
||||||
|
" refid NMTOKEN #IMPLIED "> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Space-separated list of `ids` references, for backlinks. The NMTOKENS |
||||||
|
type is used instead of IDREF, because XML doesn't support a multiple-ID |
||||||
|
"IDS" type. |
||||||
|
--> |
||||||
|
<!ENTITY % backrefs.att |
||||||
|
" backrefs NMTOKENS #IMPLIED "> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Internal reference to the `name` attribute of an element. On a |
||||||
|
'target' element, 'refname' indicates an indirect target which may |
||||||
|
resolve to either an internal or external reference. |
||||||
|
--> |
||||||
|
<!ENTITY % refname.att |
||||||
|
" refname NMTOKENS #IMPLIED "> |
||||||
|
|
||||||
|
<!ENTITY % additional.reference.atts ""> |
||||||
|
<!-- Collected hyperlink reference attributes. --> |
||||||
|
<!ENTITY % reference.atts |
||||||
|
" %refuri.att; |
||||||
|
%refid.att; |
||||||
|
%refname.att; |
||||||
|
%additional.reference.atts; "> |
||||||
|
|
||||||
|
<!-- Unnamed hyperlink. --> |
||||||
|
<!ENTITY % anonymous.att |
||||||
|
" anonymous %yesorno; #IMPLIED "> |
||||||
|
|
||||||
|
<!-- Auto-numbered footnote or title. --> |
||||||
|
<!ENTITY % auto.att |
||||||
|
" auto CDATA #IMPLIED "> |
||||||
|
|
||||||
|
<!-- XML standard attribute for whitespace-preserving elements. --> |
||||||
|
<!ENTITY % fixedspace.att |
||||||
|
" xml:space (default | preserve) #FIXED 'preserve' "> |
||||||
|
|
||||||
|
<!ENTITY % align-h.att |
||||||
|
" align (left | center | right) #IMPLIED "> |
||||||
|
|
||||||
|
<!ENTITY % align-hv.att |
||||||
|
" align (top | middle | bottom | left | center | right) #IMPLIED "> |
||||||
|
|
||||||
|
|
||||||
|
<!-- Element OR-Lists |
||||||
|
============================================================= --> |
||||||
|
|
||||||
|
<!ENTITY % additional.bibliographic.elements ""> |
||||||
|
<!ENTITY % bibliographic.elements |
||||||
|
" author | authors | organization | address | contact |
||||||
|
| version | revision | status | date | copyright |
||||||
|
| field |
||||||
|
%additional.bibliographic.elements; "> |
||||||
|
|
||||||
|
<!ENTITY % additional.section.elements ""> |
||||||
|
<!ENTITY % section.elements |
||||||
|
" section |
||||||
|
%additional.section.elements; "> |
||||||
|
|
||||||
|
<!ENTITY % additional.body.elements ""> |
||||||
|
<!ENTITY % body.elements |
||||||
|
" paragraph | compound | container | literal_block | doctest_block |
||||||
|
| math_block | line_block | block_quote |
||||||
|
| table | figure | image | footnote | citation | rubric |
||||||
|
| bullet_list | enumerated_list | definition_list | field_list |
||||||
|
| option_list |
||||||
|
| attention | caution | danger | error | hint | important | note |
||||||
|
| tip | warning | admonition |
||||||
|
| reference | target | substitution_definition | comment | pending |
||||||
|
| system_message | raw |
||||||
|
%additional.body.elements; "> |
||||||
|
|
||||||
|
<!ENTITY % additional.inline.elements ""> |
||||||
|
<!ENTITY % inline.elements |
||||||
|
" emphasis | strong | literal | math |
||||||
|
| reference | footnote_reference | citation_reference |
||||||
|
| substitution_reference | title_reference |
||||||
|
| abbreviation | acronym | subscript | superscript |
||||||
|
| inline | problematic | generated |
||||||
|
| target | image | raw |
||||||
|
%additional.inline.elements; "> |
||||||
|
|
||||||
|
|
||||||
|
<!-- Element Content Models |
||||||
|
================================================================== --> |
||||||
|
|
||||||
|
<!-- The structure model may not end with a transition. --> |
||||||
|
<!ENTITY % structure.model |
||||||
|
" ( ( (%body.elements; | topic | sidebar)+, transition? )*, |
||||||
|
( (%section.elements;), (transition?, (%section.elements;) )* )? )"> |
||||||
|
|
||||||
|
<!ENTITY % text.model |
||||||
|
" (#PCDATA | %inline.elements;)* "> |
||||||
|
|
||||||
|
|
||||||
|
<!-- Table Model |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
|
||||||
|
This DTD uses the Exchange subset of the CALS-table model (OASIS |
||||||
|
Technical Memorandum 9901:1999 "XML Exchange Table Model DTD", |
||||||
|
http://www.oasis-open.org/html/tm9901.htm). |
||||||
|
--> |
||||||
|
|
||||||
|
<!ENTITY % calstblx PUBLIC |
||||||
|
"-//OASIS//DTD XML Exchange Table Model 19990315//EN" |
||||||
|
"soextblx.dtd"> |
||||||
|
|
||||||
|
<!-- These parameter entities customize the table model DTD. --> |
||||||
|
<!ENTITY % bodyatt " %basic.atts; "> <!-- table elt --> |
||||||
|
<!-- 1 colspec element is expected per table column: --> |
||||||
|
<!ENTITY % tbl.tgroup.mdl "colspec+,thead?,tbody"> |
||||||
|
<!ENTITY % tbl.tgroup.att " %basic.atts; "> |
||||||
|
<!ENTITY % tbl.thead.att " %basic.atts; "> |
||||||
|
<!ENTITY % tbl.tbody.att " %basic.atts; "> |
||||||
|
<!ENTITY % tbl.colspec.att |
||||||
|
" %basic.atts; |
||||||
|
stub %yesorno; #IMPLIED "> |
||||||
|
<!ENTITY % tbl.row.att " %basic.atts; "> |
||||||
|
<!-- ``(...)*``: nested tables are supported --> |
||||||
|
<!ENTITY % tbl.entry.mdl " (%body.elements;)* "> |
||||||
|
<!ENTITY % tbl.entry.att |
||||||
|
" %basic.atts; |
||||||
|
morecols %number; #IMPLIED "> |
||||||
|
<!ATTLIST table |
||||||
|
%align-h.att;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
Root Element |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- Optional elements may be generated by internal processing. --> |
||||||
|
<!ELEMENT document |
||||||
|
( (title, subtitle?)?, |
||||||
|
decoration?, |
||||||
|
(docinfo, transition?)?, |
||||||
|
%structure.model; )> |
||||||
|
<!ATTLIST document |
||||||
|
%basic.atts; |
||||||
|
title CDATA #IMPLIED> |
||||||
|
|
||||||
|
<!-- |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
Title Elements |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT title %text.model;> |
||||||
|
<!ATTLIST title |
||||||
|
%basic.atts; |
||||||
|
%refid.att; |
||||||
|
%auto.att;> |
||||||
|
|
||||||
|
<!ELEMENT subtitle %text.model;> |
||||||
|
<!ATTLIST subtitle %basic.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
Bibliographic Elements |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- Container for bibliographic elements. May not be empty. --> |
||||||
|
<!ELEMENT docinfo (%bibliographic.elements;)+> |
||||||
|
<!ATTLIST docinfo %basic.atts;> |
||||||
|
|
||||||
|
<!-- Container for bibliographic elements. May not be empty. |
||||||
|
Eventual replacement for docinfo? --> |
||||||
|
<!ELEMENT info (%bibliographic.elements;)+> |
||||||
|
<!ATTLIST info %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT author %text.model;> |
||||||
|
<!ATTLIST author %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT authors (author, organization?, address?, contact?)+> |
||||||
|
<!ATTLIST authors %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT organization %text.model;> |
||||||
|
<!ATTLIST organization %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT address %text.model;> |
||||||
|
<!ATTLIST address |
||||||
|
%basic.atts; |
||||||
|
%fixedspace.att;> |
||||||
|
|
||||||
|
<!ELEMENT contact %text.model;> |
||||||
|
<!ATTLIST contact %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT version %text.model;> |
||||||
|
<!ATTLIST version %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT revision %text.model;> |
||||||
|
<!ATTLIST revision %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT status %text.model;> |
||||||
|
<!ATTLIST status %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT date %text.model;> |
||||||
|
<!ATTLIST date %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT copyright %text.model;> |
||||||
|
<!ATTLIST copyright %basic.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
Decoration Elements |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT decoration (header?, footer?)> |
||||||
|
<!ATTLIST decoration %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT header (%body.elements;)+> |
||||||
|
<!ATTLIST header %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT footer (%body.elements;)+> |
||||||
|
<!ATTLIST footer %basic.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
Structural Elements |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT section |
||||||
|
(title, subtitle?, info?, decoration?, %structure.model;)> |
||||||
|
<!ATTLIST section %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT topic (title?, (%body.elements;)+)> |
||||||
|
<!ATTLIST topic %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT sidebar (title, subtitle?, (%body.elements; | topic)+)> |
||||||
|
<!ATTLIST sidebar %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT transition EMPTY> |
||||||
|
<!ATTLIST transition %basic.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
Body Elements |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT paragraph %text.model;> |
||||||
|
<!ATTLIST paragraph %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT compound (%body.elements;)+> |
||||||
|
<!ATTLIST compound %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT container (%body.elements;)+> |
||||||
|
<!ATTLIST container %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT bullet_list (list_item+)> |
||||||
|
<!ATTLIST bullet_list |
||||||
|
%basic.atts; |
||||||
|
bullet CDATA #IMPLIED> |
||||||
|
|
||||||
|
<!ELEMENT enumerated_list (list_item+)> |
||||||
|
<!ATTLIST enumerated_list |
||||||
|
%basic.atts; |
||||||
|
enumtype (arabic | loweralpha | upperalpha |
||||||
|
| lowerroman | upperroman) |
||||||
|
#IMPLIED |
||||||
|
prefix CDATA #IMPLIED |
||||||
|
suffix CDATA #IMPLIED |
||||||
|
start %number; #IMPLIED> |
||||||
|
|
||||||
|
<!ELEMENT list_item (%body.elements;)*> |
||||||
|
<!ATTLIST list_item %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT definition_list (definition_list_item+)> |
||||||
|
<!ATTLIST definition_list %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT definition_list_item (term, classifier*, definition)> |
||||||
|
<!ATTLIST definition_list_item %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT term %text.model;> |
||||||
|
<!ATTLIST term %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT classifier %text.model;> |
||||||
|
<!ATTLIST classifier %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT definition (%body.elements;)+> |
||||||
|
<!ATTLIST definition %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT field_list (field+)> |
||||||
|
<!ATTLIST field_list %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT field (field_name, field_body)> |
||||||
|
<!ATTLIST field %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT field_name %text.model;> |
||||||
|
<!ATTLIST field_name %basic.atts;> |
||||||
|
|
||||||
|
<!-- May be empty. --> |
||||||
|
<!ELEMENT field_body (%body.elements;)*> |
||||||
|
<!ATTLIST field_body %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT option_list (option_list_item+)> |
||||||
|
<!ATTLIST option_list %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT option_list_item (option_group, description)> |
||||||
|
<!ATTLIST option_list_item %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT option_group (option+)> |
||||||
|
<!ATTLIST option_group %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT option (option_string, option_argument*)> |
||||||
|
<!ATTLIST option %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT option_string (#PCDATA)> |
||||||
|
<!ATTLIST option_string %basic.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
`delimiter` contains the text preceding the `option_argument`: either |
||||||
|
the text separating it from the `option_string` (typically either "=" |
||||||
|
or " ") or the text between option arguments (typically either "," or |
||||||
|
" "). |
||||||
|
--> |
||||||
|
<!ELEMENT option_argument (#PCDATA)> |
||||||
|
<!ATTLIST option_argument |
||||||
|
%basic.atts; |
||||||
|
delimiter CDATA #IMPLIED> |
||||||
|
|
||||||
|
<!ELEMENT description (%body.elements;)+> |
||||||
|
<!ATTLIST description %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT literal_block %text.model;> |
||||||
|
<!ATTLIST literal_block |
||||||
|
%basic.atts; |
||||||
|
%fixedspace.att;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
`math_block` contains a block of text in "LaTeX math format" |
||||||
|
that is typeset as mathematical notation (display formula). |
||||||
|
--> |
||||||
|
<!ELEMENT math_block (#PCDATA)> |
||||||
|
<!ATTLIST math_block %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT line_block (line | line_block)+> |
||||||
|
<!ATTLIST line_block %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT line %text.model;> |
||||||
|
<!ATTLIST line %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT block_quote ((%body.elements;)+, attribution?)> |
||||||
|
<!ATTLIST block_quote %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT attribution %text.model;> |
||||||
|
<!ATTLIST attribution %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT doctest_block %text.model;> |
||||||
|
<!ATTLIST doctest_block |
||||||
|
%basic.atts; |
||||||
|
%fixedspace.att;> |
||||||
|
|
||||||
|
<!ELEMENT attention (%body.elements;)+> |
||||||
|
<!ATTLIST attention %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT caution (%body.elements;)+> |
||||||
|
<!ATTLIST caution %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT danger (%body.elements;)+> |
||||||
|
<!ATTLIST danger %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT error (%body.elements;)+> |
||||||
|
<!ATTLIST error %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT hint (%body.elements;)+> |
||||||
|
<!ATTLIST hint %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT important (%body.elements;)+> |
||||||
|
<!ATTLIST important %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT note (%body.elements;)+> |
||||||
|
<!ATTLIST note %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT tip (%body.elements;)+> |
||||||
|
<!ATTLIST tip %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT warning (%body.elements;)+> |
||||||
|
<!ATTLIST warning %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT admonition (title, (%body.elements;)+)> |
||||||
|
<!ATTLIST admonition %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT footnote (label?, (%body.elements;)+)> |
||||||
|
<!ATTLIST footnote |
||||||
|
%basic.atts; |
||||||
|
%backrefs.att; |
||||||
|
%auto.att;> |
||||||
|
|
||||||
|
<!ELEMENT citation (label, (%body.elements;)+)> |
||||||
|
<!ATTLIST citation |
||||||
|
%basic.atts; |
||||||
|
%backrefs.att;> |
||||||
|
|
||||||
|
<!ELEMENT label (#PCDATA)> |
||||||
|
<!ATTLIST label %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT rubric %text.model;> |
||||||
|
<!ATTLIST rubric %basic.atts;> |
||||||
|
|
||||||
|
<!-- Empty except when used as an inline element. --> |
||||||
|
<!ELEMENT target %text.model;> |
||||||
|
<!ATTLIST target |
||||||
|
%basic.atts; |
||||||
|
%reference.atts; |
||||||
|
%anonymous.att;> |
||||||
|
|
||||||
|
<!ELEMENT substitution_definition %text.model;> |
||||||
|
<!ATTLIST substitution_definition |
||||||
|
%basic.atts; |
||||||
|
ltrim %yesorno; #IMPLIED |
||||||
|
rtrim %yesorno; #IMPLIED> |
||||||
|
|
||||||
|
<!ELEMENT comment (#PCDATA)> |
||||||
|
<!ATTLIST comment |
||||||
|
%basic.atts; |
||||||
|
%fixedspace.att;> |
||||||
|
|
||||||
|
<!ELEMENT pending EMPTY> |
||||||
|
<!ATTLIST pending %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT figure (image, ((caption, legend?) | legend)) > |
||||||
|
<!ATTLIST figure |
||||||
|
%basic.atts; |
||||||
|
%align-h.att; |
||||||
|
width %measure; #IMPLIED> |
||||||
|
|
||||||
|
<!-- Also an inline element. --> |
||||||
|
<!ELEMENT image EMPTY> |
||||||
|
<!ATTLIST image |
||||||
|
%basic.atts; |
||||||
|
%align-hv.att; |
||||||
|
uri CDATA #REQUIRED |
||||||
|
alt CDATA #IMPLIED |
||||||
|
height %measure; #IMPLIED |
||||||
|
width %measure; #IMPLIED |
||||||
|
scale %number; #IMPLIED> |
||||||
|
|
||||||
|
<!ELEMENT caption %text.model;> |
||||||
|
<!ATTLIST caption %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT legend (%body.elements;)+> |
||||||
|
<!ATTLIST legend %basic.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Table elements: table, tgroup, colspec, thead, tbody, row, entry. |
||||||
|
--> |
||||||
|
%calstblx; |
||||||
|
|
||||||
|
<!-- Used to record processing information. --> |
||||||
|
<!ELEMENT system_message (%body.elements;)+> |
||||||
|
<!ATTLIST system_message |
||||||
|
%basic.atts; |
||||||
|
%backrefs.att; |
||||||
|
level %number; #IMPLIED |
||||||
|
line %number; #IMPLIED |
||||||
|
type NMTOKEN #IMPLIED> |
||||||
|
|
||||||
|
<!-- Used to pass raw data through the system. Also inline. --> |
||||||
|
<!ELEMENT raw %text.model;> |
||||||
|
<!ATTLIST raw |
||||||
|
%basic.atts; |
||||||
|
%fixedspace.att; |
||||||
|
format NMTOKENS #IMPLIED> |
||||||
|
|
||||||
|
<!-- |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
Inline Elements |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
|
||||||
|
Inline elements occur within the text contents of body elements. Some |
||||||
|
nesting of inline elements is allowed by these definitions, with the |
||||||
|
following caveats: |
||||||
|
|
||||||
|
- An inline element may not contain a nested element of the same type |
||||||
|
(e.g. <strong> may not contain another <strong>). |
||||||
|
- Nested inline elements may or may not be supported by individual |
||||||
|
applications using this DTD. |
||||||
|
- The inline elements <footnote_reference>, <citation_reference>, |
||||||
|
<math>, and <image> do not support nesting. |
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT emphasis %text.model;> |
||||||
|
<!ATTLIST emphasis %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT strong %text.model;> |
||||||
|
<!ATTLIST strong %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT literal %text.model;> |
||||||
|
<!ATTLIST literal %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT math (#PCDATA)> |
||||||
|
<!ATTLIST math %basic.atts;> |
||||||
|
|
||||||
|
<!-- Can also be a body element, when it contains an "image" element. --> |
||||||
|
<!ELEMENT reference %text.model;> |
||||||
|
<!ATTLIST reference |
||||||
|
name CDATA #IMPLIED |
||||||
|
%basic.atts; |
||||||
|
%reference.atts; |
||||||
|
%anonymous.att;> |
||||||
|
|
||||||
|
<!ELEMENT footnote_reference (#PCDATA)> |
||||||
|
<!ATTLIST footnote_reference |
||||||
|
%basic.atts; |
||||||
|
%refid.att; |
||||||
|
%refname.att; |
||||||
|
%auto.att;> |
||||||
|
|
||||||
|
<!ELEMENT citation_reference (#PCDATA)> |
||||||
|
<!ATTLIST citation_reference |
||||||
|
%basic.atts; |
||||||
|
%refid.att; |
||||||
|
%refname.att;> |
||||||
|
|
||||||
|
<!ELEMENT substitution_reference %text.model;> |
||||||
|
<!ATTLIST substitution_reference |
||||||
|
%basic.atts; |
||||||
|
%refname.att;> |
||||||
|
|
||||||
|
<!ELEMENT title_reference %text.model;> |
||||||
|
<!ATTLIST title_reference %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT abbreviation %text.model;> |
||||||
|
<!ATTLIST abbreviation %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT acronym %text.model;> |
||||||
|
<!ATTLIST acronym %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT superscript %text.model;> |
||||||
|
<!ATTLIST superscript %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT subscript %text.model;> |
||||||
|
<!ATTLIST subscript %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT inline %text.model;> |
||||||
|
<!ATTLIST inline %basic.atts;> |
||||||
|
|
||||||
|
<!ELEMENT problematic %text.model;> |
||||||
|
<!ATTLIST problematic |
||||||
|
%basic.atts; |
||||||
|
%refid.att;> |
||||||
|
|
||||||
|
<!ELEMENT generated %text.model;> |
||||||
|
<!ATTLIST generated %basic.atts;> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Local Variables: |
||||||
|
mode: sgml |
||||||
|
indent-tabs-mode: nil |
||||||
|
fill-column: 70 |
||||||
|
End: |
||||||
|
--> |
@ -0,0 +1,380 @@ |
|||||||
|
========================================= |
||||||
|
reStructuredText Interpreted Text Roles |
||||||
|
========================================= |
||||||
|
|
||||||
|
:Author: David Goodger |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Revision: $Revision: 7307 $ |
||||||
|
:Date: $Date: 2012-01-06 12:11:51 +0100 (Fr, 06 Jan 2012) $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
This document describes the interpreted text roles implemented in the |
||||||
|
reference reStructuredText parser. |
||||||
|
|
||||||
|
Interpreted text uses backquotes (`) around the text. An explicit |
||||||
|
role marker may optionally appear before or after the text, delimited |
||||||
|
with colons. For example:: |
||||||
|
|
||||||
|
This is `interpreted text` using the default role. |
||||||
|
|
||||||
|
This is :title:`interpreted text` using an explicit role. |
||||||
|
|
||||||
|
A default role may be defined by applications of reStructuredText; it |
||||||
|
is used if no explicit ``:role:`` prefix or suffix is given. The |
||||||
|
"default default role" is `:title-reference:`_. It can be changed |
||||||
|
using the default-role_ directive. |
||||||
|
|
||||||
|
See the `Interpreted Text`_ section in the `reStructuredText Markup |
||||||
|
Specification`_ for syntax details. For details on the hierarchy of |
||||||
|
elements, please see `The Docutils Document Tree`_ and the `Docutils |
||||||
|
Generic DTD`_ XML document type definition. For interpreted text role |
||||||
|
implementation details, see `Creating reStructuredText Interpreted |
||||||
|
Text Roles`_. |
||||||
|
|
||||||
|
.. _"role" directive: directives.html#role |
||||||
|
.. _default-role: directives.html#default-role |
||||||
|
.. _Interpreted Text: restructuredtext.html#interpreted-text |
||||||
|
.. _reStructuredText Markup Specification: restructuredtext.html |
||||||
|
.. _The Docutils Document Tree: ../doctree.html |
||||||
|
.. _Docutils Generic DTD: ../docutils.dtd |
||||||
|
.. _Creating reStructuredText Interpreted Text Roles: |
||||||
|
../../howto/rst-roles.html |
||||||
|
|
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
|
||||||
|
--------------- |
||||||
|
Customization |
||||||
|
--------------- |
||||||
|
|
||||||
|
Custom interpreted text roles may be defined in a document with the |
||||||
|
`"role" directive`_. Customization details are listed with each role. |
||||||
|
|
||||||
|
.. _class: |
||||||
|
|
||||||
|
A ``class`` option is recognized by the "role" directive for most |
||||||
|
interpreted text roles. A description__ is provided in the `"role" |
||||||
|
directive`_ documentation. |
||||||
|
|
||||||
|
__ directives.html#role-class |
||||||
|
|
||||||
|
|
||||||
|
---------------- |
||||||
|
Standard Roles |
||||||
|
---------------- |
||||||
|
|
||||||
|
``:emphasis:`` |
||||||
|
============== |
||||||
|
|
||||||
|
:Aliases: None |
||||||
|
:DTD Element: emphasis |
||||||
|
:Customization: |
||||||
|
:Options: class_. |
||||||
|
:Content: None. |
||||||
|
|
||||||
|
Implements emphasis. These are equivalent:: |
||||||
|
|
||||||
|
*text* |
||||||
|
:emphasis:`text` |
||||||
|
|
||||||
|
|
||||||
|
``:literal:`` |
||||||
|
============== |
||||||
|
|
||||||
|
:Aliases: None |
||||||
|
:DTD Element: literal |
||||||
|
:Customization: |
||||||
|
:Options: class_. |
||||||
|
:Content: None. |
||||||
|
|
||||||
|
Implements inline literal text. These are equivalent:: |
||||||
|
|
||||||
|
``text`` |
||||||
|
:literal:`text` |
||||||
|
|
||||||
|
Care must be taken with backslash-escapes though. These are *not* |
||||||
|
equivalent:: |
||||||
|
|
||||||
|
``text \ and \ backslashes`` |
||||||
|
:literal:`text \ and \ backslashes` |
||||||
|
|
||||||
|
The backslashes in the first line are preserved (and do nothing), |
||||||
|
whereas the backslashes in the second line escape the following |
||||||
|
spaces. |
||||||
|
|
||||||
|
|
||||||
|
``:code:`` |
||||||
|
========== |
||||||
|
|
||||||
|
:Aliases: None |
||||||
|
:DTD Element: literal |
||||||
|
:Customization: |
||||||
|
:Options: class_, language |
||||||
|
:Content: None. |
||||||
|
|
||||||
|
(New in Docutils 0.9.) |
||||||
|
|
||||||
|
The ``code`` role marks its content as code in a formal language. |
||||||
|
|
||||||
|
For syntax highlight of inline code, the `"role" directive`_ can be used to |
||||||
|
build custom roles with the code language specified in the "language" |
||||||
|
option. |
||||||
|
|
||||||
|
For example, the following creates a LaTeX-specific "latex" role:: |
||||||
|
|
||||||
|
.. role:: latex(code) |
||||||
|
:language: latex |
||||||
|
|
||||||
|
Content of the new role is parsed and tagged by the Pygments_ syntax |
||||||
|
highlighter. See the `code directive`_ for more info on parsing and display |
||||||
|
of code in reStructuredText. |
||||||
|
|
||||||
|
In addition to "class_", the following option is recognized: |
||||||
|
|
||||||
|
``language`` : text |
||||||
|
Name of the code's language. |
||||||
|
See `supported languages and markup formats`_ for recognized values. |
||||||
|
|
||||||
|
.. _code directive: directives.html#code |
||||||
|
.. _Pygments: http://pygments.org/ |
||||||
|
.. _supported languages and markup formats: http://pygments.org/languages/ |
||||||
|
|
||||||
|
|
||||||
|
``:math:`` |
||||||
|
========== |
||||||
|
|
||||||
|
:Aliases: None |
||||||
|
:DTD Element: math |
||||||
|
:Customization: |
||||||
|
:Options: class_ |
||||||
|
:Content: None. |
||||||
|
|
||||||
|
(New in Docutils 0.8.) |
||||||
|
|
||||||
|
The ``math`` role marks its content as mathematical notation (inline |
||||||
|
formula). |
||||||
|
|
||||||
|
The input format is LaTeX math syntax without the “math delimiters“ |
||||||
|
(``$ $``), for example:: |
||||||
|
|
||||||
|
The area of a circle is :math:`A_\text{c} = (\pi/4) d^2`. |
||||||
|
|
||||||
|
See the `math directive`_ (producing display formulas) for more info |
||||||
|
on mathematical notation in reStructuredText. |
||||||
|
|
||||||
|
.. _math directive: directives.html#math |
||||||
|
|
||||||
|
|
||||||
|
``:pep-reference:`` |
||||||
|
=================== |
||||||
|
|
||||||
|
:Aliases: ``:PEP:`` |
||||||
|
:DTD Element: reference |
||||||
|
:Customization: |
||||||
|
:Options: class_. |
||||||
|
:Content: None. |
||||||
|
|
||||||
|
The ``:pep-reference:`` role is used to create an HTTP reference to a |
||||||
|
PEP (Python Enhancement Proposal). The ``:PEP:`` alias is usually |
||||||
|
used. For example:: |
||||||
|
|
||||||
|
See :PEP:`287` for more information about reStructuredText. |
||||||
|
|
||||||
|
This is equivalent to:: |
||||||
|
|
||||||
|
See `PEP 287`__ for more information about reStructuredText. |
||||||
|
|
||||||
|
__ http://www.python.org/peps/pep-0287.html |
||||||
|
|
||||||
|
|
||||||
|
``:rfc-reference:`` |
||||||
|
=================== |
||||||
|
|
||||||
|
:Aliases: ``:RFC:`` |
||||||
|
:DTD Element: reference |
||||||
|
:Customization: |
||||||
|
:Options: class_. |
||||||
|
:Content: None. |
||||||
|
|
||||||
|
The ``:rfc-reference:`` role is used to create an HTTP reference to an |
||||||
|
RFC (Internet Request for Comments). The ``:RFC:`` alias is usually |
||||||
|
used. For example:: |
||||||
|
|
||||||
|
See :RFC:`2822` for information about email headers. |
||||||
|
|
||||||
|
This is equivalent to:: |
||||||
|
|
||||||
|
See `RFC 2822`__ for information about email headers. |
||||||
|
|
||||||
|
__ http://www.faqs.org/rfcs/rfc2822.html |
||||||
|
|
||||||
|
|
||||||
|
``:strong:`` |
||||||
|
============ |
||||||
|
|
||||||
|
:Aliases: None |
||||||
|
:DTD Element: strong |
||||||
|
:Customization: |
||||||
|
:Options: class_. |
||||||
|
:Content: None. |
||||||
|
|
||||||
|
Implements strong emphasis. These are equivalent:: |
||||||
|
|
||||||
|
**text** |
||||||
|
:strong:`text` |
||||||
|
|
||||||
|
|
||||||
|
``:subscript:`` |
||||||
|
=============== |
||||||
|
|
||||||
|
:Aliases: ``:sub:`` |
||||||
|
:DTD Element: subscript |
||||||
|
:Customization: |
||||||
|
:Options: class_. |
||||||
|
:Content: None. |
||||||
|
|
||||||
|
Implements subscripts. |
||||||
|
|
||||||
|
.. Tip:: |
||||||
|
|
||||||
|
Whitespace or punctuation is required around interpreted text, but |
||||||
|
often not desired with subscripts & superscripts. |
||||||
|
Backslash-escaped whitespace can be used; the whitespace will be |
||||||
|
removed from the processed document:: |
||||||
|
|
||||||
|
H\ :sub:`2`\ O |
||||||
|
E = mc\ :sup:`2` |
||||||
|
|
||||||
|
In such cases, readability of the plain text can be greatly |
||||||
|
improved with substitutions:: |
||||||
|
|
||||||
|
The chemical formula for pure water is |H2O|. |
||||||
|
|
||||||
|
.. |H2O| replace:: H\ :sub:`2`\ O |
||||||
|
|
||||||
|
See `the reStructuredText spec`__ for further information on |
||||||
|
`character-level markup`__ and `the substitution mechanism`__. |
||||||
|
|
||||||
|
__ restructuredtext.html |
||||||
|
__ restructuredtext.html#character-level-inline-markup |
||||||
|
__ restructuredtext.html#substitution-references |
||||||
|
|
||||||
|
|
||||||
|
``:superscript:`` |
||||||
|
================= |
||||||
|
|
||||||
|
:Aliases: ``:sup:`` |
||||||
|
:DTD Element: superscript |
||||||
|
:Customization: |
||||||
|
:Options: class_. |
||||||
|
:Content: None. |
||||||
|
|
||||||
|
Implements superscripts. See the tip in `:subscript:`_ above. |
||||||
|
|
||||||
|
|
||||||
|
``:title-reference:`` |
||||||
|
===================== |
||||||
|
|
||||||
|
:Aliases: ``:title:``, ``:t:``. |
||||||
|
:DTD Element: title_reference |
||||||
|
:Customization: |
||||||
|
:Options: class_. |
||||||
|
:Content: None. |
||||||
|
|
||||||
|
The ``:title-reference:`` role is used to describe the titles of |
||||||
|
books, periodicals, and other materials. It is the equivalent of the |
||||||
|
HTML "cite" element, and it is expected that HTML writers will |
||||||
|
typically render "title_reference" elements using "cite". |
||||||
|
|
||||||
|
Since title references are typically rendered with italics, they are |
||||||
|
often marked up using ``*emphasis*``, which is misleading and vague. |
||||||
|
The "title_reference" element provides accurate and unambiguous |
||||||
|
descriptive markup. |
||||||
|
|
||||||
|
Let's assume ``:title-reference:`` is the default interpreted text |
||||||
|
role (see below) for this example:: |
||||||
|
|
||||||
|
`Design Patterns` [GoF95]_ is an excellent read. |
||||||
|
|
||||||
|
The following document fragment (pseudo-XML_) will result from |
||||||
|
processing:: |
||||||
|
|
||||||
|
<paragraph> |
||||||
|
<title_reference> |
||||||
|
Design Patterns |
||||||
|
|
||||||
|
<citation_reference refname="gof95"> |
||||||
|
GoF95 |
||||||
|
is an excellent read. |
||||||
|
|
||||||
|
``:title-reference:`` is the default interpreted text role in the |
||||||
|
standard reStructuredText parser. This means that no explicit role is |
||||||
|
required. Applications of reStructuredText may designate a different |
||||||
|
default role, in which case the explicit ``:title-reference:`` role |
||||||
|
must be used to obtain a ``title_reference`` element. |
||||||
|
|
||||||
|
|
||||||
|
.. _pseudo-XML: ../doctree.html#pseudo-xml |
||||||
|
|
||||||
|
|
||||||
|
------------------- |
||||||
|
Specialized Roles |
||||||
|
------------------- |
||||||
|
|
||||||
|
``raw`` |
||||||
|
======= |
||||||
|
|
||||||
|
:Aliases: None |
||||||
|
:DTD Element: raw |
||||||
|
:Customization: |
||||||
|
:Options: class_, format |
||||||
|
:Content: None |
||||||
|
|
||||||
|
.. WARNING:: |
||||||
|
|
||||||
|
The "raw" role is a stop-gap measure allowing the author to bypass |
||||||
|
reStructuredText's markup. It is a "power-user" feature that |
||||||
|
should not be overused or abused. The use of "raw" ties documents |
||||||
|
to specific output formats and makes them less portable. |
||||||
|
|
||||||
|
If you often need to use "raw"-derived interpreted text roles or |
||||||
|
the "raw" directive, that is a sign either of overuse/abuse or that |
||||||
|
functionality may be missing from reStructuredText. Please |
||||||
|
describe your situation in a message to the Docutils-users_ mailing |
||||||
|
list. |
||||||
|
|
||||||
|
.. _Docutils-users: ../../user/mailing-lists.html#docutils-user |
||||||
|
|
||||||
|
The "raw" role indicates non-reStructuredText data that is to be |
||||||
|
passed untouched to the Writer. It is the inline equivalent of the |
||||||
|
`"raw" directive`_; see its documentation for details on the |
||||||
|
semantics. |
||||||
|
|
||||||
|
.. _"raw" directive: directives.html#raw-directive |
||||||
|
|
||||||
|
The "raw" role cannot be used directly. The `"role" directive`_ must |
||||||
|
first be used to build custom roles based on the "raw" role. One or |
||||||
|
more formats (Writer names) must be provided in a "format" option. |
||||||
|
|
||||||
|
For example, the following creates an HTML-specific "raw-html" role:: |
||||||
|
|
||||||
|
.. role:: raw-html(raw) |
||||||
|
:format: html |
||||||
|
|
||||||
|
This role can now be used directly to pass data untouched to the HTML |
||||||
|
Writer. For example:: |
||||||
|
|
||||||
|
If there just *has* to be a line break here, |
||||||
|
:raw-html:`<br />` |
||||||
|
it can be accomplished with a "raw"-derived role. |
||||||
|
But the line block syntax should be considered first. |
||||||
|
|
||||||
|
.. Tip:: Roles based on "raw" should clearly indicate their origin, so |
||||||
|
they are not mistaken for reStructuredText markup. Using a "raw-" |
||||||
|
prefix for role names is recommended. |
||||||
|
|
||||||
|
In addition to "class_", the following option is recognized: |
||||||
|
|
||||||
|
``format`` : text |
||||||
|
One or more space-separated output format names (Writer names). |
@ -0,0 +1,312 @@ |
|||||||
|
<!-- |
||||||
|
=========================================================================== |
||||||
|
OASIS XML Exchange Table Model Declaration Module |
||||||
|
=========================================================================== |
||||||
|
:Date: 1999-03-15 |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- This set of declarations defines the XML version of the Exchange |
||||||
|
Table Model as of the date shown in the Formal Public Identifier |
||||||
|
(FPI) for this entity. |
||||||
|
|
||||||
|
This set of declarations may be referred to using a public external |
||||||
|
entity declaration and reference as shown in the following three |
||||||
|
lines: |
||||||
|
|
||||||
|
<!ENTITY % calstblx |
||||||
|
PUBLIC "-//OASIS//DTD XML Exchange Table Model 19990315//EN"> |
||||||
|
%calstblx; |
||||||
|
|
||||||
|
If various parameter entities used within this set of declarations |
||||||
|
are to be given non-default values, the appropriate declarations |
||||||
|
should be given before calling in this package (i.e., before the |
||||||
|
"%calstblx;" reference). |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- The motivation for this XML version of the Exchange Table Model |
||||||
|
is simply to create an XML version of the SGML Exchange Table |
||||||
|
Model. By design, no effort has been made to "improve" the model. |
||||||
|
|
||||||
|
This XML version incorporates the logical bare minimum changes |
||||||
|
necessary to make the Exchange Table Model a valid XML DTD. |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- The XML version of the Exchange Table Model differs from |
||||||
|
the SGML version in the following ways: |
||||||
|
|
||||||
|
The following parameter entities have been removed: |
||||||
|
|
||||||
|
- tbl.table.excep, tbl.hdft.excep, tbl.row.excep, tbl.entry.excep |
||||||
|
There are no exceptions in XML. The following normative statement |
||||||
|
is made in lieu of exceptions: the exchange table model explicitly |
||||||
|
forbids a table from occurring within another table. If the |
||||||
|
content model of an entry includes a table element, then this |
||||||
|
cannot be enforced by the DTD, but it is a deviation from the |
||||||
|
exchange table model to include a table within a table. |
||||||
|
|
||||||
|
- tbl.hdft.name, tbl.hdft.mdl, tbl.hdft.excep, tbl.hdft.att |
||||||
|
The motivation for these elements was to change the table |
||||||
|
header/footer elements. Since XML does not allow element declarations |
||||||
|
to contain name groups, and the exchange table model does not |
||||||
|
allow a table to contain footers, the continued presence of these |
||||||
|
attributes seems unnecessary. |
||||||
|
|
||||||
|
The following parameter entity has been added: |
||||||
|
|
||||||
|
- tbl.thead.att |
||||||
|
This entity parameterizes the attributes on thead. It replaces |
||||||
|
the tbl.hdft.att parameter entity. |
||||||
|
|
||||||
|
Other miscellaneous changes: |
||||||
|
|
||||||
|
- Tag ommission indicators have been removed |
||||||
|
- Comments have been removed from declarations |
||||||
|
- NUMBER attributes have been changed to NMTOKEN |
||||||
|
- NUTOKEN attributes have been to changed to NMTOKEN |
||||||
|
- Removed the grouping characters around the content model |
||||||
|
parameter entry for the 'entry' element. This is necessary |
||||||
|
so that an entry can contain #PCDATA and be defined as an |
||||||
|
optional, repeatable OR group beginning with #PCDATA. |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- This entity includes a set of element and attribute declarations |
||||||
|
that partially defines the Exchange table model. However, the model |
||||||
|
is not well-defined without the accompanying natural language |
||||||
|
description of the semantics (meanings) of these various elements, |
||||||
|
attributes, and attribute values. The semantic writeup, also available |
||||||
|
from SGML Open, should be used in conjunction with this entity. |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- In order to use the Exchange table model, various parameter entity |
||||||
|
declarations are required. A brief description is as follows: |
||||||
|
|
||||||
|
ENTITY NAME WHERE USED WHAT IT IS |
||||||
|
|
||||||
|
%yesorno In ATTLIST of: An attribute declared value |
||||||
|
almost all elements for a "boolean" attribute |
||||||
|
|
||||||
|
%paracon In content model of: The "text" (logical content) |
||||||
|
<entry> of the model group for <entry> |
||||||
|
|
||||||
|
%titles In content model of: The "title" part of the model |
||||||
|
table element group for the table element |
||||||
|
|
||||||
|
%tbl.table.name In declaration of: The name of the "table" |
||||||
|
table element element |
||||||
|
|
||||||
|
%tbl.table-titles.mdl In content model of: The model group for the title |
||||||
|
table elements part of the content model for |
||||||
|
table element |
||||||
|
|
||||||
|
%tbl.table.mdl In content model of: The model group for the content |
||||||
|
table elements model for table element, |
||||||
|
often (and by default) defined |
||||||
|
in terms of %tbl.table-titles.mdl |
||||||
|
and tgroup |
||||||
|
|
||||||
|
%tbl.table.att In ATTLIST of: Additional attributes on the |
||||||
|
table element table element |
||||||
|
|
||||||
|
%bodyatt In ATTLIST of: Additional attributes on the |
||||||
|
table element table element (for backward |
||||||
|
compatibility with the SGML |
||||||
|
model) |
||||||
|
|
||||||
|
%tbl.tgroup.mdl In content model of: The model group for the content |
||||||
|
<tgroup> model for <tgroup> |
||||||
|
|
||||||
|
%tbl.tgroup.att In ATTLIST of: Additional attributes on the |
||||||
|
4 <tgroup> <tgroup> element |
||||||
|
|
||||||
|
%tbl.thead.att In ATTLIST of: Additional attributes on the |
||||||
|
<thead> <thead> element |
||||||
|
|
||||||
|
%tbl.tbody.att In ATTLIST of: Additional attributes on the |
||||||
|
<tbody> <tbody> element |
||||||
|
|
||||||
|
%tbl.colspec.att In ATTLIST of: Additional attributes on the |
||||||
|
<colspec> <colspec> element |
||||||
|
|
||||||
|
%tbl.row.mdl In content model of: The model group for the content |
||||||
|
<row> model for <row> |
||||||
|
|
||||||
|
%tbl.row.att In ATTLIST of: Additional attributes on the |
||||||
|
<row> <row> element |
||||||
|
|
||||||
|
%tbl.entry.mdl In content model of: The model group for the content |
||||||
|
<entry> model for <entry> |
||||||
|
|
||||||
|
%tbl.entry.att In ATTLIST of: Additional attributes on the |
||||||
|
<entry> <entry> element |
||||||
|
|
||||||
|
This set of declarations will use the default definitions shown below |
||||||
|
for any of these parameter entities that are not declared before this |
||||||
|
set of declarations is referenced. |
||||||
|
--> |
||||||
|
|
||||||
|
<!-- These definitions are not directly related to the table model, but are |
||||||
|
used in the default CALS table model and may be defined elsewhere (and |
||||||
|
prior to the inclusion of this table module) in the referencing DTD. --> |
||||||
|
|
||||||
|
<!ENTITY % yesorno 'NMTOKEN'> <!-- no if zero(s), yes if any other value --> |
||||||
|
<!ENTITY % titles 'title?'> |
||||||
|
<!ENTITY % paracon '#PCDATA'> <!-- default for use in entry content --> |
||||||
|
|
||||||
|
<!-- |
||||||
|
The parameter entities as defined below change and simplify the CALS table |
||||||
|
model as published (as part of the Example DTD) in MIL-HDBK-28001. The |
||||||
|
resulting simplified DTD has support from the SGML Open vendors and is |
||||||
|
therefore more interoperable among different systems. |
||||||
|
|
||||||
|
These following declarations provide the Exchange default definitions |
||||||
|
for these entities. However, these entities can be redefined (by giving |
||||||
|
the appropriate parameter entity declaration(s) prior to the reference |
||||||
|
to this Table Model declaration set entity) to fit the needs of the |
||||||
|
current application. |
||||||
|
|
||||||
|
Note, however, that changes may have significant effect on the ability to |
||||||
|
interchange table information. These changes may manifest themselves |
||||||
|
in useability, presentation, and possible structure information degradation. |
||||||
|
--> |
||||||
|
|
||||||
|
<!ENTITY % tbl.table.name "table"> |
||||||
|
<!ENTITY % tbl.table-titles.mdl "%titles;,"> |
||||||
|
<!ENTITY % tbl.table-main.mdl "tgroup+"> |
||||||
|
<!ENTITY % tbl.table.mdl "%tbl.table-titles.mdl; %tbl.table-main.mdl;"> |
||||||
|
<!ENTITY % tbl.table.att " |
||||||
|
pgwide %yesorno; #IMPLIED "> |
||||||
|
<!ENTITY % bodyatt ""> |
||||||
|
<!ENTITY % tbl.tgroup.mdl "colspec*,thead?,tbody"> |
||||||
|
<!ENTITY % tbl.tgroup.att ""> |
||||||
|
<!ENTITY % tbl.thead.att ""> |
||||||
|
<!ENTITY % tbl.tbody.att ""> |
||||||
|
<!ENTITY % tbl.colspec.att ""> |
||||||
|
<!ENTITY % tbl.row.mdl "entry+"> |
||||||
|
<!ENTITY % tbl.row.att ""> |
||||||
|
<!ENTITY % tbl.entry.mdl "(%paracon;)*"> |
||||||
|
<!ENTITY % tbl.entry.att ""> |
||||||
|
|
||||||
|
<!-- ===== Element and attribute declarations follow. ===== --> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Default declarations previously defined in this entity and |
||||||
|
referenced below include: |
||||||
|
ENTITY % tbl.table.name "table" |
||||||
|
ENTITY % tbl.table-titles.mdl "%titles;," |
||||||
|
ENTITY % tbl.table.mdl "%tbl.table-titles; tgroup+" |
||||||
|
ENTITY % tbl.table.att " |
||||||
|
pgwide %yesorno; #IMPLIED " |
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT %tbl.table.name; (%tbl.table.mdl;)> |
||||||
|
|
||||||
|
<!ATTLIST %tbl.table.name; |
||||||
|
frame (top|bottom|topbot|all|sides|none) #IMPLIED |
||||||
|
colsep %yesorno; #IMPLIED |
||||||
|
rowsep %yesorno; #IMPLIED |
||||||
|
%tbl.table.att; |
||||||
|
%bodyatt; |
||||||
|
> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Default declarations previously defined in this entity and |
||||||
|
referenced below include: |
||||||
|
ENTITY % tbl.tgroup.mdl "colspec*,thead?,tbody" |
||||||
|
ENTITY % tbl.tgroup.att "" |
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT tgroup (%tbl.tgroup.mdl;) > |
||||||
|
|
||||||
|
<!ATTLIST tgroup |
||||||
|
cols NMTOKEN #REQUIRED |
||||||
|
colsep %yesorno; #IMPLIED |
||||||
|
rowsep %yesorno; #IMPLIED |
||||||
|
align (left|right|center|justify|char) #IMPLIED |
||||||
|
%tbl.tgroup.att; |
||||||
|
> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Default declarations previously defined in this entity and |
||||||
|
referenced below include: |
||||||
|
ENTITY % tbl.colspec.att "" |
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT colspec EMPTY > |
||||||
|
|
||||||
|
<!ATTLIST colspec |
||||||
|
colnum NMTOKEN #IMPLIED |
||||||
|
colname NMTOKEN #IMPLIED |
||||||
|
colwidth CDATA #IMPLIED |
||||||
|
colsep %yesorno; #IMPLIED |
||||||
|
rowsep %yesorno; #IMPLIED |
||||||
|
align (left|right|center|justify|char) #IMPLIED |
||||||
|
char CDATA #IMPLIED |
||||||
|
charoff NMTOKEN #IMPLIED |
||||||
|
%tbl.colspec.att; |
||||||
|
> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Default declarations previously defined in this entity and |
||||||
|
referenced below include: |
||||||
|
ENTITY % tbl.thead.att "" |
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT thead (row+)> |
||||||
|
|
||||||
|
<!ATTLIST thead |
||||||
|
valign (top|middle|bottom) #IMPLIED |
||||||
|
%tbl.thead.att; |
||||||
|
> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Default declarations previously defined in this entity and |
||||||
|
referenced below include: |
||||||
|
ENTITY % tbl.tbody.att "" |
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT tbody (row+)> |
||||||
|
|
||||||
|
<!ATTLIST tbody |
||||||
|
valign (top|middle|bottom) #IMPLIED |
||||||
|
%tbl.tbody.att; |
||||||
|
> |
||||||
|
|
||||||
|
<!-- |
||||||
|
Default declarations previously defined in this entity and |
||||||
|
referenced below include: |
||||||
|
ENTITY % tbl.row.mdl "entry+" |
||||||
|
ENTITY % tbl.row.att "" |
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT row (%tbl.row.mdl;)> |
||||||
|
|
||||||
|
<!ATTLIST row |
||||||
|
rowsep %yesorno; #IMPLIED |
||||||
|
valign (top|middle|bottom) #IMPLIED |
||||||
|
%tbl.row.att; |
||||||
|
> |
||||||
|
|
||||||
|
|
||||||
|
<!-- |
||||||
|
Default declarations previously defined in this entity and |
||||||
|
referenced below include: |
||||||
|
ENTITY % paracon "#PCDATA" |
||||||
|
ENTITY % tbl.entry.mdl "(%paracon;)*" |
||||||
|
ENTITY % tbl.entry.att "" |
||||||
|
--> |
||||||
|
|
||||||
|
<!ELEMENT entry %tbl.entry.mdl;> |
||||||
|
|
||||||
|
<!ATTLIST entry |
||||||
|
colname NMTOKEN #IMPLIED |
||||||
|
namest NMTOKEN #IMPLIED |
||||||
|
nameend NMTOKEN #IMPLIED |
||||||
|
morerows NMTOKEN #IMPLIED |
||||||
|
colsep %yesorno; #IMPLIED |
||||||
|
rowsep %yesorno; #IMPLIED |
||||||
|
align (left|right|center|justify|char) #IMPLIED |
||||||
|
char CDATA #IMPLIED |
||||||
|
charoff NMTOKEN #IMPLIED |
||||||
|
valign (top|middle|bottom) #IMPLIED |
||||||
|
%tbl.entry.att; |
||||||
|
> |
@ -0,0 +1,207 @@ |
|||||||
|
===================== |
||||||
|
Docutils Transforms |
||||||
|
===================== |
||||||
|
|
||||||
|
:Author: David Goodger |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Revision: $Revision: 7530 $ |
||||||
|
:Date: $Date: 2012-10-16 14:40:36 +0200 (Di, 16 Okt 2012) $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
Transforms change the document tree in-place, add to the tree, or prune it. |
||||||
|
Transforms resolve references and footnote numbers, process interpreted |
||||||
|
text, and do other context-sensitive processing. Each transform is a |
||||||
|
subclass of ``docutils.tranforms.Transform``. |
||||||
|
|
||||||
|
There are `transforms added by components`_, others (e.g. |
||||||
|
``parts.Contents``) are added by the parser, if a corresponding directive is |
||||||
|
found in the document. |
||||||
|
|
||||||
|
To add a transform, components (objects inheriting from |
||||||
|
Docutils.Component like Readers, Parsers, Writers, Input, Output) overwrite |
||||||
|
the ``get_transforms()`` method of their base class. After the Reader has |
||||||
|
finished processing, the Publisher calls |
||||||
|
``Transformer.populate_from_components()`` with a list of components and all |
||||||
|
transforms returned by the component's ``get_transforms()`` method are |
||||||
|
stored in a `transformer object` attached to the document tree. |
||||||
|
|
||||||
|
|
||||||
|
For more about transforms and the Transformer object, see also `PEP |
||||||
|
258`_. (The ``default_transforms()`` attribute of component classes mentioned |
||||||
|
there is deprecated. Use the ``get_transforms()`` method instead.) |
||||||
|
|
||||||
|
.. _PEP 258: ../peps/pep-0258.html#transformer |
||||||
|
|
||||||
|
|
||||||
|
Transforms Listed in Priority Order |
||||||
|
=================================== |
||||||
|
|
||||||
|
Transform classes each have a default_priority attribute which is used by |
||||||
|
the Transformer to apply transforms in order (low to high). The default |
||||||
|
priority can be overridden when adding transforms to the Transformer object. |
||||||
|
|
||||||
|
|
||||||
|
============================== ============================ ======== |
||||||
|
Transform: module.Class Added By Priority |
||||||
|
============================== ============================ ======== |
||||||
|
misc.class "class" (d/p) 210 |
||||||
|
|
||||||
|
references.Substitutions standalone (r), pep (r) 220 |
||||||
|
|
||||||
|
references.PropagateTargets standalone (r), pep (r) 260 |
||||||
|
|
||||||
|
frontmatter.DocTitle standalone (r) 320 |
||||||
|
|
||||||
|
frontmatter.DocInfo standalone (r) 340 |
||||||
|
|
||||||
|
frontmatter.SectSubTitle standalone (r) 350 |
||||||
|
|
||||||
|
peps.Headers pep (r) 360 |
||||||
|
|
||||||
|
peps.Contents pep (r) 380 |
||||||
|
|
||||||
|
universal.StripClasses... Writer (w) 420 |
||||||
|
|
||||||
|
references.AnonymousHyperlinks standalone (r), pep (r) 440 |
||||||
|
|
||||||
|
references.IndirectHyperlinks standalone (r), pep (r) 460 |
||||||
|
|
||||||
|
peps.TargetNotes pep (r) 520 |
||||||
|
|
||||||
|
references.TargetNotes peps.TargetNotes (t/p) 0 |
||||||
|
|
||||||
|
misc.CallBack peps.TargetNotes (t/p) 1 |
||||||
|
|
||||||
|
references.TargetNotes "target-notes" (d/p) 540 |
||||||
|
|
||||||
|
references.Footnotes standalone (r), pep (r) 620 |
||||||
|
|
||||||
|
references.ExternalTargets standalone (r), pep (r) 640 |
||||||
|
|
||||||
|
references.InternalTargets standalone (r), pep (r) 660 |
||||||
|
|
||||||
|
parts.SectNum "sectnum" (d/p) 710 |
||||||
|
|
||||||
|
parts.Contents "contents" (d/p), 720 |
||||||
|
peps.Contents (t/p) |
||||||
|
|
||||||
|
universal.StripComments Reader (r) 740 |
||||||
|
|
||||||
|
peps.PEPZero peps.Headers (t/p) 760 |
||||||
|
|
||||||
|
components.Filter "meta" (d/p) 780 |
||||||
|
|
||||||
|
universal.Decorations Reader (r) 820 |
||||||
|
|
||||||
|
misc.Transitions standalone (r), pep (r) 830 |
||||||
|
|
||||||
|
universal.ExposeInternals Reader (r) 840 |
||||||
|
|
||||||
|
references.DanglingReferences standalone (r), pep (r) 850 |
||||||
|
|
||||||
|
universal.Messages Writer (w) 860 |
||||||
|
|
||||||
|
universal.FilterMessages Writer (w) 870 |
||||||
|
|
||||||
|
universal.SmartQuotes Parser 850 |
||||||
|
|
||||||
|
universal.TestMessages DocutilsTestSupport 880 |
||||||
|
|
||||||
|
writer_aux.Compound newlatex2e (w) 910 |
||||||
|
|
||||||
|
writer_aux.Admonitions html4css1 (w), 920 |
||||||
|
latex2e (w) |
||||||
|
|
||||||
|
misc.CallBack n/a 990 |
||||||
|
============================== ============================ ======== |
||||||
|
|
||||||
|
Key: |
||||||
|
|
||||||
|
* (r): Reader |
||||||
|
* (w): Writer |
||||||
|
* (d): Directive |
||||||
|
* (t): Transform |
||||||
|
* (/p): Via a "pending" node |
||||||
|
|
||||||
|
|
||||||
|
Transform Priority Range Categories |
||||||
|
=================================== |
||||||
|
|
||||||
|
==== ==== ================================================ |
||||||
|
Priority |
||||||
|
---------- ------------------------------------------------ |
||||||
|
From To Category |
||||||
|
==== ==== ================================================ |
||||||
|
0 99 immediate execution (added by another transform) |
||||||
|
100 199 very early (non-standard) |
||||||
|
200 299 very early |
||||||
|
300 399 early |
||||||
|
400 699 main |
||||||
|
700 799 late |
||||||
|
800 899 very late |
||||||
|
900 999 very late (non-standard) |
||||||
|
==== ==== ================================================ |
||||||
|
|
||||||
|
|
||||||
|
Transforms added by components |
||||||
|
=============================== |
||||||
|
|
||||||
|
|
||||||
|
readers.Reader: |
||||||
|
| universal.Decorations, |
||||||
|
| universal.ExposeInternals, |
||||||
|
| universal.StripComments |
||||||
|
|
||||||
|
readers.ReReader: |
||||||
|
None |
||||||
|
|
||||||
|
readers.standalone.Reader: |
||||||
|
| references.Substitutions, |
||||||
|
| references.PropagateTargets, |
||||||
|
| frontmatter.DocTitle, |
||||||
|
| frontmatter.SectionSubTitle, |
||||||
|
| frontmatter.DocInfo, |
||||||
|
| references.AnonymousHyperlinks, |
||||||
|
| references.IndirectHyperlinks, |
||||||
|
| references.Footnotes, |
||||||
|
| references.ExternalTargets, |
||||||
|
| references.InternalTargets, |
||||||
|
| references.DanglingReferences, |
||||||
|
| misc.Transitions |
||||||
|
|
||||||
|
readers.pep.Reader: |
||||||
|
| references.Substitutions, |
||||||
|
| references.PropagateTargets, |
||||||
|
| references.AnonymousHyperlinks, |
||||||
|
| references.IndirectHyperlinks, |
||||||
|
| references.Footnotes, |
||||||
|
| references.ExternalTargets, |
||||||
|
| references.InternalTargets, |
||||||
|
| references.DanglingReferences, |
||||||
|
| misc.Transitions, |
||||||
|
| peps.Headers, |
||||||
|
| peps.Contents, |
||||||
|
| peps.TargetNotes |
||||||
|
|
||||||
|
parsers.rst.Parser |
||||||
|
universal.SmartQuotes |
||||||
|
|
||||||
|
writers.Writer: |
||||||
|
| universal.Messages, |
||||||
|
| universal.FilterMessages, |
||||||
|
| universal.StripClassesAndElements |
||||||
|
|
||||||
|
writers.UnfilteredWriter |
||||||
|
None |
||||||
|
|
||||||
|
writers.latex2e.Writer |
||||||
|
writer_aux.Admonitions |
||||||
|
|
||||||
|
writers.html4css1.Writer: |
||||||
|
writer_aux.Admonitions |
||||||
|
|
||||||
|
writers.odf_odt.Writer: |
||||||
|
removes references.DanglingReferences |
@ -0,0 +1,9 @@ |
|||||||
|
slide-shows.s5.html: slide-shows.txt |
||||||
|
rst2s5.py slide-shows.txt slide-shows.s5.html \
|
||||||
|
--config ../../tools/docutils.conf \
|
||||||
|
--overwrite-theme-files \
|
||||||
|
--link-stylesheet \
|
||||||
|
--no-generator --no-datestamp --no-source-link
|
||||||
|
|
||||||
|
smartquotes.html: smartquotes.txt |
||||||
|
rst2html.py smartquotes.txt smartquotes.html --smart-quotes=true
|
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 40 KiB |
@ -0,0 +1,464 @@ |
|||||||
|
===================== |
||||||
|
Docutils_ Link List |
||||||
|
===================== |
||||||
|
|
||||||
|
:Author: Lea Wiemann, the Docutils team |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Revision: $Revision: 8025 $ |
||||||
|
:Date: $Date: 2017-02-06 15:35:40 +0100 (Mo, 06 Feb 2017) $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
.. title:: Docutils Links |
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
This document contains links users of Docutils and reStructuredText |
||||||
|
may find useful. Many of the projects |
||||||
|
listed here are hosted in the `Docutils Sandbox`_. If you have |
||||||
|
something to publish, you can get write access, too! |
||||||
|
|
||||||
|
The most current version of this link list can always be found at |
||||||
|
http://docutils.sourceforge.net/docs/user/links.html. |
||||||
|
|
||||||
|
.. _Docutils: http://docutils.sourceforge.net/ |
||||||
|
.. _Docutils Sandbox: http://docutils.sf.net/sandbox/README.html |
||||||
|
|
||||||
|
|
||||||
|
Editors |
||||||
|
------- |
||||||
|
|
||||||
|
Advanced text editors with reStructuredText support, IDEs, and docutils GUIs: |
||||||
|
|
||||||
|
* Emacs `rst mode <http://docutils.sf.net/tools/editors/emacs>`__. |
||||||
|
|
||||||
|
* `Vim <http://www.vim.org/index.php>`__: |
||||||
|
|
||||||
|
- `reStructuredText syntax highlighting mode |
||||||
|
<http://www.vim.org/scripts/script.php?script_id=973>`__, |
||||||
|
|
||||||
|
- `VST <http://www.vim.org/scripts/script.php?script_id=1334>`__ (Vim |
||||||
|
reStructuredText) plugin for Vim7 with folding. |
||||||
|
|
||||||
|
- `VOoM <http://www.vim.org/scripts/script.php?script_id=2657>`__ |
||||||
|
plugin for Vim that emulates two-pane outliner with |
||||||
|
support for reStructuredText (since version 4.0b2). |
||||||
|
|
||||||
|
- `Riv: Take notes in rst <https://github.com/Rykka/riv.vim>`__ Vim |
||||||
|
plugin to take notes in reStructured text. |
||||||
|
|
||||||
|
* `JED <http://www.jedsoft.org/jed/>`__ programmers editor with |
||||||
|
`rst mode <http://jedmodes.sf.net/mode/rst/>`__ |
||||||
|
|
||||||
|
* `reStructuredText editor plug-in for Eclipse`__ |
||||||
|
|
||||||
|
__ http://resteditor.sf.net/ |
||||||
|
|
||||||
|
* Gnome's gedit offers syntax highlighting and a reST preview pane. |
||||||
|
|
||||||
|
Latest version of the plugin is available from `bittner @ github`_ |
||||||
|
(See also: `Gedit third party plugins`__). |
||||||
|
|
||||||
|
__ https://wiki.gnome.org/Apps/Gedit/ThirdPartyPlugins-v3.8 |
||||||
|
|
||||||
|
.. _bittner @ github: https://github.com/bittner/gedit-reST-plugin |
||||||
|
|
||||||
|
* A BBEdit_/TextWrangler `language module`__ for editing reST documents. |
||||||
|
|
||||||
|
.. _BBEdit: https://en.wikipedia.org/wiki/BBEdit |
||||||
|
__ http://ericfromcanada.bitbucket.org/ |
||||||
|
|
||||||
|
* Gunnar Schwant's DocFactory_ is a wxPython GUI application for |
||||||
|
Docutils. |
||||||
|
|
||||||
|
* ReSTedit_ by Bill Bumgarner is a Docutils GUI for Mac OS X. |
||||||
|
|
||||||
|
* Leo_ is an outliner_, written in Python using PyQt. It can be used as IDE |
||||||
|
for literal programming, as a filing cabinet holding any kind of data and |
||||||
|
as `document editor`__ with outlines containing reStructuredText markup. |
||||||
|
|
||||||
|
.. _outliner: http://en.wikipedia.org/wiki/Outliner |
||||||
|
__ http://leoeditor.com/tutorial-rst3.html |
||||||
|
|
||||||
|
* `NoTex <https://notex.ch>`_ is a browser-based reStructuredText editor |
||||||
|
with syntax highlighting and PDF/HTML export functionality using Sphinx. |
||||||
|
|
||||||
|
* `rsted <https://github.com/anru/rsted>`_ is a "simple online editor for |
||||||
|
reStructuredText on Flask". You can try it on http://rst.ninjs.org/ |
||||||
|
|
||||||
|
.. _DocFactory: http://docutils.sf.net/sandbox/gschwant/docfactory/doc/ |
||||||
|
.. _ReSTedit: http://www.friday.com/bbum/index.php?s=restedit |
||||||
|
.. _Leo: http://leoeditor.com/ |
||||||
|
|
||||||
|
|
||||||
|
Export |
||||||
|
------ |
||||||
|
|
||||||
|
Convert reStructuredText to other formats: |
||||||
|
|
||||||
|
PDF |
||||||
|
``` |
||||||
|
|
||||||
|
* `rst2pdf (reportlab) |
||||||
|
<http://rst2pdf.googlecode.com>`_ is a tool to go |
||||||
|
directly from reStructuredText to PDF, via `reportlab |
||||||
|
<http://www.reportlab.org/rl_toolkit.html>`_. No LaTeX installation is |
||||||
|
required. |
||||||
|
|
||||||
|
* `rst2pdf (pdflatex) |
||||||
|
<http://docutils.sourceforge.net/sandbox/blais/rst2pdf/>`_ by Martin Blais |
||||||
|
is a minimal front end producing LaTeX, compiling the LaTeX file, getting |
||||||
|
the produced output to the destination location and finally deleting all |
||||||
|
the messy temporary files that this process generates. |
||||||
|
|
||||||
|
* `rst2pdf (rubber) |
||||||
|
<http://docutils.sf.net/sandbox/rst2pdf/README.html>`_ is |
||||||
|
a front end for the generation of PDF documents from a reStructuredText |
||||||
|
source via LaTeX in one step cleaning up intermediate files. It uses the |
||||||
|
`rubber <http://iml.univ-mrs.fr/~beffara/soft/rubber/>`_ Python wrapper |
||||||
|
for LaTeX and friends. |
||||||
|
|
||||||
|
* ``py.rest`` from the Codespeak `py Lib scripts`_ converts |
||||||
|
reStructuredText files to HTML and PDF (cleaning up the intermediate |
||||||
|
latex files). Similar to ``buildhtml.py``, it looks recursively for |
||||||
|
.txt files in the given PATHS. |
||||||
|
|
||||||
|
* rlpdf_ is another PDF Writer based on ReportLabs. |
||||||
|
|
||||||
|
* RinohType_ is a pure Python PDF Writer based on a document template and a |
||||||
|
style sheet (beta). |
||||||
|
|
||||||
|
.. _py Lib scripts: http://codespeak.net/py/dist/bin.html |
||||||
|
.. _rlpdf: http://docutils.sf.net/sandbox/dreamcatcher/rlpdf/ |
||||||
|
.. _RinohType: http://pypi.python.org/pypi/RinohType/0.2.1 |
||||||
|
|
||||||
|
OpenOffice |
||||||
|
`````````` |
||||||
|
|
||||||
|
* Since version 0.5, the odtwriter_ by Dave Kuhlman is part of the Docutils_ |
||||||
|
core. |
||||||
|
|
||||||
|
.. _odtwriter: http://docutils.sf.net/docs/user/odt.html |
||||||
|
|
||||||
|
|
||||||
|
website generators and HTML variants |
||||||
|
```````````````````````````````````` |
||||||
|
|
||||||
|
* The Sphinx_ Python Documentation Generator by Georg Brandl was originally |
||||||
|
created to translate the `Python documentation`_, and is now `used by |
||||||
|
<http://sphinx.pocoo.org/examples.html>`__ a wide choice of projects. |
||||||
|
|
||||||
|
It can generate complete web sites (interlinked and indexed HTML pages), |
||||||
|
ePub, PDF, and others [#]_ from a set of rst source files. |
||||||
|
|
||||||
|
.. [#] see http://sphinx-doc.org/config.html#options-for-epub-output |
||||||
|
.. _Sphinx: http://sphinx.pocoo.org/ |
||||||
|
|
||||||
|
* The Nikola_ static site generator, uses reStructuredText by |
||||||
|
default. |
||||||
|
|
||||||
|
.. _nikola: http://getnikola.com/ |
||||||
|
|
||||||
|
* Pelican_ is a static site generator (mainly for blogs). Articles/pages can |
||||||
|
be written in reStructuredText or Markdown\ [#markdown]_ format. |
||||||
|
|
||||||
|
.. _pelican: http://docs.getpelican.com |
||||||
|
|
||||||
|
* tinkerer_ is a static bloggin framework based on Sphinx_. |
||||||
|
|
||||||
|
.. _tinkerer: http://tinkerer.me |
||||||
|
|
||||||
|
* rst2ht_ by Oliver Rutherfurd, converts reStructuredText to an .ht |
||||||
|
template, for use with ht2html_. |
||||||
|
|
||||||
|
.. _rst2ht: http://www.rutherfurd.net/articles/rst-ht2html.html |
||||||
|
.. _ht2html: http://ht2html.sourceforge.net/ |
||||||
|
|
||||||
|
* htmlnav_ by Gunnar Schwant, is an HTML writer which supports navigation |
||||||
|
bars. |
||||||
|
|
||||||
|
.. _htmlnav: http://docutils.sf.net/sandbox/gschwant/htmlnav/ |
||||||
|
|
||||||
|
* rest2web_, by Michael Foord, is a tool for creating web sites with |
||||||
|
reStructuredText. |
||||||
|
|
||||||
|
.. _rest2web: http://www.voidspace.org.uk/python/rest2web/ |
||||||
|
|
||||||
|
* rst2chm_ by Oliver Rutherfurd, generates Microsoft HTML Help files from |
||||||
|
reStructuredText files. |
||||||
|
|
||||||
|
.. _rst2chm: http://www.rutherfurd.net/software/rst2chm/ |
||||||
|
|
||||||
|
* `html4strict <http://docutils.sf.net/sandbox/html4strict/>`__ |
||||||
|
produces XHTML that strictly conforms to the XHTML 1.0 specification. |
||||||
|
|
||||||
|
* `html4trans <http://docutils.sf.net/sandbox/html4trans/>`__ |
||||||
|
produces XHTML conforming to the version 1.0 Transitional DTD that |
||||||
|
contains enough formatting information to be viewed by a lightweight HTML |
||||||
|
browser without CSS support. |
||||||
|
|
||||||
|
* A `simple HTML writer`_ by Bill Bumgarner that doesn't rely on CSS |
||||||
|
(stylesheets). |
||||||
|
|
||||||
|
.. _simple HTML writer: http://docutils.sf.net/sandbox/bbum/DocArticle/ |
||||||
|
|
||||||
|
ePub |
||||||
|
```` |
||||||
|
|
||||||
|
* The `rst2epub`_ project by Robert Wierschke converts simple |
||||||
|
reStructuredText doucments into valid epub files. |
||||||
|
|
||||||
|
.. simple but well structured with classes/modules for epub components, |
||||||
|
and a standard ``setup.py`` installation file. |
||||||
|
|
||||||
|
* rst2epub2_ by Matt Harrison includes the epublib (originally by Tim |
||||||
|
Tambin) and a rst2epub.py executable for the conversion. |
||||||
|
|
||||||
|
* Sphinx_ provides ePub as output option, too. |
||||||
|
|
||||||
|
.. _rst2epub: https://bitbucket.org/wierob/rst2epub |
||||||
|
.. _rst2epub2: https://github.com/mattharrison/rst2epub2 |
||||||
|
|
||||||
|
|
||||||
|
Others |
||||||
|
`````` |
||||||
|
|
||||||
|
* Pandoc_ is a document converter that can write Markdown\ [#markdown]_, |
||||||
|
reStructuredText, HTML, LaTeX, RTF, DocBook XML, and S5. |
||||||
|
|
||||||
|
* restxsl_ by Michael Alyn Miller, lets you transform reStructuredText |
||||||
|
documents into XML/XHTML files using XSLT stylesheets. |
||||||
|
|
||||||
|
* An `XSLT script`__ by Ladislav Lhotka enables reStructuredText annotations |
||||||
|
to be included in RELAG NG XML schemas. |
||||||
|
|
||||||
|
__ http://www.cesnet.cz/doc/techzpravy/2006/rngrest/ |
||||||
|
|
||||||
|
* `DocBook Writer`_ by Oliver Rutherfurd. |
||||||
|
|
||||||
|
* Nabu_, written by Martin Blais, is a publishing system which |
||||||
|
extracts information from reStructuredText documents and stores it |
||||||
|
in a database. Python knowledge is required to write extractor |
||||||
|
functions (see `Writing an Extractor`_) and to retrieve the data |
||||||
|
from the database again. |
||||||
|
|
||||||
|
* The `pickle writer`_ by Martin Blais pickles the document tree to a binary |
||||||
|
string. Later unpickling will allow you to publish with other Writers. |
||||||
|
|
||||||
|
* The `Texinfo Writer`_, by Jon Waltman converts reStructuredText to |
||||||
|
Texinfo, the documentation format used by the GNU project and the |
||||||
|
Emacs text editor. Texinfo can be used to produce multiple output |
||||||
|
formats, including HTML, PDF, and Info. |
||||||
|
|
||||||
|
* For `confluence CMS`_ see https://github.com/netresearch/rst2confluence. |
||||||
|
|
||||||
|
* Deploying into wikis might be aided by deploy-rst_. |
||||||
|
|
||||||
|
.. _Pandoc: http://sophos.berkeley.edu/macfarlane/pandoc/ |
||||||
|
.. _restxsl: http://www.strangeGizmo.com/products/restxsl/ |
||||||
|
.. _DocBook Writer: http://docutils.sf.net/sandbox/oliverr/docbook/ |
||||||
|
.. _Nabu: http://furius.ca/nabu/ |
||||||
|
.. _Writing an Extractor: http://furius.ca/nabu/doc/nabu-extractor.html |
||||||
|
.. _pickle writer: http://docutils.sf.net/sandbox/blais/pickle_writer/ |
||||||
|
.. _Texinfo Writer: http://docutils.sf.net/sandbox/texinfo-writer/README.html |
||||||
|
.. _confluence CMS: http://www.atlassian.com/software/confluence |
||||||
|
.. _deploy-rst: https://github.com/netresearch/deploy-rst |
||||||
|
|
||||||
|
|
||||||
|
Import |
||||||
|
------ |
||||||
|
|
||||||
|
Convert other formats to reStructuredText: |
||||||
|
|
||||||
|
* recommonmark_ is a Markdown\ [#markdown]_ (CommonMark_) parser for docutils. |
||||||
|
|
||||||
|
* sxw2rest_, by Trent W. Buck, converts StarOffice XML Writer (SXW) |
||||||
|
files to reStructuredText. |
||||||
|
|
||||||
|
* xml2rst_, an XSLT stylesheet written by Stefan Merten, converts XML |
||||||
|
dumps of the document tree (e.g. created with rst2xml.py) back to |
||||||
|
reStructuredText. |
||||||
|
|
||||||
|
* xhtml2rest_, written by Antonios Christofides, is a simple utility |
||||||
|
to convert XHTML to reStructuredText. |
||||||
|
|
||||||
|
* DashTable_ by Gustav Klopp converts HTML tables into reStructuredText. |
||||||
|
Colspan and Rowspan supported! |
||||||
|
|
||||||
|
.. _DashTable: https://github.com/gustavklopp/DashTable |
||||||
|
|
||||||
|
* Sphinx_ includes a `LaTeX to Rst converter |
||||||
|
<http://svn.python.org/projects/doctools/converter/>`__ in its source code |
||||||
|
(trimmed to importing the old Python docs). |
||||||
|
|
||||||
|
* Pandoc_ can read Markdown\ [#markdown]_ and (subsets of) HTML, and LaTeX and export to |
||||||
|
(amongst others) reStructuredText. |
||||||
|
|
||||||
|
* PySource_, by Tony Ibbs, is an experimental Python source Reader. |
||||||
|
There is some related code in David Goodger's sandbox |
||||||
|
(pysource_reader_) and a `Python Source Reader`_ document. |
||||||
|
|
||||||
|
.. [#markdown] |
||||||
|
`Markdown <http://daringfireball.net/projects/markdown/syntax>`__ is |
||||||
|
another lightwight markup language. See also documentation on `Common |
||||||
|
markup for Markdown and reStructuredText`_. |
||||||
|
|
||||||
|
.. _recommonmark: https://github.com/rtfd/recommonmark |
||||||
|
.. _CommonMark: http://commonmark.org/ |
||||||
|
.. _sxw2rest: http://twb.ath.cx/~twb/darcs/sxw2rest/ |
||||||
|
.. _xml2rst: http://www.merten-home.de/FreeSoftware/xml2rst/index.html |
||||||
|
.. _xhtml2rest: http://docutils.sf.net/sandbox/wiemann/xhtml2rest/ |
||||||
|
.. _PySource: http://docutils.sf.net/sandbox/tibs/pysource/ |
||||||
|
.. _pysource_reader: http://docutils.sf.net/sandbox/davidg/pysource_reader/ |
||||||
|
.. _Python Source Reader: http://docutils.sf.net/docs/dev/pysource.html |
||||||
|
.. _Common markup for Markdown and reStructuredText: |
||||||
|
https://gist.github.com/dupuy/1855764 |
||||||
|
|
||||||
|
|
||||||
|
Extensions |
||||||
|
---------- |
||||||
|
|
||||||
|
Extend the reStructuredText syntax or the features of Docutils. |
||||||
|
More extensions are in the `Docutils Sandbox`_. |
||||||
|
|
||||||
|
* Beni Cherniavsky has written a generic `preprocessing module`_ for |
||||||
|
roles and/or directives and built preprocessors for TeX math for |
||||||
|
both LaTeX and HTML output on top of it. |
||||||
|
|
||||||
|
* Beni Cherniavsky maintains a Makefile_ for driving Docutils, hoping |
||||||
|
to handle everything one might do with Docutils. |
||||||
|
|
||||||
|
* The `ASCII art to SVG converter`_ (aafigure) developed by |
||||||
|
Chris Liechti can parse ASCII art images, embedded in reST documents and |
||||||
|
output an image. This would mean that simple illustrations could be |
||||||
|
embedded as ASCII art in the reST source and still look nice when |
||||||
|
converted to e.g. HTML |
||||||
|
|
||||||
|
* zot4rst_ by Erik Hetzner is an extension that allows users to write reST |
||||||
|
documents using citations from a Zotero_ library. |
||||||
|
|
||||||
|
* Quick and easy publishing reStructuredText source files as blog posts |
||||||
|
on blogger.com is possible with `rst2blogger`_ . |
||||||
|
|
||||||
|
.. _preprocessing module: http://docutils.sf.net/sandbox/cben/rolehack/ |
||||||
|
.. _Makefile: http://docutils.sf.net/sandbox/cben/make/ |
||||||
|
.. _ASCII art to SVG converter: |
||||||
|
http://docutils.sf.net/sandbox/cliechti/aafigure/ |
||||||
|
.. _zot4rst: http://e6h.org/~egh/hg/zotero-plain |
||||||
|
.. _Zotero: http://www.zotero.org/ |
||||||
|
.. _rst2blogger: https://github.com/dhellmann/rst2blogger#readme |
||||||
|
|
||||||
|
|
||||||
|
Related Applications |
||||||
|
-------------------- |
||||||
|
|
||||||
|
Applications using docutils/reStructuredText and helper applications. |
||||||
|
|
||||||
|
* For Wikis, please see the `FAQ entry about Wikis`_. |
||||||
|
|
||||||
|
* For Blogs (Weblogs), please see the `FAQ entry about Blogs`_. |
||||||
|
|
||||||
|
* `Project Gutenberg`_ uses a customized version of Docutils with it's own |
||||||
|
xetex- and nroff-writer and epub generator. |
||||||
|
|
||||||
|
.. _FAQ entry about Wikis: http://docutils.sf.net/FAQ.html |
||||||
|
#are-there-any-wikis-that-use-restructuredtext-syntax |
||||||
|
.. _FAQ entry about Blogs: http://docutils.sf.net/FAQ.html |
||||||
|
#are-there-any-weblog-blog-projects-that-use-restructuredtext-syntax |
||||||
|
.. _Project Gutenberg: http://www.gutenberg.org |
||||||
|
|
||||||
|
|
||||||
|
Tools |
||||||
|
````` |
||||||
|
|
||||||
|
* rstcheck_ Checks syntax of reStructuredText and code blocks nested within |
||||||
|
it. (Using the Sphinx syntax "code-block" for the "code" directive.) |
||||||
|
|
||||||
|
.. _rstcheck: https://pypi.python.org/pypi/rstcheck |
||||||
|
|
||||||
|
* restview_ is a viewer for ReStructuredText documents. |
||||||
|
|
||||||
|
Pass the name of a ReStructuredText document to restview, and it will |
||||||
|
launch a web server on localhost:random-port and open a web browser. It |
||||||
|
will also watch for changes in that file and automatically reload and |
||||||
|
rerender it. This is very convenient for previewing a document while |
||||||
|
you're editing it. |
||||||
|
|
||||||
|
.. _restview: http://mg.pov.lt/restview/ |
||||||
|
|
||||||
|
|
||||||
|
Development |
||||||
|
``````````` |
||||||
|
|
||||||
|
* Sphinx_ extends the ReStructuredText syntax to better support the |
||||||
|
documentation of Software (and other) *projects* (but other documents |
||||||
|
can be written with it too). |
||||||
|
|
||||||
|
Since version 2.6, the `Python documentation`_ is based on |
||||||
|
reStructuredText and Sphinx. |
||||||
|
|
||||||
|
* Trac_, a project management and bug/issue tracking system, supports |
||||||
|
`using reStructuredText |
||||||
|
<http://trac.edgewall.org/wiki/WikiRestructuredText>`__ as an |
||||||
|
alternative to wiki markup. |
||||||
|
|
||||||
|
* PyLit_ provides a bidirectional text <--> code converter for *literate |
||||||
|
programming with reStructuredText*. |
||||||
|
|
||||||
|
* If you are developing a Qt app, rst2qhc_ lets you generate the whole help |
||||||
|
automatically from reStructuredText. That includes keywords, TOC, |
||||||
|
multiple manuals per project, filters, project file, collection project |
||||||
|
file, and more. |
||||||
|
|
||||||
|
.. _Python documentation: http://docs.python.org/ |
||||||
|
.. _Trac: http://trac.edgewall.org/ |
||||||
|
.. _PyLit: http://repo.or.cz/pylit.git |
||||||
|
.. _rst2qhc: http://rst2qhc.googlecode.com |
||||||
|
|
||||||
|
|
||||||
|
CMS Systems |
||||||
|
``````````` |
||||||
|
|
||||||
|
* Plone_ and Zope_ both support reStructuredText markup. |
||||||
|
* ZReST_, by Richard Jones, is a "ReStructuredText Document for Zope_" |
||||||
|
application that is complete and ready to install. |
||||||
|
|
||||||
|
.. _Plone: http://plone.org/ |
||||||
|
.. _Zope: http://www.zope.org/ |
||||||
|
.. _ZReST: http://docutils.sf.net/sandbox/richard/ZReST/ |
||||||
|
|
||||||
|
|
||||||
|
Presentations |
||||||
|
````````````` |
||||||
|
|
||||||
|
* rst2html5_ transform restructuredtext documents to html5 + twitter's |
||||||
|
bootstrap css, deck.js or reveal.js |
||||||
|
|
||||||
|
* landslide_ generates HTML5 slideshows from markdown, ReST, or textile. |
||||||
|
|
||||||
|
* `native support for S5 <slide-shows.s5.html>`_. |
||||||
|
|
||||||
|
* The `PythonPoint interface`_ by Richard Jones produces PDF |
||||||
|
presentations using ReportLabs' PythonPoint_. |
||||||
|
|
||||||
|
* rst2beamer_ generates a LaTeX source that uses the `Beamer` document class. |
||||||
|
Can be converted to PDF slides with pdfLaTeX/XeLaTeX/LuaLaTeX. |
||||||
|
|
||||||
|
* InkSlide_ quick and easy presentations using Inkscape_. InkSlide uses |
||||||
|
reStructuredText for markup, although it renders only a subset of rst. |
||||||
|
|
||||||
|
* rst2outline_ translates a reStructuredText document to a plain text |
||||||
|
outline. This can then be transformed to PowerPoint. |
||||||
|
|
||||||
|
* Pandoc_ can also be used to produce slides, as shown in this |
||||||
|
`Pandoc Slides Demo`_ |
||||||
|
|
||||||
|
.. _PythonPoint: http://www.reportlab.org/python_point.html |
||||||
|
.. _PythonPoint interface: http://docutils.sf.net/sandbox/richard/pythonpoint/ |
||||||
|
.. _rst2beamer: http://docutils.sf.net/sandbox/rst2beamer/ |
||||||
|
.. _Inkscape: http://inkscape.org/ |
||||||
|
.. _InkSlide: http://wiki.inkscape.org/wiki/index.php/InkSlide |
||||||
|
.. _rst2html5: https://github.com/marianoguerra/rst2html5 |
||||||
|
.. _landslide: https://github.com/adamzap/landslide |
||||||
|
.. _rst2outline: http://docutils.sf.net/sandbox/rst2outline/ |
||||||
|
.. _Pandoc Slides Demo: |
||||||
|
http://johnmacfarlane.net/pandoc/demo/example9/producing-slide-shows-with-pandoc |
@ -0,0 +1,157 @@ |
|||||||
|
========================= |
||||||
|
Docutils_ Mailing Lists |
||||||
|
========================= |
||||||
|
|
||||||
|
:Author: Lea Wiemann |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Revision: $Revision: 8111 $ |
||||||
|
:Date: $Date: 2017-06-10 22:35:01 +0200 (Sa, 10 Jun 2017) $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
|
||||||
|
.. Gmane went down 2016 and is only partially restored. |
||||||
|
http://home.gmane.org/2016/08/29/next-steps-gmane/ |
||||||
|
|
||||||
|
.. raw:: html |
||||||
|
|
||||||
|
<div class="sidebar"> |
||||||
|
<p class="first sidebar-title">Search the list archives</p> |
||||||
|
<form method="get" action="https://sourceforge.net/p/docutils/mailman/search/"> |
||||||
|
<p style="margin-bottom: 3px;"><input type="text" name="q" style="width: 100%;" /></p> |
||||||
|
<p>Search in <select name="mail_list"> |
||||||
|
<option value="all">all mailing lists</option> |
||||||
|
<option value="docutils-users">Docutils-users</option> |
||||||
|
<option value="docutils-develop">Docutils-develop</option> |
||||||
|
<option value="docutils-checkins">Docutils-checkins</option> |
||||||
|
</select></p> |
||||||
|
<p class="last"><input type="submit" value="Search" /></p> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
|
||||||
|
All discussion about Docutils takes place on mailing lists. |
||||||
|
|
||||||
|
There are four different lists with traffic related to Docutils. |
||||||
|
For an oversight, see https://sourceforge.net/p/docutils/mailman/. |
||||||
|
If unsure, use the **Docutils-users** mailing list: |
||||||
|
|
||||||
|
|
||||||
|
Docutils-users |
||||||
|
-------------- |
||||||
|
|
||||||
|
The `Docutils-users mailing list`_ is a place to discuss any issues |
||||||
|
related to the usage of Docutils and reStructuredText. (Please be |
||||||
|
sure to check the FAQ_ first.) |
||||||
|
|
||||||
|
There are several possibilities to **read and post** messages on the |
||||||
|
mailing lists; use the one you feel most comfortable with. |
||||||
|
|
||||||
|
* Using an `email subscription`__. This is the traditional way; you |
||||||
|
will receive all messages sent to the mailing list via email. |
||||||
|
|
||||||
|
__ `docutils-users mailing list`_ |
||||||
|
|
||||||
|
.. * Using Gmane's `web interface`__. To post a message, click "post" or |
||||||
|
"followup" in the drop-down menu on the right. (Gmane also has a |
||||||
|
complete **archive** of the mailing list; use the search form at the |
||||||
|
top of this page to search it.) |
||||||
|
|
||||||
|
__ http://news.gmane.org/gmane.text.docutils.user |
||||||
|
|
||||||
|
* Use a newsreader with Gmane's `NNTP interface`__ |
||||||
|
(gmane.text.docutils.user on news.gmane.org). |
||||||
|
|
||||||
|
__ nntp://news.gmane.org/gmane.text.docutils.user |
||||||
|
|
||||||
|
* **If you do not wish to subscribe,** you can also just send an email |
||||||
|
message with your question or comment to |
||||||
|
Docutils-users@lists.sourceforge.net. |
||||||
|
|
||||||
|
Note in your message that you are not subscribed (to make sure that you |
||||||
|
receive copies [CCs] of any replies) or check for answers in the |
||||||
|
`Docutils-users Archives`_. |
||||||
|
|
||||||
|
The first time you post a message without being subscribed (also when |
||||||
|
posting via Gmane), you will receive an automatic response with the subject |
||||||
|
"Your message to Docutils-users awaits moderator approval"; this is done to |
||||||
|
prevent spam to the mailing lists. Your message will usually be approved |
||||||
|
within a few hours. To avoid duplicates, please do not resend your message |
||||||
|
using a different email address. After your first message has been |
||||||
|
approved, your email address will be added to the whitelist and future |
||||||
|
messages will be posted to the mailing list without moderation. |
||||||
|
|
||||||
|
To see the collection of prior postings to the list, visit the |
||||||
|
`Docutils-users Archives`_. |
||||||
|
|
||||||
|
|
||||||
|
Docutils-develop |
||||||
|
---------------- |
||||||
|
|
||||||
|
Discussions about developing and extending Docutils take place on the |
||||||
|
`Docutils-develop mailing list`_. |
||||||
|
|
||||||
|
You can access this list via `email subscription`__ or news__ |
||||||
|
(gmane.text.docutils.devel); the posting address is |
||||||
|
Docutils-develop@lists.sourceforge.net. |
||||||
|
|
||||||
|
To see the collection of prior postings to the list, visit the |
||||||
|
`Docutils-develop Archives`__. |
||||||
|
|
||||||
|
__ `Docutils-develop mailing list`_ |
||||||
|
__ nntp://news.gmane.org/gmane.text.docutils.devel |
||||||
|
__ http://sourceforge.net/mailarchive/forum.php?forum_name=docutils-develop |
||||||
|
|
||||||
|
Docutils-checkins |
||||||
|
----------------- |
||||||
|
|
||||||
|
All check-ins to the `Subversion repository`_ cause a "check-in email" |
||||||
|
to the `Docutils-checkins list`_. In order to stay informed about |
||||||
|
current development, developers are advised to monitor this mailing |
||||||
|
list. |
||||||
|
|
||||||
|
This mailing list is for reading only; please direct any discussion |
||||||
|
about the check-ins to Docutils-develop. (For your convenience, the |
||||||
|
Reply-To header of all check-in emails points to Docutils-develop.) |
||||||
|
|
||||||
|
This mailing list is accessible via `email subscription`__ or |
||||||
|
news__ (gmane.text.docutils.cvs) as well. |
||||||
|
|
||||||
|
If you are using an email subscription and you would prefer to only |
||||||
|
receive check-in messages for changes that affect the main Docutils |
||||||
|
distribution (i.e. ``trunk/docutils/*``), go to the `list options`_ |
||||||
|
page and select the "Docutils core" topic. |
||||||
|
|
||||||
|
__ `Docutils-checkins list`_ |
||||||
|
__ nntp://news.gmane.org/gmane.text.docutils.cvs |
||||||
|
.. _list options: http://lists.sf.net/lists/options/docutils-checkins |
||||||
|
|
||||||
|
Doc-SIG |
||||||
|
------- |
||||||
|
|
||||||
|
The "Python Documentation Special Interest Group" (`Doc-SIG`_) mailing list |
||||||
|
is occasionally used to discuss the usage of Docutils for Python |
||||||
|
documentation. |
||||||
|
|
||||||
|
This mailing list can be accessed via `email subscription`__ or |
||||||
|
news__ (gmane.comp.python.documentation) as well. You must be |
||||||
|
subscribed in order to post messages to this mailing list. |
||||||
|
|
||||||
|
__ `Doc-SIG`_ |
||||||
|
__ nntp://news.gmane.org/gmane.comp.python.documentation |
||||||
|
|
||||||
|
|
||||||
|
.. _Docutils-users mailing list: |
||||||
|
http://lists.sourceforge.net/lists/listinfo/docutils-users |
||||||
|
.. _Docutils-users Archives: |
||||||
|
http://sourceforge.net/mailarchive/forum.php?forum_name=docutils-users |
||||||
|
.. _Docutils-develop mailing list: |
||||||
|
http://lists.sourceforge.net/lists/listinfo/docutils-develop |
||||||
|
.. _Docutils-develop Archives: |
||||||
|
http://sourceforge.net/mailarchive/forum.php?forum_name=docutils-develop |
||||||
|
.. _Docutils-checkins list: |
||||||
|
http://lists.sourceforge.net/lists/listinfo/docutils-checkins |
||||||
|
.. _Doc-SIG: |
||||||
|
http://mail.python.org/mailman/listinfo/doc-sig |
||||||
|
|
||||||
|
.. _Subversion repository: ../dev/repository.html |
||||||
|
.. _Docutils: http://docutils.sourceforge.net/ |
||||||
|
.. _FAQ: ../../FAQ.html |
@ -0,0 +1,163 @@ |
|||||||
|
============================== |
||||||
|
manpage writer for Docutils_ |
||||||
|
============================== |
||||||
|
|
||||||
|
:Author: Engelbert Gruber |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Revision: $Revision: 7302 $ |
||||||
|
:Date: $Date: 2012-01-03 20:23:53 +0100 (Di, 03 Jan 2012) $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
This tries to explore the posibilities to generate man-pages from |
||||||
|
reStructuredText. Man pages are the way for Unix systems to provide |
||||||
|
help to the user. GNU does this with (TeX)info-pages. |
||||||
|
|
||||||
|
Module information |
||||||
|
'''''''''''''''''' |
||||||
|
|
||||||
|
Unix man page belong into a numbered section, 1 is user commands, 8 contains |
||||||
|
administrator commands, the headlines of all manpages are collected into a |
||||||
|
database, queryable with the programm ``apropos``, therefore the headline |
||||||
|
should contain a short text describing into which group this command belongs. |
||||||
|
|
||||||
|
These informations are collected from title, subtitle and the docinfo. |
||||||
|
|
||||||
|
Also man pages have a defined set of sections, that are more or less |
||||||
|
mandatory, see References_. |
||||||
|
|
||||||
|
man pages look like:: |
||||||
|
|
||||||
|
man(1) Man Pager Utils man(1) |
||||||
|
|
||||||
|
NAME |
||||||
|
man - an interface to the on-line reference manuals |
||||||
|
|
||||||
|
SYNOPSIS |
||||||
|
man [-c|-w|-tZT device] [-adhu7V] [-m system[,...]] [-L locale] |
||||||
|
|
||||||
|
in roff formatting:: |
||||||
|
|
||||||
|
.TH man 1 "14 May 2001" "2.3.19" "Manual pager utils" |
||||||
|
.SH NAME |
||||||
|
man \- an interface to the on-line reference manuals |
||||||
|
.SH SYNOPSIS |
||||||
|
.\" The general command line |
||||||
|
.B man |
||||||
|
.RB [\| \-c \||\| \-w \||\| \-tZT |
||||||
|
.IR device \|] |
||||||
|
|
||||||
|
This means we have |
||||||
|
|
||||||
|
* a title "man" |
||||||
|
* a subtitle "an interface to the on-line reference manuals" |
||||||
|
* a manual section "1" |
||||||
|
* a manual group "Manual pager utils" |
||||||
|
* a date "14 May 2001" |
||||||
|
* a version "2.3.19" |
||||||
|
|
||||||
|
References |
||||||
|
'''''''''' |
||||||
|
|
||||||
|
man pages from section 7, ``man`` and ``man-pages``. |
||||||
|
|
||||||
|
.. [LMHT] Linux Man Page Howto. |
||||||
|
|
||||||
|
Conventions |
||||||
|
''''''''''' |
||||||
|
|
||||||
|
* man pages have a special structure and organization. From the manpage |
||||||
|
to *man*:: |
||||||
|
|
||||||
|
The table below shows the section numbers of the manual followed by the |
||||||
|
types of pages they contain. |
||||||
|
|
||||||
|
1 Executable programs or shell commands |
||||||
|
2 System calls (functions provided by the kernel) |
||||||
|
3 Library calls (functions within program libraries) |
||||||
|
4 Special files (usually found in /dev) |
||||||
|
5 File formats and conventions eg /etc/passwd |
||||||
|
6 Games |
||||||
|
7 Miscellaneous (including macro packages and conven- |
||||||
|
tions), e.g. man(7), groff(7) |
||||||
|
8 System administration commands (usually only for root) |
||||||
|
9 Kernel routines [Non standard] |
||||||
|
|
||||||
|
A manual page consists of several parts. |
||||||
|
|
||||||
|
They may be labelled NAME, SYNOPSIS, DESCRIPTION, OPTIONS, FILES, |
||||||
|
SEE ALSO, BUGS, and AUTHOR. |
||||||
|
|
||||||
|
The following conventions apply to the SYNOPSIS section and can be used |
||||||
|
as a guide in other sections. |
||||||
|
|
||||||
|
bold text type exactly as shown. |
||||||
|
italic text replace with appropriate argument. |
||||||
|
[-abc] any or all arguments within [ ] are optional. |
||||||
|
-a|-b options delimited by | cannot be used together. |
||||||
|
argument ... argument is repeatable. |
||||||
|
[expression] ... entire expression within [ ] is repeatable. |
||||||
|
|
||||||
|
The command or function illustration is a pattern that should match all |
||||||
|
possible invocations. In some cases it is advisable to illustrate sev- |
||||||
|
eral exclusive invocations as is shown in the SYNOPSIS section of this |
||||||
|
manual page. |
||||||
|
|
||||||
|
* new lines in general. |
||||||
|
|
||||||
|
Consecutive blank lines are merged by the viewer but not on printouts. |
||||||
|
So one has to be cautious. This is most disturbing when printing |
||||||
|
postscript. |
||||||
|
|
||||||
|
.. NOTE:: |
||||||
|
|
||||||
|
1. Roff requests only work when at line start. |
||||||
|
2. But consecutive blank lines are merged by the viewer but not on |
||||||
|
printouts. |
||||||
|
|
||||||
|
So try the rule start new lines in ``visit_``-functions, but only if |
||||||
|
necessary. E.g. ``field-names`` are already on a new line because of |
||||||
|
docutils structure. |
||||||
|
|
||||||
|
* Indentation, left margin: |
||||||
|
|
||||||
|
- The writer includes two macros ``.INDENT`` and ``.UNINDENT`` that |
||||||
|
keep track of the indentation in roff-code, for line-blocks python |
||||||
|
keeps track of it. WHAT should be the preferred way ? |
||||||
|
|
||||||
|
But standard macros like ``.PP`` might reset it. |
||||||
|
|
||||||
|
- Why do ``.RE`` and ``.RS`` not work? |
||||||
|
|
||||||
|
.. Note:: |
||||||
|
Current indent is in register ``.i``. |
||||||
|
|
||||||
|
* [LMHT]_ Filenames are always in italics, except in the SYNOPSIS section, |
||||||
|
use:: |
||||||
|
|
||||||
|
.I /usr/include/stdio.h |
||||||
|
|
||||||
|
and:: |
||||||
|
|
||||||
|
.B #include <stdio.h> |
||||||
|
|
||||||
|
* Tables are possible, via the external processor tbl, although one should |
||||||
|
avoid them. |
||||||
|
|
||||||
|
Open issues |
||||||
|
''''''''''' |
||||||
|
|
||||||
|
* How to typeset command/manpage names in text. |
||||||
|
* How to write long syntax lines. |
||||||
|
* Line ends around email or web addresses in texts. |
||||||
|
How to distinguish something is inline or not ? |
||||||
|
|
||||||
|
* Images and equations are discouraged. |
||||||
|
* Lists in admonitions are not intended. |
||||||
|
* Encoding declaration ``'\" t -*- coding: ISO-8859-1 -*-`` |
||||||
|
in first line. |
||||||
|
|
||||||
|
BUT if UTF-8 is declared tables are no longer processed. |
||||||
|
|
||||||
|
* Input and output encoding are problematic at least. |
||||||
|
|
||||||
|
.. _Docutils: http://docutils.sourceforge.net/ |
@ -0,0 +1,552 @@ |
|||||||
|
.. This is a comment. Note how any initial comments are moved by |
||||||
|
transforms to after the document title, subtitle, and docinfo. |
||||||
|
|
||||||
|
================================ |
||||||
|
reStructuredText Demonstration |
||||||
|
================================ |
||||||
|
|
||||||
|
.. Above is the document title, and below is the subtitle. |
||||||
|
They are transformed from section titles after parsing. |
||||||
|
|
||||||
|
-------------------------------- |
||||||
|
Examples of Syntax Constructs |
||||||
|
-------------------------------- |
||||||
|
|
||||||
|
.. bibliographic fields (which also require a transform): |
||||||
|
|
||||||
|
:Author: David Goodger |
||||||
|
:Address: 123 Example Street |
||||||
|
Example, EX Canada |
||||||
|
A1B 2C3 |
||||||
|
:Contact: docutils-develop@lists.sourceforge.net |
||||||
|
:Authors: Me; Myself; I |
||||||
|
:organization: humankind |
||||||
|
:date: $Date: 2012-01-03 20:23:53 +0100 (Di, 03 Jan 2012) $ |
||||||
|
:status: This is a "work in progress" |
||||||
|
:revision: $Revision: 7302 $ |
||||||
|
:version: 1 |
||||||
|
:copyright: This document has been placed in the public domain. You |
||||||
|
may do with it as you wish. You may copy, modify, |
||||||
|
redistribute, reattribute, sell, buy, rent, lease, |
||||||
|
destroy, or improve it, quote it at length, excerpt, |
||||||
|
incorporate, collate, fold, staple, or mutilate it, or do |
||||||
|
anything else to it that your or anyone else's heart |
||||||
|
desires. |
||||||
|
:field name: This is a generic bibliographic field. |
||||||
|
:field name 2: |
||||||
|
Generic bibliographic fields may contain multiple body elements. |
||||||
|
|
||||||
|
Like this. |
||||||
|
|
||||||
|
:Dedication: |
||||||
|
|
||||||
|
For Docutils users & co-developers. |
||||||
|
|
||||||
|
:abstract: |
||||||
|
|
||||||
|
This document is a demonstration of the reStructuredText markup |
||||||
|
language, containing examples of all basic reStructuredText |
||||||
|
constructs and many advanced constructs. |
||||||
|
|
||||||
|
.. meta:: |
||||||
|
:keywords: reStructuredText, demonstration, demo, parser |
||||||
|
:description lang=en: A demonstration of the reStructuredText |
||||||
|
markup language, containing examples of all basic |
||||||
|
constructs and many advanced constructs. |
||||||
|
|
||||||
|
.. contents:: Table of Contents |
||||||
|
.. section-numbering:: |
||||||
|
|
||||||
|
|
||||||
|
Structural Elements |
||||||
|
=================== |
||||||
|
|
||||||
|
Section Title |
||||||
|
------------- |
||||||
|
|
||||||
|
That's it, the text just above this line. |
||||||
|
|
||||||
|
Transitions |
||||||
|
----------- |
||||||
|
|
||||||
|
Here's a transition: |
||||||
|
|
||||||
|
--------- |
||||||
|
|
||||||
|
It divides the section. |
||||||
|
|
||||||
|
Body Elements |
||||||
|
============= |
||||||
|
|
||||||
|
Paragraphs |
||||||
|
---------- |
||||||
|
|
||||||
|
A paragraph. |
||||||
|
|
||||||
|
Inline Markup |
||||||
|
````````````` |
||||||
|
|
||||||
|
Paragraphs contain text and may contain inline markup: *emphasis*, |
||||||
|
**strong emphasis**, ``inline literals``, standalone hyperlinks |
||||||
|
(http://www.python.org), external hyperlinks (Python_), internal |
||||||
|
cross-references (example_), external hyperlinks with embedded URIs |
||||||
|
(`Python web site <http://www.python.org>`__), footnote references |
||||||
|
(manually numbered [1]_, anonymous auto-numbered [#]_, labeled |
||||||
|
auto-numbered [#label]_, or symbolic [*]_), citation references |
||||||
|
([CIT2002]_), substitution references (|example|), and _`inline |
||||||
|
hyperlink targets` (see Targets_ below for a reference back to here). |
||||||
|
Character-level inline markup is also possible (although exceedingly |
||||||
|
ugly!) in *re*\ ``Structured``\ *Text*. Problems are indicated by |
||||||
|
|problematic| text (generated by processing errors; this one is |
||||||
|
intentional). |
||||||
|
|
||||||
|
The default role for interpreted text is `Title Reference`. Here are |
||||||
|
some explicit interpreted text roles: a PEP reference (:PEP:`287`); an |
||||||
|
RFC reference (:RFC:`2822`); a :sub:`subscript`; a :sup:`superscript`; |
||||||
|
and explicit roles for :emphasis:`standard` :strong:`inline` |
||||||
|
:literal:`markup`. |
||||||
|
|
||||||
|
.. DO NOT RE-WRAP THE FOLLOWING PARAGRAPH! |
||||||
|
|
||||||
|
Let's test wrapping and whitespace significance in inline literals: |
||||||
|
``This is an example of --inline-literal --text, --including some-- |
||||||
|
strangely--hyphenated-words. Adjust-the-width-of-your-browser-window |
||||||
|
to see how the text is wrapped. -- ---- -------- Now note the |
||||||
|
spacing between the words of this sentence (words |
||||||
|
should be grouped in pairs).`` |
||||||
|
|
||||||
|
If the ``--pep-references`` option was supplied, there should be a |
||||||
|
live link to PEP 258 here. |
||||||
|
|
||||||
|
Bullet Lists |
||||||
|
------------ |
||||||
|
|
||||||
|
- A bullet list |
||||||
|
|
||||||
|
+ Nested bullet list. |
||||||
|
+ Nested item 2. |
||||||
|
|
||||||
|
- Item 2. |
||||||
|
|
||||||
|
Paragraph 2 of item 2. |
||||||
|
|
||||||
|
* Nested bullet list. |
||||||
|
* Nested item 2. |
||||||
|
|
||||||
|
- Third level. |
||||||
|
- Item 2. |
||||||
|
|
||||||
|
* Nested item 3. |
||||||
|
|
||||||
|
Enumerated Lists |
||||||
|
---------------- |
||||||
|
|
||||||
|
1. Arabic numerals. |
||||||
|
|
||||||
|
a) lower alpha) |
||||||
|
|
||||||
|
(i) (lower roman) |
||||||
|
|
||||||
|
A. upper alpha. |
||||||
|
|
||||||
|
I) upper roman) |
||||||
|
|
||||||
|
2. Lists that don't start at 1: |
||||||
|
|
||||||
|
3. Three |
||||||
|
|
||||||
|
4. Four |
||||||
|
|
||||||
|
C. C |
||||||
|
|
||||||
|
D. D |
||||||
|
|
||||||
|
iii. iii |
||||||
|
|
||||||
|
iv. iv |
||||||
|
|
||||||
|
#. List items may also be auto-enumerated. |
||||||
|
|
||||||
|
Definition Lists |
||||||
|
---------------- |
||||||
|
|
||||||
|
Term |
||||||
|
Definition |
||||||
|
Term : classifier |
||||||
|
Definition paragraph 1. |
||||||
|
|
||||||
|
Definition paragraph 2. |
||||||
|
Term |
||||||
|
Definition |
||||||
|
|
||||||
|
Field Lists |
||||||
|
----------- |
||||||
|
|
||||||
|
:what: Field lists map field names to field bodies, like database |
||||||
|
records. They are often part of an extension syntax. They are |
||||||
|
an unambiguous variant of RFC 2822 fields. |
||||||
|
|
||||||
|
:how arg1 arg2: |
||||||
|
|
||||||
|
The field marker is a colon, the field name, and a colon. |
||||||
|
|
||||||
|
The field body may contain one or more body elements, indented |
||||||
|
relative to the field marker. |
||||||
|
|
||||||
|
Option Lists |
||||||
|
------------ |
||||||
|
|
||||||
|
For listing command-line options: |
||||||
|
|
||||||
|
-a command-line option "a" |
||||||
|
-b file options can have arguments |
||||||
|
and long descriptions |
||||||
|
--long options can be long also |
||||||
|
--input=file long options can also have |
||||||
|
arguments |
||||||
|
|
||||||
|
--very-long-option |
||||||
|
The description can also start on the next line. |
||||||
|
|
||||||
|
The description may contain multiple body elements, |
||||||
|
regardless of where it starts. |
||||||
|
|
||||||
|
-x, -y, -z Multiple options are an "option group". |
||||||
|
-v, --verbose Commonly-seen: short & long options. |
||||||
|
-1 file, --one=file, --two file |
||||||
|
Multiple options with arguments. |
||||||
|
/V DOS/VMS-style options too |
||||||
|
|
||||||
|
There must be at least two spaces between the option and the |
||||||
|
description. |
||||||
|
|
||||||
|
Literal Blocks |
||||||
|
-------------- |
||||||
|
|
||||||
|
Literal blocks are indicated with a double-colon ("::") at the end of |
||||||
|
the preceding paragraph (over there ``-->``). They can be indented:: |
||||||
|
|
||||||
|
if literal_block: |
||||||
|
text = 'is left as-is' |
||||||
|
spaces_and_linebreaks = 'are preserved' |
||||||
|
markup_processing = None |
||||||
|
|
||||||
|
Or they can be quoted without indentation:: |
||||||
|
|
||||||
|
>> Great idea! |
||||||
|
> |
||||||
|
> Why didn't I think of that? |
||||||
|
|
||||||
|
Line Blocks |
||||||
|
----------- |
||||||
|
|
||||||
|
| This is a line block. It ends with a blank line. |
||||||
|
| Each new line begins with a vertical bar ("|"). |
||||||
|
| Line breaks and initial indents are preserved. |
||||||
|
| Continuation lines are wrapped portions of long lines; |
||||||
|
they begin with a space in place of the vertical bar. |
||||||
|
| The left edge of a continuation line need not be aligned with |
||||||
|
the left edge of the text above it. |
||||||
|
|
||||||
|
| This is a second line block. |
||||||
|
| |
||||||
|
| Blank lines are permitted internally, but they must begin with a "|". |
||||||
|
|
||||||
|
Take it away, Eric the Orchestra Leader! |
||||||
|
|
||||||
|
| A one, two, a one two three four |
||||||
|
| |
||||||
|
| Half a bee, philosophically, |
||||||
|
| must, *ipso facto*, half not be. |
||||||
|
| But half the bee has got to be, |
||||||
|
| *vis a vis* its entity. D'you see? |
||||||
|
| |
||||||
|
| But can a bee be said to be |
||||||
|
| or not to be an entire bee, |
||||||
|
| when half the bee is not a bee, |
||||||
|
| due to some ancient injury? |
||||||
|
| |
||||||
|
| Singing... |
||||||
|
|
||||||
|
Block Quotes |
||||||
|
------------ |
||||||
|
|
||||||
|
Block quotes consist of indented body elements: |
||||||
|
|
||||||
|
My theory by A. Elk. Brackets Miss, brackets. This theory goes |
||||||
|
as follows and begins now. All brontosauruses are thin at one |
||||||
|
end, much much thicker in the middle and then thin again at the |
||||||
|
far end. That is my theory, it is mine, and belongs to me and I |
||||||
|
own it, and what it is too. |
||||||
|
|
||||||
|
-- Anne Elk (Miss) |
||||||
|
|
||||||
|
Doctest Blocks |
||||||
|
-------------- |
||||||
|
|
||||||
|
>>> print 'Python-specific usage examples; begun with ">>>"' |
||||||
|
Python-specific usage examples; begun with ">>>" |
||||||
|
>>> print '(cut and pasted from interactive Python sessions)' |
||||||
|
(cut and pasted from interactive Python sessions) |
||||||
|
|
||||||
|
Tables |
||||||
|
------ |
||||||
|
|
||||||
|
Here's a grid table followed by a simple table: |
||||||
|
|
||||||
|
+------------------------+------------+----------+----------+ |
||||||
|
| Header row, column 1 | Header 2 | Header 3 | Header 4 | |
||||||
|
| (header rows optional) | | | | |
||||||
|
+========================+============+==========+==========+ |
||||||
|
| body row 1, column 1 | column 2 | column 3 | column 4 | |
||||||
|
+------------------------+------------+----------+----------+ |
||||||
|
| body row 2 | Cells may span columns. | |
||||||
|
+------------------------+------------+---------------------+ |
||||||
|
| body row 3 | Cells may | - Table cells | |
||||||
|
+------------------------+ span rows. | - contain | |
||||||
|
| body row 4 | | - body elements. | |
||||||
|
+------------------------+------------+----------+----------+ |
||||||
|
| body row 5 | Cells may also be | | |
||||||
|
| | empty: ``-->`` | | |
||||||
|
+------------------------+-----------------------+----------+ |
||||||
|
|
||||||
|
===== ===== ====== |
||||||
|
Inputs Output |
||||||
|
------------ ------ |
||||||
|
A B A or B |
||||||
|
===== ===== ====== |
||||||
|
False False False |
||||||
|
True False True |
||||||
|
False True True |
||||||
|
True True True |
||||||
|
===== ===== ====== |
||||||
|
|
||||||
|
Footnotes |
||||||
|
--------- |
||||||
|
|
||||||
|
.. [1] A footnote contains body elements, consistently indented by at |
||||||
|
least 3 spaces. |
||||||
|
|
||||||
|
This is the footnote's second paragraph. |
||||||
|
|
||||||
|
.. [#label] Footnotes may be numbered, either manually (as in [1]_) or |
||||||
|
automatically using a "#"-prefixed label. This footnote has a |
||||||
|
label so it can be referred to from multiple places, both as a |
||||||
|
footnote reference ([#label]_) and as a hyperlink reference |
||||||
|
(label_). |
||||||
|
|
||||||
|
.. [#] This footnote is numbered automatically and anonymously using a |
||||||
|
label of "#" only. |
||||||
|
|
||||||
|
.. [*] Footnotes may also use symbols, specified with a "*" label. |
||||||
|
Here's a reference to the next footnote: [*]_. |
||||||
|
|
||||||
|
.. [*] This footnote shows the next symbol in the sequence. |
||||||
|
|
||||||
|
.. [4] Here's an unreferenced footnote, with a reference to a |
||||||
|
nonexistent footnote: [5]_. |
||||||
|
|
||||||
|
Citations |
||||||
|
--------- |
||||||
|
|
||||||
|
.. [CIT2002] Citations are text-labeled footnotes. They may be |
||||||
|
rendered separately and differently from footnotes. |
||||||
|
|
||||||
|
Here's a reference to the above, [CIT2002]_, and a [nonexistent]_ |
||||||
|
citation. |
||||||
|
|
||||||
|
Targets |
||||||
|
------- |
||||||
|
|
||||||
|
.. _example: |
||||||
|
|
||||||
|
This paragraph is pointed to by the explicit "example" target. A |
||||||
|
reference can be found under `Inline Markup`_, above. `Inline |
||||||
|
hyperlink targets`_ are also possible. |
||||||
|
|
||||||
|
Section headers are implicit targets, referred to by name. See |
||||||
|
Targets_, which is a subsection of `Body Elements`_. |
||||||
|
|
||||||
|
Explicit external targets are interpolated into references such as |
||||||
|
"Python_". |
||||||
|
|
||||||
|
.. _Python: http://www.python.org/ |
||||||
|
|
||||||
|
Targets may be indirect and anonymous. Thus `this phrase`__ may also |
||||||
|
refer to the Targets_ section. |
||||||
|
|
||||||
|
__ Targets_ |
||||||
|
|
||||||
|
Here's a `hyperlink reference without a target`_, which generates an |
||||||
|
error. |
||||||
|
|
||||||
|
Duplicate Target Names |
||||||
|
`````````````````````` |
||||||
|
|
||||||
|
Duplicate names in section headers or other implicit targets will |
||||||
|
generate "info" (level-1) system messages. Duplicate names in |
||||||
|
explicit targets will generate "warning" (level-2) system messages. |
||||||
|
|
||||||
|
Duplicate Target Names |
||||||
|
`````````````````````` |
||||||
|
|
||||||
|
Since there are two "Duplicate Target Names" section headers, we |
||||||
|
cannot uniquely refer to either of them by name. If we try to (like |
||||||
|
this: `Duplicate Target Names`_), an error is generated. |
||||||
|
|
||||||
|
Directives |
||||||
|
---------- |
||||||
|
|
||||||
|
.. contents:: :local: |
||||||
|
|
||||||
|
These are just a sample of the many reStructuredText Directives. For |
||||||
|
others, please see |
||||||
|
http://docutils.sourceforge.net/docs/ref/rst/directives.html. |
||||||
|
|
||||||
|
Document Parts |
||||||
|
`````````````` |
||||||
|
|
||||||
|
An example of the "contents" directive can be seen above this section |
||||||
|
(a local, untitled table of contents_) and at the beginning of the |
||||||
|
document (a document-wide `table of contents`_). |
||||||
|
|
||||||
|
Images |
||||||
|
`````` |
||||||
|
|
||||||
|
An image directive (also clickable -- a hyperlink reference): |
||||||
|
|
||||||
|
.. image:: images/title.png |
||||||
|
:target: directives_ |
||||||
|
|
||||||
|
A figure directive: |
||||||
|
|
||||||
|
.. figure:: images/title.png |
||||||
|
:alt: reStructuredText, the markup syntax |
||||||
|
|
||||||
|
A figure is an image with a caption and/or a legend: |
||||||
|
|
||||||
|
+------------+-----------------------------------------------+ |
||||||
|
| re | Revised, revisited, based on 're' module. | |
||||||
|
+------------+-----------------------------------------------+ |
||||||
|
| Structured | Structure-enhanced text, structuredtext. | |
||||||
|
+------------+-----------------------------------------------+ |
||||||
|
| Text | Well it is, isn't it? | |
||||||
|
+------------+-----------------------------------------------+ |
||||||
|
|
||||||
|
This paragraph is also part of the legend. |
||||||
|
|
||||||
|
Admonitions |
||||||
|
``````````` |
||||||
|
|
||||||
|
.. Attention:: Directives at large. |
||||||
|
|
||||||
|
.. Caution:: |
||||||
|
|
||||||
|
Don't take any wooden nickels. |
||||||
|
|
||||||
|
.. DANGER:: Mad scientist at work! |
||||||
|
|
||||||
|
.. Error:: Does not compute. |
||||||
|
|
||||||
|
.. Hint:: It's bigger than a bread box. |
||||||
|
|
||||||
|
.. Important:: |
||||||
|
- Wash behind your ears. |
||||||
|
- Clean up your room. |
||||||
|
- Call your mother. |
||||||
|
- Back up your data. |
||||||
|
|
||||||
|
.. Note:: This is a note. |
||||||
|
|
||||||
|
.. Tip:: 15% if the service is good. |
||||||
|
|
||||||
|
.. WARNING:: Strong prose may provoke extreme mental exertion. |
||||||
|
Reader discretion is strongly advised. |
||||||
|
|
||||||
|
.. admonition:: And, by the way... |
||||||
|
|
||||||
|
You can make up your own admonition too. |
||||||
|
|
||||||
|
Topics, Sidebars, and Rubrics |
||||||
|
````````````````````````````` |
||||||
|
|
||||||
|
.. sidebar:: Sidebar Title |
||||||
|
:subtitle: Optional Subtitle |
||||||
|
|
||||||
|
This is a sidebar. It is for text outside the flow of the main |
||||||
|
text. |
||||||
|
|
||||||
|
.. rubric:: This is a rubric inside a sidebar |
||||||
|
|
||||||
|
Sidebars often appears beside the main text with a border and |
||||||
|
background color. |
||||||
|
|
||||||
|
.. topic:: Topic Title |
||||||
|
|
||||||
|
This is a topic. |
||||||
|
|
||||||
|
.. rubric:: This is a rubric |
||||||
|
|
||||||
|
Target Footnotes |
||||||
|
```````````````` |
||||||
|
|
||||||
|
.. target-notes:: |
||||||
|
|
||||||
|
Replacement Text |
||||||
|
```````````````` |
||||||
|
|
||||||
|
I recommend you try |Python|_. |
||||||
|
|
||||||
|
.. |Python| replace:: Python, *the* best language around |
||||||
|
|
||||||
|
Compound Paragraph |
||||||
|
`````````````````` |
||||||
|
|
||||||
|
.. compound:: |
||||||
|
|
||||||
|
This paragraph contains a literal block:: |
||||||
|
|
||||||
|
Connecting... OK |
||||||
|
Transmitting data... OK |
||||||
|
Disconnecting... OK |
||||||
|
|
||||||
|
and thus consists of a simple paragraph, a literal block, and |
||||||
|
another simple paragraph. Nonetheless it is semantically *one* |
||||||
|
paragraph. |
||||||
|
|
||||||
|
This construct is called a *compound paragraph* and can be produced |
||||||
|
with the "compound" directive. |
||||||
|
|
||||||
|
Substitution Definitions |
||||||
|
------------------------ |
||||||
|
|
||||||
|
An inline image (|example|) example: |
||||||
|
|
||||||
|
.. |EXAMPLE| image:: images/biohazard.png |
||||||
|
|
||||||
|
(Substitution definitions are not visible in the HTML source.) |
||||||
|
|
||||||
|
Comments |
||||||
|
-------- |
||||||
|
|
||||||
|
Here's one: |
||||||
|
|
||||||
|
.. Comments begin with two dots and a space. Anything may |
||||||
|
follow, except for the syntax of footnotes, hyperlink |
||||||
|
targets, directives, or substitution definitions. |
||||||
|
|
||||||
|
Double-dashes -- "--" -- must be escaped somehow in HTML output. |
||||||
|
|
||||||
|
(View the HTML source to see the comment.) |
||||||
|
|
||||||
|
Error Handling |
||||||
|
============== |
||||||
|
|
||||||
|
Any errors caught during processing will generate system messages. |
||||||
|
|
||||||
|
|*** Expect 6 errors (including this one). ***| |
||||||
|
|
||||||
|
There should be six messages in the following, auto-generated |
||||||
|
section, "Docutils System Messages": |
||||||
|
|
||||||
|
.. section should be added by Docutils automatically |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 179 B |
After Width: | Height: | Size: 7.4 KiB |
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,404 @@ |
|||||||
|
A ReStructuredText Primer |
||||||
|
========================= |
||||||
|
|
||||||
|
:Author: Richard Jones |
||||||
|
:Version: $Revision: 5801 $ |
||||||
|
:Copyright: This document has been placed in the public domain. |
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
|
||||||
|
The text below contains links that look like "(quickref__)". These |
||||||
|
are relative links that point to the `Quick reStructuredText`_ user |
||||||
|
reference. If these links don't work, please refer to the `master |
||||||
|
quick reference`_ document. |
||||||
|
|
||||||
|
__ |
||||||
|
.. _Quick reStructuredText: quickref.html |
||||||
|
.. _master quick reference: |
||||||
|
http://docutils.sourceforge.net/docs/user/rst/quickref.html |
||||||
|
|
||||||
|
.. Note:: This document is an informal introduction to |
||||||
|
reStructuredText. The `What Next?`_ section below has links to |
||||||
|
further resources, including a formal reference. |
||||||
|
|
||||||
|
|
||||||
|
Structure |
||||||
|
--------- |
||||||
|
|
||||||
|
From the outset, let me say that "Structured Text" is probably a bit |
||||||
|
of a misnomer. It's more like "Relaxed Text" that uses certain |
||||||
|
consistent patterns. These patterns are interpreted by a HTML |
||||||
|
converter to produce "Very Structured Text" that can be used by a web |
||||||
|
browser. |
||||||
|
|
||||||
|
The most basic pattern recognised is a **paragraph** (quickref__). |
||||||
|
That's a chunk of text that is separated by blank lines (one is |
||||||
|
enough). Paragraphs must have the same indentation -- that is, line |
||||||
|
up at their left edge. Paragraphs that start indented will result in |
||||||
|
indented quote paragraphs. For example:: |
||||||
|
|
||||||
|
This is a paragraph. It's quite |
||||||
|
short. |
||||||
|
|
||||||
|
This paragraph will result in an indented block of |
||||||
|
text, typically used for quoting other text. |
||||||
|
|
||||||
|
This is another one. |
||||||
|
|
||||||
|
Results in: |
||||||
|
|
||||||
|
This is a paragraph. It's quite |
||||||
|
short. |
||||||
|
|
||||||
|
This paragraph will result in an indented block of |
||||||
|
text, typically used for quoting other text. |
||||||
|
|
||||||
|
This is another one. |
||||||
|
|
||||||
|
__ quickref.html#paragraphs |
||||||
|
|
||||||
|
|
||||||
|
Text styles |
||||||
|
----------- |
||||||
|
|
||||||
|
(quickref__) |
||||||
|
|
||||||
|
__ quickref.html#inline-markup |
||||||
|
|
||||||
|
Inside paragraphs and other bodies of text, you may additionally mark |
||||||
|
text for *italics* with "``*italics*``" or **bold** with |
||||||
|
"``**bold**``". This is called "inline markup". |
||||||
|
|
||||||
|
If you want something to appear as a fixed-space literal, use |
||||||
|
"````double back-quotes````". Note that no further fiddling is done |
||||||
|
inside the double back-quotes -- so asterisks "``*``" etc. are left |
||||||
|
alone. |
||||||
|
|
||||||
|
If you find that you want to use one of the "special" characters in |
||||||
|
text, it will generally be OK -- reStructuredText is pretty smart. |
||||||
|
For example, this lone asterisk * is handled just fine, as is the |
||||||
|
asterisk in this equation: 5*6=30. If you actually |
||||||
|
want text \*surrounded by asterisks* to **not** be italicised, then |
||||||
|
you need to indicate that the asterisk is not special. You do this by |
||||||
|
placing a backslash just before it, like so "``\*``" (quickref__), or |
||||||
|
by enclosing it in double back-quotes (inline literals), like this:: |
||||||
|
|
||||||
|
``*`` |
||||||
|
|
||||||
|
__ quickref.html#escaping |
||||||
|
|
||||||
|
.. Tip:: Think of inline markup as a form of (parentheses) and use it |
||||||
|
the same way: immediately before and after the text being marked |
||||||
|
up. Inline markup by itself (surrounded by whitespace) or in the |
||||||
|
middle of a word won't be recognized. See the `markup spec`__ for |
||||||
|
full details. |
||||||
|
|
||||||
|
__ ../../ref/rst/restructuredtext.html#inline-markup |
||||||
|
|
||||||
|
|
||||||
|
Lists |
||||||
|
----- |
||||||
|
|
||||||
|
Lists of items come in three main flavours: **enumerated**, |
||||||
|
**bulleted** and **definitions**. In all list cases, you may have as |
||||||
|
many paragraphs, sublists, etc. as you want, as long as the left-hand |
||||||
|
side of the paragraph or whatever aligns with the first line of text |
||||||
|
in the list item. |
||||||
|
|
||||||
|
Lists must always start a new paragraph -- that is, they must appear |
||||||
|
after a blank line. |
||||||
|
|
||||||
|
**enumerated** lists (numbers, letters or roman numerals; quickref__) |
||||||
|
__ quickref.html#enumerated-lists |
||||||
|
|
||||||
|
Start a line off with a number or letter followed by a period ".", |
||||||
|
right bracket ")" or surrounded by brackets "( )" -- whatever you're |
||||||
|
comfortable with. All of the following forms are recognised:: |
||||||
|
|
||||||
|
1. numbers |
||||||
|
|
||||||
|
A. upper-case letters |
||||||
|
and it goes over many lines |
||||||
|
|
||||||
|
with two paragraphs and all! |
||||||
|
|
||||||
|
a. lower-case letters |
||||||
|
|
||||||
|
3. with a sub-list starting at a different number |
||||||
|
4. make sure the numbers are in the correct sequence though! |
||||||
|
|
||||||
|
I. upper-case roman numerals |
||||||
|
|
||||||
|
i. lower-case roman numerals |
||||||
|
|
||||||
|
(1) numbers again |
||||||
|
|
||||||
|
1) and again |
||||||
|
|
||||||
|
Results in (note: the different enumerated list styles are not |
||||||
|
always supported by every web browser, so you may not get the full |
||||||
|
effect here): |
||||||
|
|
||||||
|
1. numbers |
||||||
|
|
||||||
|
A. upper-case letters |
||||||
|
and it goes over many lines |
||||||
|
|
||||||
|
with two paragraphs and all! |
||||||
|
|
||||||
|
a. lower-case letters |
||||||
|
|
||||||
|
3. with a sub-list starting at a different number |
||||||
|
4. make sure the numbers are in the correct sequence though! |
||||||
|
|
||||||
|
I. upper-case roman numerals |
||||||
|
|
||||||
|
i. lower-case roman numerals |
||||||
|
|
||||||
|
(1) numbers again |
||||||
|
|
||||||
|
1) and again |
||||||
|
|
||||||
|
**bulleted** lists (quickref__) |
||||||
|
__ quickref.html#bullet-lists |
||||||
|
|
||||||
|
Just like enumerated lists, start the line off with a bullet point |
||||||
|
character - either "-", "+" or "*":: |
||||||
|
|
||||||
|
* a bullet point using "*" |
||||||
|
|
||||||
|
- a sub-list using "-" |
||||||
|
|
||||||
|
+ yet another sub-list |
||||||
|
|
||||||
|
- another item |
||||||
|
|
||||||
|
Results in: |
||||||
|
|
||||||
|
* a bullet point using "*" |
||||||
|
|
||||||
|
- a sub-list using "-" |
||||||
|
|
||||||
|
+ yet another sub-list |
||||||
|
|
||||||
|
- another item |
||||||
|
|
||||||
|
**definition** lists (quickref__) |
||||||
|
__ quickref.html#definition-lists |
||||||
|
|
||||||
|
Unlike the other two, the definition lists consist of a term, and |
||||||
|
the definition of that term. The format of a definition list is:: |
||||||
|
|
||||||
|
what |
||||||
|
Definition lists associate a term with a definition. |
||||||
|
|
||||||
|
*how* |
||||||
|
The term is a one-line phrase, and the definition is one or more |
||||||
|
paragraphs or body elements, indented relative to the term. |
||||||
|
Blank lines are not allowed between term and definition. |
||||||
|
|
||||||
|
Results in: |
||||||
|
|
||||||
|
what |
||||||
|
Definition lists associate a term with a definition. |
||||||
|
|
||||||
|
*how* |
||||||
|
The term is a one-line phrase, and the definition is one or more |
||||||
|
paragraphs or body elements, indented relative to the term. |
||||||
|
Blank lines are not allowed between term and definition. |
||||||
|
|
||||||
|
|
||||||
|
Preformatting (code samples) |
||||||
|
---------------------------- |
||||||
|
(quickref__) |
||||||
|
|
||||||
|
__ quickref.html#literal-blocks |
||||||
|
|
||||||
|
To just include a chunk of preformatted, never-to-be-fiddled-with |
||||||
|
text, finish the prior paragraph with "``::``". The preformatted |
||||||
|
block is finished when the text falls back to the same indentation |
||||||
|
level as a paragraph prior to the preformatted block. For example:: |
||||||
|
|
||||||
|
An example:: |
||||||
|
|
||||||
|
Whitespace, newlines, blank lines, and all kinds of markup |
||||||
|
(like *this* or \this) is preserved by literal blocks. |
||||||
|
Lookie here, I've dropped an indentation level |
||||||
|
(but not far enough) |
||||||
|
|
||||||
|
no more example |
||||||
|
|
||||||
|
Results in: |
||||||
|
|
||||||
|
An example:: |
||||||
|
|
||||||
|
Whitespace, newlines, blank lines, and all kinds of markup |
||||||
|
(like *this* or \this) is preserved by literal blocks. |
||||||
|
Lookie here, I've dropped an indentation level |
||||||
|
(but not far enough) |
||||||
|
|
||||||
|
no more example |
||||||
|
|
||||||
|
Note that if a paragraph consists only of "``::``", then it's removed |
||||||
|
from the output:: |
||||||
|
|
||||||
|
:: |
||||||
|
|
||||||
|
This is preformatted text, and the |
||||||
|
last "::" paragraph is removed |
||||||
|
|
||||||
|
Results in: |
||||||
|
|
||||||
|
:: |
||||||
|
|
||||||
|
This is preformatted text, and the |
||||||
|
last "::" paragraph is removed |
||||||
|
|
||||||
|
|
||||||
|
Sections |
||||||
|
-------- |
||||||
|
|
||||||
|
(quickref__) |
||||||
|
|
||||||
|
__ quickref.html#section-structure |
||||||
|
|
||||||
|
To break longer text up into sections, you use **section headers**. |
||||||
|
These are a single line of text (one or more words) with adornment: an |
||||||
|
underline alone, or an underline and an overline together, in dashes |
||||||
|
"``-----``", equals "``======``", tildes "``~~~~~~``" or any of the |
||||||
|
non-alphanumeric characters ``= - ` : ' " ~ ^ _ * + # < >`` that you |
||||||
|
feel comfortable with. An underline-only adornment is distinct from |
||||||
|
an overline-and-underline adornment using the same character. The |
||||||
|
underline/overline must be at least as long as the title text. Be |
||||||
|
consistent, since all sections marked with the same adornment style |
||||||
|
are deemed to be at the same level:: |
||||||
|
|
||||||
|
Chapter 1 Title |
||||||
|
=============== |
||||||
|
|
||||||
|
Section 1.1 Title |
||||||
|
----------------- |
||||||
|
|
||||||
|
Subsection 1.1.1 Title |
||||||
|
~~~~~~~~~~~~~~~~~~~~~~ |
||||||
|
|
||||||
|
Section 1.2 Title |
||||||
|
----------------- |
||||||
|
|
||||||
|
Chapter 2 Title |
||||||
|
=============== |
||||||
|
|
||||||
|
This results in the following structure, illustrated by simplified |
||||||
|
pseudo-XML:: |
||||||
|
|
||||||
|
<section> |
||||||
|
<title> |
||||||
|
Chapter 1 Title |
||||||
|
<section> |
||||||
|
<title> |
||||||
|
Section 1.1 Title |
||||||
|
<section> |
||||||
|
<title> |
||||||
|
Subsection 1.1.1 Title |
||||||
|
<section> |
||||||
|
<title> |
||||||
|
Section 1.2 Title |
||||||
|
<section> |
||||||
|
<title> |
||||||
|
Chapter 2 Title |
||||||
|
|
||||||
|
(Pseudo-XML uses indentation for nesting and has no end-tags. It's |
||||||
|
not possible to show actual processed output, as in the other |
||||||
|
examples, because sections cannot exist inside block quotes. For a |
||||||
|
concrete example, compare the section structure of this document's |
||||||
|
source text and processed output.) |
||||||
|
|
||||||
|
Note that section headers are available as link targets, just using |
||||||
|
their name. To link to the Lists_ heading, I write "``Lists_``". If |
||||||
|
the heading has a space in it like `text styles`_, we need to quote |
||||||
|
the heading "```text styles`_``". |
||||||
|
|
||||||
|
|
||||||
|
Document Title / Subtitle |
||||||
|
````````````````````````` |
||||||
|
|
||||||
|
The title of the whole document is distinct from section titles and |
||||||
|
may be formatted somewhat differently (e.g. the HTML writer by default |
||||||
|
shows it as a centered heading). |
||||||
|
|
||||||
|
To indicate the document title in reStructuredText, use a unique adornment |
||||||
|
style at the beginning of the document. To indicate the document subtitle, |
||||||
|
use another unique adornment style immediately after the document title. For |
||||||
|
example:: |
||||||
|
|
||||||
|
================ |
||||||
|
Document Title |
||||||
|
================ |
||||||
|
---------- |
||||||
|
Subtitle |
||||||
|
---------- |
||||||
|
|
||||||
|
Section Title |
||||||
|
============= |
||||||
|
|
||||||
|
... |
||||||
|
|
||||||
|
Note that "Document Title" and "Section Title" above both use equals |
||||||
|
signs, but are distict and unrelated styles. The text of |
||||||
|
overline-and-underlined titles (but not underlined-only) may be inset |
||||||
|
for aesthetics. |
||||||
|
|
||||||
|
|
||||||
|
Images |
||||||
|
------ |
||||||
|
|
||||||
|
(quickref__) |
||||||
|
|
||||||
|
__ quickref.html#directives |
||||||
|
|
||||||
|
To include an image in your document, you use the the ``image`` directive__. |
||||||
|
For example:: |
||||||
|
|
||||||
|
.. image:: images/biohazard.png |
||||||
|
|
||||||
|
results in: |
||||||
|
|
||||||
|
.. image:: images/biohazard.png |
||||||
|
|
||||||
|
The ``images/biohazard.png`` part indicates the filename of the image |
||||||
|
you wish to appear in the document. There's no restriction placed on |
||||||
|
the image (format, size etc). If the image is to appear in HTML and |
||||||
|
you wish to supply additional information, you may:: |
||||||
|
|
||||||
|
.. image:: images/biohazard.png |
||||||
|
:height: 100 |
||||||
|
:width: 200 |
||||||
|
:scale: 50 |
||||||
|
:alt: alternate text |
||||||
|
|
||||||
|
See the full `image directive documentation`__ for more info. |
||||||
|
|
||||||
|
__ ../../ref/rst/directives.html |
||||||
|
__ ../../ref/rst/directives.html#images |
||||||
|
|
||||||
|
|
||||||
|
What Next? |
||||||
|
---------- |
||||||
|
|
||||||
|
This primer introduces the most common features of reStructuredText, |
||||||
|
but there are a lot more to explore. The `Quick reStructuredText`_ |
||||||
|
user reference is a good place to go next. For complete details, the |
||||||
|
`reStructuredText Markup Specification`_ is the place to go [#]_. |
||||||
|
|
||||||
|
Users who have questions or need assistance with Docutils or |
||||||
|
reStructuredText should post a message to the Docutils-users_ mailing |
||||||
|
list. |
||||||
|
|
||||||
|
.. [#] If that relative link doesn't work, try the master document: |
||||||
|
http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html. |
||||||
|
|
||||||
|
.. _reStructuredText Markup Specification: |
||||||
|
../../ref/rst/restructuredtext.html |
||||||
|
.. _Docutils-users: ../mailing-lists.html#docutils-users |
||||||
|
.. _Docutils project web site: http://docutils.sourceforge.net/ |
@ -0,0 +1,16 @@ |
|||||||
|
# These entries affect all processing: |
||||||
|
[general] |
||||||
|
source-link: yes |
||||||
|
datestamp: %Y-%m-%d %H:%M UTC |
||||||
|
generator: on |
||||||
|
|
||||||
|
# These entries affect HTML output: |
||||||
|
[html4css1 writer] |
||||||
|
stylesheet-path: docutils/writers/html4css1/html4css1.css |
||||||
|
embed-stylesheet: no |
||||||
|
field-name-limit: 20 |
||||||
|
|
||||||
|
# Prevent tools/buildhtml.py from processing certain text files. |
||||||
|
[buildhtml application] |
||||||
|
ignore: GPL2.txt |
||||||
|
prune: .svn:.hg:docs/.svn:docutils:test:tools:licenses:build:dist |
@ -0,0 +1,48 @@ |
|||||||
|
# $Id: _compat.py 7486 2012-07-11 12:25:14Z milde $ |
||||||
|
# Author: Georg Brandl <georg@python.org> |
||||||
|
# Copyright: This module has been placed in the public domain. |
||||||
|
|
||||||
|
""" |
||||||
|
Python 2/3 compatibility definitions. |
||||||
|
|
||||||
|
This module currently provides the following helper symbols: |
||||||
|
|
||||||
|
* bytes (name of byte string type; str in 2.x, bytes in 3.x) |
||||||
|
* b (function converting a string literal to an ASCII byte string; |
||||||
|
can be also used to convert a Unicode string into a byte string) |
||||||
|
* u_prefix (unicode repr prefix: 'u' in 2.x, '' in 3.x) |
||||||
|
(Required in docutils/test/test_publisher.py) |
||||||
|
* BytesIO (a StringIO class that works with bytestrings) |
||||||
|
""" |
||||||
|
|
||||||
|
import sys |
||||||
|
|
||||||
|
if sys.version_info < (3,0): |
||||||
|
b = bytes = str |
||||||
|
u_prefix = 'u' |
||||||
|
from StringIO import StringIO as BytesIO |
||||||
|
else: |
||||||
|
import builtins |
||||||
|
bytes = builtins.bytes |
||||||
|
u_prefix = '' |
||||||
|
def b(s): |
||||||
|
if isinstance(s, str): |
||||||
|
return s.encode('latin1') |
||||||
|
elif isinstance(s, bytes): |
||||||
|
return s |
||||||
|
else: |
||||||
|
raise TypeError("Invalid argument %r for b()" % (s,)) |
||||||
|
# using this hack since 2to3 "fixes" the relative import |
||||||
|
# when using ``from io import BytesIO`` |
||||||
|
BytesIO = __import__('io').BytesIO |
||||||
|
|
||||||
|
if sys.version_info < (2,5): |
||||||
|
import __builtin__ |
||||||
|
|
||||||
|
def __import__(name, globals={}, locals={}, fromlist=[], level=-1): |
||||||
|
"""Compatibility definition for Python 2.4. |
||||||
|
|
||||||
|
Silently ignore the `level` argument missing in Python < 2.5. |
||||||
|
""" |
||||||
|
# we need the level arg because the default changed in Python 3.3 |
||||||
|
return __builtin__.__import__(name, globals, locals, fromlist) |
@ -0,0 +1,665 @@ |
|||||||
|
# $Id: core.py 8126 2017-06-23 09:34:28Z milde $ |
||||||
|
# Author: David Goodger <goodger@python.org> |
||||||
|
# Copyright: This module has been placed in the public domain. |
||||||
|
|
||||||
|
""" |
||||||
|
Calling the ``publish_*`` convenience functions (or instantiating a |
||||||
|
`Publisher` object) with component names will result in default |
||||||
|
behavior. For custom behavior (setting component options), create |
||||||
|
custom component objects first, and pass *them* to |
||||||
|
``publish_*``/`Publisher`. See `The Docutils Publisher`_. |
||||||
|
|
||||||
|
.. _The Docutils Publisher: http://docutils.sf.net/docs/api/publisher.html |
||||||
|
""" |
||||||
|
|
||||||
|
__docformat__ = 'reStructuredText' |
||||||
|
|
||||||
|
import sys |
||||||
|
import pprint |
||||||
|
from docutils import __version__, __version_details__, SettingsSpec |
||||||
|
from docutils import frontend, io, utils, readers, writers |
||||||
|
from docutils.frontend import OptionParser |
||||||
|
from docutils.transforms import Transformer |
||||||
|
from docutils.utils.error_reporting import ErrorOutput, ErrorString |
||||||
|
import docutils.readers.doctree |
||||||
|
|
||||||
|
class Publisher: |
||||||
|
|
||||||
|
""" |
||||||
|
A facade encapsulating the high-level logic of a Docutils system. |
||||||
|
""" |
||||||
|
|
||||||
|
def __init__(self, reader=None, parser=None, writer=None, |
||||||
|
source=None, source_class=io.FileInput, |
||||||
|
destination=None, destination_class=io.FileOutput, |
||||||
|
settings=None): |
||||||
|
""" |
||||||
|
Initial setup. If any of `reader`, `parser`, or `writer` are not |
||||||
|
specified, the corresponding ``set_...`` method should be called with |
||||||
|
a component name (`set_reader` sets the parser as well). |
||||||
|
""" |
||||||
|
|
||||||
|
self.document = None |
||||||
|
"""The document tree (`docutils.nodes` objects).""" |
||||||
|
|
||||||
|
self.reader = reader |
||||||
|
"""A `docutils.readers.Reader` instance.""" |
||||||
|
|
||||||
|
self.parser = parser |
||||||
|
"""A `docutils.parsers.Parser` instance.""" |
||||||
|
|
||||||
|
self.writer = writer |
||||||
|
"""A `docutils.writers.Writer` instance.""" |
||||||
|
|
||||||
|
for component in 'reader', 'parser', 'writer': |
||||||
|
assert not isinstance(getattr(self, component), str), ( |
||||||
|
'passed string "%s" as "%s" parameter; pass an instance, ' |
||||||
|
'or use the "%s_name" parameter instead (in ' |
||||||
|
'docutils.core.publish_* convenience functions).' |
||||||
|
% (getattr(self, component), component, component)) |
||||||
|
|
||||||
|
self.source = source |
||||||
|
"""The source of input data, a `docutils.io.Input` instance.""" |
||||||
|
|
||||||
|
self.source_class = source_class |
||||||
|
"""The class for dynamically created source objects.""" |
||||||
|
|
||||||
|
self.destination = destination |
||||||
|
"""The destination for docutils output, a `docutils.io.Output` |
||||||
|
instance.""" |
||||||
|
|
||||||
|
self.destination_class = destination_class |
||||||
|
"""The class for dynamically created destination objects.""" |
||||||
|
|
||||||
|
self.settings = settings |
||||||
|
"""An object containing Docutils settings as instance attributes. |
||||||
|
Set by `self.process_command_line()` or `self.get_settings()`.""" |
||||||
|
|
||||||
|
self._stderr = ErrorOutput() |
||||||
|
|
||||||
|
def set_reader(self, reader_name, parser, parser_name): |
||||||
|
"""Set `self.reader` by name.""" |
||||||
|
reader_class = readers.get_reader_class(reader_name) |
||||||
|
self.reader = reader_class(parser, parser_name) |
||||||
|
self.parser = self.reader.parser |
||||||
|
|
||||||
|
def set_writer(self, writer_name): |
||||||
|
"""Set `self.writer` by name.""" |
||||||
|
writer_class = writers.get_writer_class(writer_name) |
||||||
|
self.writer = writer_class() |
||||||
|
|
||||||
|
def set_components(self, reader_name, parser_name, writer_name): |
||||||
|
if self.reader is None: |
||||||
|
self.set_reader(reader_name, self.parser, parser_name) |
||||||
|
if self.parser is None: |
||||||
|
if self.reader.parser is None: |
||||||
|
self.reader.set_parser(parser_name) |
||||||
|
self.parser = self.reader.parser |
||||||
|
if self.writer is None: |
||||||
|
self.set_writer(writer_name) |
||||||
|
|
||||||
|
def setup_option_parser(self, usage=None, description=None, |
||||||
|
settings_spec=None, config_section=None, |
||||||
|
**defaults): |
||||||
|
if config_section: |
||||||
|
if not settings_spec: |
||||||
|
settings_spec = SettingsSpec() |
||||||
|
settings_spec.config_section = config_section |
||||||
|
parts = config_section.split() |
||||||
|
if len(parts) > 1 and parts[-1] == 'application': |
||||||
|
settings_spec.config_section_dependencies = ['applications'] |
||||||
|
#@@@ Add self.source & self.destination to components in future? |
||||||
|
option_parser = OptionParser( |
||||||
|
components=(self.parser, self.reader, self.writer, settings_spec), |
||||||
|
defaults=defaults, read_config_files=True, |
||||||
|
usage=usage, description=description) |
||||||
|
return option_parser |
||||||
|
|
||||||
|
def get_settings(self, usage=None, description=None, |
||||||
|
settings_spec=None, config_section=None, **defaults): |
||||||
|
""" |
||||||
|
Set and return default settings (overrides in `defaults` dict). |
||||||
|
|
||||||
|
Set components first (`self.set_reader` & `self.set_writer`). |
||||||
|
Explicitly setting `self.settings` disables command line option |
||||||
|
processing from `self.publish()`. |
||||||
|
""" |
||||||
|
option_parser = self.setup_option_parser( |
||||||
|
usage, description, settings_spec, config_section, **defaults) |
||||||
|
self.settings = option_parser.get_default_values() |
||||||
|
return self.settings |
||||||
|
|
||||||
|
def process_programmatic_settings(self, settings_spec, |
||||||
|
settings_overrides, |
||||||
|
config_section): |
||||||
|
if self.settings is None: |
||||||
|
defaults = (settings_overrides or {}).copy() |
||||||
|
# Propagate exceptions by default when used programmatically: |
||||||
|
defaults.setdefault('traceback', True) |
||||||
|
self.get_settings(settings_spec=settings_spec, |
||||||
|
config_section=config_section, |
||||||
|
**defaults) |
||||||
|
|
||||||
|
def process_command_line(self, argv=None, usage=None, description=None, |
||||||
|
settings_spec=None, config_section=None, |
||||||
|
**defaults): |
||||||
|
""" |
||||||
|
Pass an empty list to `argv` to avoid reading `sys.argv` (the |
||||||
|
default). |
||||||
|
|
||||||
|
Set components first (`self.set_reader` & `self.set_writer`). |
||||||
|
""" |
||||||
|
option_parser = self.setup_option_parser( |
||||||
|
usage, description, settings_spec, config_section, **defaults) |
||||||
|
if argv is None: |
||||||
|
argv = sys.argv[1:] |
||||||
|
# converting to Unicode (Python 3 does this automatically): |
||||||
|
if sys.version_info < (3,0): |
||||||
|
# TODO: make this failsafe and reversible? |
||||||
|
argv_encoding = (frontend.locale_encoding or 'ascii') |
||||||
|
argv = [a.decode(argv_encoding) for a in argv] |
||||||
|
self.settings = option_parser.parse_args(argv) |
||||||
|
|
||||||
|
def set_io(self, source_path=None, destination_path=None): |
||||||
|
if self.source is None: |
||||||
|
self.set_source(source_path=source_path) |
||||||
|
if self.destination is None: |
||||||
|
self.set_destination(destination_path=destination_path) |
||||||
|
|
||||||
|
def set_source(self, source=None, source_path=None): |
||||||
|
if source_path is None: |
||||||
|
source_path = self.settings._source |
||||||
|
else: |
||||||
|
self.settings._source = source_path |
||||||
|
# Raise IOError instead of system exit with `tracback == True` |
||||||
|
# TODO: change io.FileInput's default behaviour and remove this hack |
||||||
|
try: |
||||||
|
self.source = self.source_class( |
||||||
|
source=source, source_path=source_path, |
||||||
|
encoding=self.settings.input_encoding) |
||||||
|
except TypeError: |
||||||
|
self.source = self.source_class( |
||||||
|
source=source, source_path=source_path, |
||||||
|
encoding=self.settings.input_encoding) |
||||||
|
|
||||||
|
def set_destination(self, destination=None, destination_path=None): |
||||||
|
if destination_path is None: |
||||||
|
destination_path = self.settings._destination |
||||||
|
else: |
||||||
|
self.settings._destination = destination_path |
||||||
|
self.destination = self.destination_class( |
||||||
|
destination=destination, destination_path=destination_path, |
||||||
|
encoding=self.settings.output_encoding, |
||||||
|
error_handler=self.settings.output_encoding_error_handler) |
||||||
|
|
||||||
|
def apply_transforms(self): |
||||||
|
self.document.transformer.populate_from_components( |
||||||
|
(self.source, self.reader, self.reader.parser, self.writer, |
||||||
|
self.destination)) |
||||||
|
self.document.transformer.apply_transforms() |
||||||
|
|
||||||
|
def publish(self, argv=None, usage=None, description=None, |
||||||
|
settings_spec=None, settings_overrides=None, |
||||||
|
config_section=None, enable_exit_status=False): |
||||||
|
""" |
||||||
|
Process command line options and arguments (if `self.settings` not |
||||||
|
already set), run `self.reader` and then `self.writer`. Return |
||||||
|
`self.writer`'s output. |
||||||
|
""" |
||||||
|
exit = None |
||||||
|
try: |
||||||
|
if self.settings is None: |
||||||
|
self.process_command_line( |
||||||
|
argv, usage, description, settings_spec, config_section, |
||||||
|
**(settings_overrides or {})) |
||||||
|
self.set_io() |
||||||
|
self.document = self.reader.read(self.source, self.parser, |
||||||
|
self.settings) |
||||||
|
self.apply_transforms() |
||||||
|
output = self.writer.write(self.document, self.destination) |
||||||
|
self.writer.assemble_parts() |
||||||
|
except SystemExit, error: |
||||||
|
exit = 1 |
||||||
|
exit_status = error.code |
||||||
|
except Exception, error: |
||||||
|
if not self.settings: # exception too early to report nicely |
||||||
|
raise |
||||||
|
if self.settings.traceback: # Propagate exceptions? |
||||||
|
self.debugging_dumps() |
||||||
|
raise |
||||||
|
self.report_Exception(error) |
||||||
|
exit = True |
||||||
|
exit_status = 1 |
||||||
|
self.debugging_dumps() |
||||||
|
if (enable_exit_status and self.document |
||||||
|
and (self.document.reporter.max_level |
||||||
|
>= self.settings.exit_status_level)): |
||||||
|
sys.exit(self.document.reporter.max_level + 10) |
||||||
|
elif exit: |
||||||
|
sys.exit(exit_status) |
||||||
|
return output |
||||||
|
|
||||||
|
def debugging_dumps(self): |
||||||
|
if not self.document: |
||||||
|
return |
||||||
|
if self.settings.dump_settings: |
||||||
|
print >>self._stderr, '\n::: Runtime settings:' |
||||||
|
print >>self._stderr, pprint.pformat(self.settings.__dict__) |
||||||
|
if self.settings.dump_internals: |
||||||
|
print >>self._stderr, '\n::: Document internals:' |
||||||
|
print >>self._stderr, pprint.pformat(self.document.__dict__) |
||||||
|
if self.settings.dump_transforms: |
||||||
|
print >>self._stderr, '\n::: Transforms applied:' |
||||||
|
print >>self._stderr, (' (priority, transform class, ' |
||||||
|
'pending node details, keyword args)') |
||||||
|
print >>self._stderr, pprint.pformat( |
||||||
|
[(priority, '%s.%s' % (xclass.__module__, xclass.__name__), |
||||||
|
pending and pending.details, kwargs) |
||||||
|
for priority, xclass, pending, kwargs |
||||||
|
in self.document.transformer.applied]) |
||||||
|
if self.settings.dump_pseudo_xml: |
||||||
|
print >>self._stderr, '\n::: Pseudo-XML:' |
||||||
|
print >>self._stderr, self.document.pformat().encode( |
||||||
|
'raw_unicode_escape') |
||||||
|
|
||||||
|
def report_Exception(self, error): |
||||||
|
if isinstance(error, utils.SystemMessage): |
||||||
|
self.report_SystemMessage(error) |
||||||
|
elif isinstance(error, UnicodeEncodeError): |
||||||
|
self.report_UnicodeError(error) |
||||||
|
elif isinstance(error, io.InputError): |
||||||
|
self._stderr.write(u'Unable to open source file for reading:\n' |
||||||
|
u' %s\n' % ErrorString(error)) |
||||||
|
elif isinstance(error, io.OutputError): |
||||||
|
self._stderr.write( |
||||||
|
u'Unable to open destination file for writing:\n' |
||||||
|
u' %s\n' % ErrorString(error)) |
||||||
|
else: |
||||||
|
print >>self._stderr, u'%s' % ErrorString(error) |
||||||
|
print >>self._stderr, ("""\ |
||||||
|
Exiting due to error. Use "--traceback" to diagnose. |
||||||
|
Please report errors to <docutils-users@lists.sf.net>. |
||||||
|
Include "--traceback" output, Docutils version (%s%s), |
||||||
|
Python version (%s), your OS type & version, and the |
||||||
|
command line used.""" % (__version__, |
||||||
|
docutils.__version_details__ and |
||||||
|
' [%s]'%docutils.__version_details__ or '', |
||||||
|
sys.version.split()[0])) |
||||||
|
|
||||||
|
def report_SystemMessage(self, error): |
||||||
|
print >>self._stderr, ('Exiting due to level-%s (%s) system message.' |
||||||
|
% (error.level, |
||||||
|
utils.Reporter.levels[error.level])) |
||||||
|
|
||||||
|
def report_UnicodeError(self, error): |
||||||
|
data = error.object[error.start:error.end] |
||||||
|
self._stderr.write( |
||||||
|
'%s\n' |
||||||
|
'\n' |
||||||
|
'The specified output encoding (%s) cannot\n' |
||||||
|
'handle all of the output.\n' |
||||||
|
'Try setting "--output-encoding-error-handler" to\n' |
||||||
|
'\n' |
||||||
|
'* "xmlcharrefreplace" (for HTML & XML output);\n' |
||||||
|
' the output will contain "%s" and should be usable.\n' |
||||||
|
'* "backslashreplace" (for other output formats);\n' |
||||||
|
' look for "%s" in the output.\n' |
||||||
|
'* "replace"; look for "?" in the output.\n' |
||||||
|
'\n' |
||||||
|
'"--output-encoding-error-handler" is currently set to "%s".\n' |
||||||
|
'\n' |
||||||
|
'Exiting due to error. Use "--traceback" to diagnose.\n' |
||||||
|
'If the advice above doesn\'t eliminate the error,\n' |
||||||
|
'please report it to <docutils-users@lists.sf.net>.\n' |
||||||
|
'Include "--traceback" output, Docutils version (%s),\n' |
||||||
|
'Python version (%s), your OS type & version, and the\n' |
||||||
|
'command line used.\n' |
||||||
|
% (ErrorString(error), |
||||||
|
self.settings.output_encoding, |
||||||
|
data.encode('ascii', 'xmlcharrefreplace'), |
||||||
|
data.encode('ascii', 'backslashreplace'), |
||||||
|
self.settings.output_encoding_error_handler, |
||||||
|
__version__, sys.version.split()[0])) |
||||||
|
|
||||||
|
default_usage = '%prog [options] [<source> [<destination>]]' |
||||||
|
default_description = ('Reads from <source> (default is stdin) and writes to ' |
||||||
|
'<destination> (default is stdout). See ' |
||||||
|
'<http://docutils.sf.net/docs/user/config.html> for ' |
||||||
|
'the full reference.') |
||||||
|
|
||||||
|
def publish_cmdline(reader=None, reader_name='standalone', |
||||||
|
parser=None, parser_name='restructuredtext', |
||||||
|
writer=None, writer_name='pseudoxml', |
||||||
|
settings=None, settings_spec=None, |
||||||
|
settings_overrides=None, config_section=None, |
||||||
|
enable_exit_status=True, argv=None, |
||||||
|
usage=default_usage, description=default_description): |
||||||
|
""" |
||||||
|
Set up & run a `Publisher` for command-line-based file I/O (input and |
||||||
|
output file paths taken automatically from the command line). Return the |
||||||
|
encoded string output also. |
||||||
|
|
||||||
|
Parameters: see `publish_programmatically` for the remainder. |
||||||
|
|
||||||
|
- `argv`: Command-line argument list to use instead of ``sys.argv[1:]``. |
||||||
|
- `usage`: Usage string, output if there's a problem parsing the command |
||||||
|
line. |
||||||
|
- `description`: Program description, output for the "--help" option |
||||||
|
(along with command-line option descriptions). |
||||||
|
""" |
||||||
|
pub = Publisher(reader, parser, writer, settings=settings) |
||||||
|
pub.set_components(reader_name, parser_name, writer_name) |
||||||
|
output = pub.publish( |
||||||
|
argv, usage, description, settings_spec, settings_overrides, |
||||||
|
config_section=config_section, enable_exit_status=enable_exit_status) |
||||||
|
return output |
||||||
|
|
||||||
|
def publish_file(source=None, source_path=None, |
||||||
|
destination=None, destination_path=None, |
||||||
|
reader=None, reader_name='standalone', |
||||||
|
parser=None, parser_name='restructuredtext', |
||||||
|
writer=None, writer_name='pseudoxml', |
||||||
|
settings=None, settings_spec=None, settings_overrides=None, |
||||||
|
config_section=None, enable_exit_status=False): |
||||||
|
""" |
||||||
|
Set up & run a `Publisher` for programmatic use with file-like I/O. |
||||||
|
Return the encoded string output also. |
||||||
|
|
||||||
|
Parameters: see `publish_programmatically`. |
||||||
|
""" |
||||||
|
output, pub = publish_programmatically( |
||||||
|
source_class=io.FileInput, source=source, source_path=source_path, |
||||||
|
destination_class=io.FileOutput, |
||||||
|
destination=destination, destination_path=destination_path, |
||||||
|
reader=reader, reader_name=reader_name, |
||||||
|
parser=parser, parser_name=parser_name, |
||||||
|
writer=writer, writer_name=writer_name, |
||||||
|
settings=settings, settings_spec=settings_spec, |
||||||
|
settings_overrides=settings_overrides, |
||||||
|
config_section=config_section, |
||||||
|
enable_exit_status=enable_exit_status) |
||||||
|
return output |
||||||
|
|
||||||
|
def publish_string(source, source_path=None, destination_path=None, |
||||||
|
reader=None, reader_name='standalone', |
||||||
|
parser=None, parser_name='restructuredtext', |
||||||
|
writer=None, writer_name='pseudoxml', |
||||||
|
settings=None, settings_spec=None, |
||||||
|
settings_overrides=None, config_section=None, |
||||||
|
enable_exit_status=False): |
||||||
|
""" |
||||||
|
Set up & run a `Publisher` for programmatic use with string I/O. Return |
||||||
|
the encoded string or Unicode string output. |
||||||
|
|
||||||
|
For encoded string output, be sure to set the 'output_encoding' setting to |
||||||
|
the desired encoding. Set it to 'unicode' for unencoded Unicode string |
||||||
|
output. Here's one way:: |
||||||
|
|
||||||
|
publish_string(..., settings_overrides={'output_encoding': 'unicode'}) |
||||||
|
|
||||||
|
Similarly for Unicode string input (`source`):: |
||||||
|
|
||||||
|
publish_string(..., settings_overrides={'input_encoding': 'unicode'}) |
||||||
|
|
||||||
|
Parameters: see `publish_programmatically`. |
||||||
|
""" |
||||||
|
output, pub = publish_programmatically( |
||||||
|
source_class=io.StringInput, source=source, source_path=source_path, |
||||||
|
destination_class=io.StringOutput, |
||||||
|
destination=None, destination_path=destination_path, |
||||||
|
reader=reader, reader_name=reader_name, |
||||||
|
parser=parser, parser_name=parser_name, |
||||||
|
writer=writer, writer_name=writer_name, |
||||||
|
settings=settings, settings_spec=settings_spec, |
||||||
|
settings_overrides=settings_overrides, |
||||||
|
config_section=config_section, |
||||||
|
enable_exit_status=enable_exit_status) |
||||||
|
return output |
||||||
|
|
||||||
|
def publish_parts(source, source_path=None, source_class=io.StringInput, |
||||||
|
destination_path=None, |
||||||
|
reader=None, reader_name='standalone', |
||||||
|
parser=None, parser_name='restructuredtext', |
||||||
|
writer=None, writer_name='pseudoxml', |
||||||
|
settings=None, settings_spec=None, |
||||||
|
settings_overrides=None, config_section=None, |
||||||
|
enable_exit_status=False): |
||||||
|
""" |
||||||
|
Set up & run a `Publisher`, and return a dictionary of document parts. |
||||||
|
Dictionary keys are the names of parts, and values are Unicode strings; |
||||||
|
encoding is up to the client. For programmatic use with string I/O. |
||||||
|
|
||||||
|
For encoded string input, be sure to set the 'input_encoding' setting to |
||||||
|
the desired encoding. Set it to 'unicode' for unencoded Unicode string |
||||||
|
input. Here's how:: |
||||||
|
|
||||||
|
publish_parts(..., settings_overrides={'input_encoding': 'unicode'}) |
||||||
|
|
||||||
|
Parameters: see `publish_programmatically`. |
||||||
|
""" |
||||||
|
output, pub = publish_programmatically( |
||||||
|
source=source, source_path=source_path, source_class=source_class, |
||||||
|
destination_class=io.StringOutput, |
||||||
|
destination=None, destination_path=destination_path, |
||||||
|
reader=reader, reader_name=reader_name, |
||||||
|
parser=parser, parser_name=parser_name, |
||||||
|
writer=writer, writer_name=writer_name, |
||||||
|
settings=settings, settings_spec=settings_spec, |
||||||
|
settings_overrides=settings_overrides, |
||||||
|
config_section=config_section, |
||||||
|
enable_exit_status=enable_exit_status) |
||||||
|
return pub.writer.parts |
||||||
|
|
||||||
|
def publish_doctree(source, source_path=None, |
||||||
|
source_class=io.StringInput, |
||||||
|
reader=None, reader_name='standalone', |
||||||
|
parser=None, parser_name='restructuredtext', |
||||||
|
settings=None, settings_spec=None, |
||||||
|
settings_overrides=None, config_section=None, |
||||||
|
enable_exit_status=False): |
||||||
|
""" |
||||||
|
Set up & run a `Publisher` for programmatic use with string I/O. |
||||||
|
Return the document tree. |
||||||
|
|
||||||
|
For encoded string input, be sure to set the 'input_encoding' setting to |
||||||
|
the desired encoding. Set it to 'unicode' for unencoded Unicode string |
||||||
|
input. Here's one way:: |
||||||
|
|
||||||
|
publish_doctree(..., settings_overrides={'input_encoding': 'unicode'}) |
||||||
|
|
||||||
|
Parameters: see `publish_programmatically`. |
||||||
|
""" |
||||||
|
pub = Publisher(reader=reader, parser=parser, writer=None, |
||||||
|
settings=settings, |
||||||
|
source_class=source_class, |
||||||
|
destination_class=io.NullOutput) |
||||||
|
pub.set_components(reader_name, parser_name, 'null') |
||||||
|
pub.process_programmatic_settings( |
||||||
|
settings_spec, settings_overrides, config_section) |
||||||
|
pub.set_source(source, source_path) |
||||||
|
pub.set_destination(None, None) |
||||||
|
output = pub.publish(enable_exit_status=enable_exit_status) |
||||||
|
return pub.document |
||||||
|
|
||||||
|
def publish_from_doctree(document, destination_path=None, |
||||||
|
writer=None, writer_name='pseudoxml', |
||||||
|
settings=None, settings_spec=None, |
||||||
|
settings_overrides=None, config_section=None, |
||||||
|
enable_exit_status=False): |
||||||
|
""" |
||||||
|
Set up & run a `Publisher` to render from an existing document |
||||||
|
tree data structure, for programmatic use with string I/O. Return |
||||||
|
the encoded string output. |
||||||
|
|
||||||
|
Note that document.settings is overridden; if you want to use the settings |
||||||
|
of the original `document`, pass settings=document.settings. |
||||||
|
|
||||||
|
Also, new document.transformer and document.reporter objects are |
||||||
|
generated. |
||||||
|
|
||||||
|
For encoded string output, be sure to set the 'output_encoding' setting to |
||||||
|
the desired encoding. Set it to 'unicode' for unencoded Unicode string |
||||||
|
output. Here's one way:: |
||||||
|
|
||||||
|
publish_from_doctree( |
||||||
|
..., settings_overrides={'output_encoding': 'unicode'}) |
||||||
|
|
||||||
|
Parameters: `document` is a `docutils.nodes.document` object, an existing |
||||||
|
document tree. |
||||||
|
|
||||||
|
Other parameters: see `publish_programmatically`. |
||||||
|
""" |
||||||
|
reader = docutils.readers.doctree.Reader(parser_name='null') |
||||||
|
pub = Publisher(reader, None, writer, |
||||||
|
source=io.DocTreeInput(document), |
||||||
|
destination_class=io.StringOutput, settings=settings) |
||||||
|
if not writer and writer_name: |
||||||
|
pub.set_writer(writer_name) |
||||||
|
pub.process_programmatic_settings( |
||||||
|
settings_spec, settings_overrides, config_section) |
||||||
|
pub.set_destination(None, destination_path) |
||||||
|
return pub.publish(enable_exit_status=enable_exit_status) |
||||||
|
|
||||||
|
def publish_cmdline_to_binary(reader=None, reader_name='standalone', |
||||||
|
parser=None, parser_name='restructuredtext', |
||||||
|
writer=None, writer_name='pseudoxml', |
||||||
|
settings=None, settings_spec=None, |
||||||
|
settings_overrides=None, config_section=None, |
||||||
|
enable_exit_status=True, argv=None, |
||||||
|
usage=default_usage, description=default_description, |
||||||
|
destination=None, destination_class=io.BinaryFileOutput |
||||||
|
): |
||||||
|
""" |
||||||
|
Set up & run a `Publisher` for command-line-based file I/O (input and |
||||||
|
output file paths taken automatically from the command line). Return the |
||||||
|
encoded string output also. |
||||||
|
|
||||||
|
This is just like publish_cmdline, except that it uses |
||||||
|
io.BinaryFileOutput instead of io.FileOutput. |
||||||
|
|
||||||
|
Parameters: see `publish_programmatically` for the remainder. |
||||||
|
|
||||||
|
- `argv`: Command-line argument list to use instead of ``sys.argv[1:]``. |
||||||
|
- `usage`: Usage string, output if there's a problem parsing the command |
||||||
|
line. |
||||||
|
- `description`: Program description, output for the "--help" option |
||||||
|
(along with command-line option descriptions). |
||||||
|
""" |
||||||
|
pub = Publisher(reader, parser, writer, settings=settings, |
||||||
|
destination_class=destination_class) |
||||||
|
pub.set_components(reader_name, parser_name, writer_name) |
||||||
|
output = pub.publish( |
||||||
|
argv, usage, description, settings_spec, settings_overrides, |
||||||
|
config_section=config_section, enable_exit_status=enable_exit_status) |
||||||
|
return output |
||||||
|
|
||||||
|
def publish_programmatically(source_class, source, source_path, |
||||||
|
destination_class, destination, destination_path, |
||||||
|
reader, reader_name, |
||||||
|
parser, parser_name, |
||||||
|
writer, writer_name, |
||||||
|
settings, settings_spec, |
||||||
|
settings_overrides, config_section, |
||||||
|
enable_exit_status): |
||||||
|
""" |
||||||
|
Set up & run a `Publisher` for custom programmatic use. Return the |
||||||
|
encoded string output and the Publisher object. |
||||||
|
|
||||||
|
Applications should not need to call this function directly. If it does |
||||||
|
seem to be necessary to call this function directly, please write to the |
||||||
|
Docutils-develop mailing list |
||||||
|
<http://docutils.sf.net/docs/user/mailing-lists.html#docutils-develop>. |
||||||
|
|
||||||
|
Parameters: |
||||||
|
|
||||||
|
* `source_class` **required**: The class for dynamically created source |
||||||
|
objects. Typically `io.FileInput` or `io.StringInput`. |
||||||
|
|
||||||
|
* `source`: Type depends on `source_class`: |
||||||
|
|
||||||
|
- If `source_class` is `io.FileInput`: Either a file-like object |
||||||
|
(must have 'read' and 'close' methods), or ``None`` |
||||||
|
(`source_path` is opened). If neither `source` nor |
||||||
|
`source_path` are supplied, `sys.stdin` is used. |
||||||
|
|
||||||
|
- If `source_class` is `io.StringInput` **required**: The input |
||||||
|
string, either an encoded 8-bit string (set the |
||||||
|
'input_encoding' setting to the correct encoding) or a Unicode |
||||||
|
string (set the 'input_encoding' setting to 'unicode'). |
||||||
|
|
||||||
|
* `source_path`: Type depends on `source_class`: |
||||||
|
|
||||||
|
- `io.FileInput`: Path to the input file, opened if no `source` |
||||||
|
supplied. |
||||||
|
|
||||||
|
- `io.StringInput`: Optional. Path to the file or object that produced |
||||||
|
`source`. Only used for diagnostic output. |
||||||
|
|
||||||
|
* `destination_class` **required**: The class for dynamically created |
||||||
|
destination objects. Typically `io.FileOutput` or `io.StringOutput`. |
||||||
|
|
||||||
|
* `destination`: Type depends on `destination_class`: |
||||||
|
|
||||||
|
- `io.FileOutput`: Either a file-like object (must have 'write' and |
||||||
|
'close' methods), or ``None`` (`destination_path` is opened). If |
||||||
|
neither `destination` nor `destination_path` are supplied, |
||||||
|
`sys.stdout` is used. |
||||||
|
|
||||||
|
- `io.StringOutput`: Not used; pass ``None``. |
||||||
|
|
||||||
|
* `destination_path`: Type depends on `destination_class`: |
||||||
|
|
||||||
|
- `io.FileOutput`: Path to the output file. Opened if no `destination` |
||||||
|
supplied. |
||||||
|
|
||||||
|
- `io.StringOutput`: Path to the file or object which will receive the |
||||||
|
output; optional. Used for determining relative paths (stylesheets, |
||||||
|
source links, etc.). |
||||||
|
|
||||||
|
* `reader`: A `docutils.readers.Reader` object. |
||||||
|
|
||||||
|
* `reader_name`: Name or alias of the Reader class to be instantiated if |
||||||
|
no `reader` supplied. |
||||||
|
|
||||||
|
* `parser`: A `docutils.parsers.Parser` object. |
||||||
|
|
||||||
|
* `parser_name`: Name or alias of the Parser class to be instantiated if |
||||||
|
no `parser` supplied. |
||||||
|
|
||||||
|
* `writer`: A `docutils.writers.Writer` object. |
||||||
|
|
||||||
|
* `writer_name`: Name or alias of the Writer class to be instantiated if |
||||||
|
no `writer` supplied. |
||||||
|
|
||||||
|
* `settings`: A runtime settings (`docutils.frontend.Values`) object, for |
||||||
|
dotted-attribute access to runtime settings. It's the end result of the |
||||||
|
`SettingsSpec`, config file, and option processing. If `settings` is |
||||||
|
passed, it's assumed to be complete and no further setting/config/option |
||||||
|
processing is done. |
||||||
|
|
||||||
|
* `settings_spec`: A `docutils.SettingsSpec` subclass or object. Provides |
||||||
|
extra application-specific settings definitions independently of |
||||||
|
components. In other words, the application becomes a component, and |
||||||
|
its settings data is processed along with that of the other components. |
||||||
|
Used only if no `settings` specified. |
||||||
|
|
||||||
|
* `settings_overrides`: A dictionary containing application-specific |
||||||
|
settings defaults that override the defaults of other components. |
||||||
|
Used only if no `settings` specified. |
||||||
|
|
||||||
|
* `config_section`: A string, the name of the configuration file section |
||||||
|
for this application. Overrides the ``config_section`` attribute |
||||||
|
defined by `settings_spec`. Used only if no `settings` specified. |
||||||
|
|
||||||
|
* `enable_exit_status`: Boolean; enable exit status at end of processing? |
||||||
|
""" |
||||||
|
pub = Publisher(reader, parser, writer, settings=settings, |
||||||
|
source_class=source_class, |
||||||
|
destination_class=destination_class) |
||||||
|
pub.set_components(reader_name, parser_name, writer_name) |
||||||
|
pub.process_programmatic_settings( |
||||||
|
settings_spec, settings_overrides, config_section) |
||||||
|
pub.set_source(source, source_path) |
||||||
|
pub.set_destination(destination, destination_path) |
||||||
|
output = pub.publish(enable_exit_status=enable_exit_status) |
||||||
|
return output, pub |
@ -0,0 +1,5 @@ |
|||||||
|
# This configuration file is to prevent tools/buildhtml.py from |
||||||
|
# processing text files in and below this directory. |
||||||
|
|
||||||
|
[buildhtml application] |
||||||
|
prune: . |
@ -0,0 +1,97 @@ |
|||||||
|
# $Id: examples.py 7320 2012-01-19 22:33:02Z milde $ |
||||||
|
# Author: David Goodger <goodger@python.org> |
||||||
|
# Copyright: This module has been placed in the public domain. |
||||||
|
|
||||||
|
""" |
||||||
|
This module contains practical examples of Docutils client code. |
||||||
|
|
||||||
|
Importing this module from client code is not recommended; its contents are |
||||||
|
subject to change in future Docutils releases. Instead, it is recommended |
||||||
|
that you copy and paste the parts you need into your own code, modifying as |
||||||
|
necessary. |
||||||
|
""" |
||||||
|
|
||||||
|
from docutils import core, io |
||||||
|
|
||||||
|
|
||||||
|
def html_parts(input_string, source_path=None, destination_path=None, |
||||||
|
input_encoding='unicode', doctitle=True, |
||||||
|
initial_header_level=1): |
||||||
|
""" |
||||||
|
Given an input string, returns a dictionary of HTML document parts. |
||||||
|
|
||||||
|
Dictionary keys are the names of parts, and values are Unicode strings; |
||||||
|
encoding is up to the client. |
||||||
|
|
||||||
|
Parameters: |
||||||
|
|
||||||
|
- `input_string`: A multi-line text string; required. |
||||||
|
- `source_path`: Path to the source file or object. Optional, but useful |
||||||
|
for diagnostic output (system messages). |
||||||
|
- `destination_path`: Path to the file or object which will receive the |
||||||
|
output; optional. Used for determining relative paths (stylesheets, |
||||||
|
source links, etc.). |
||||||
|
- `input_encoding`: The encoding of `input_string`. If it is an encoded |
||||||
|
8-bit string, provide the correct encoding. If it is a Unicode string, |
||||||
|
use "unicode", the default. |
||||||
|
- `doctitle`: Disable the promotion of a lone top-level section title to |
||||||
|
document title (and subsequent section title to document subtitle |
||||||
|
promotion); enabled by default. |
||||||
|
- `initial_header_level`: The initial level for header elements (e.g. 1 |
||||||
|
for "<h1>"). |
||||||
|
""" |
||||||
|
overrides = {'input_encoding': input_encoding, |
||||||
|
'doctitle_xform': doctitle, |
||||||
|
'initial_header_level': initial_header_level} |
||||||
|
parts = core.publish_parts( |
||||||
|
source=input_string, source_path=source_path, |
||||||
|
destination_path=destination_path, |
||||||
|
writer_name='html', settings_overrides=overrides) |
||||||
|
return parts |
||||||
|
|
||||||
|
def html_body(input_string, source_path=None, destination_path=None, |
||||||
|
input_encoding='unicode', output_encoding='unicode', |
||||||
|
doctitle=True, initial_header_level=1): |
||||||
|
""" |
||||||
|
Given an input string, returns an HTML fragment as a string. |
||||||
|
|
||||||
|
The return value is the contents of the <body> element. |
||||||
|
|
||||||
|
Parameters (see `html_parts()` for the remainder): |
||||||
|
|
||||||
|
- `output_encoding`: The desired encoding of the output. If a Unicode |
||||||
|
string is desired, use the default value of "unicode" . |
||||||
|
""" |
||||||
|
parts = html_parts( |
||||||
|
input_string=input_string, source_path=source_path, |
||||||
|
destination_path=destination_path, |
||||||
|
input_encoding=input_encoding, doctitle=doctitle, |
||||||
|
initial_header_level=initial_header_level) |
||||||
|
fragment = parts['html_body'] |
||||||
|
if output_encoding != 'unicode': |
||||||
|
fragment = fragment.encode(output_encoding) |
||||||
|
return fragment |
||||||
|
|
||||||
|
def internals(input_string, source_path=None, destination_path=None, |
||||||
|
input_encoding='unicode', settings_overrides=None): |
||||||
|
""" |
||||||
|
Return the document tree and publisher, for exploring Docutils internals. |
||||||
|
|
||||||
|
Parameters: see `html_parts()`. |
||||||
|
""" |
||||||
|
if settings_overrides: |
||||||
|
overrides = settings_overrides.copy() |
||||||
|
else: |
||||||
|
overrides = {} |
||||||
|
overrides['input_encoding'] = input_encoding |
||||||
|
output, pub = core.publish_programmatically( |
||||||
|
source_class=io.StringInput, source=input_string, |
||||||
|
source_path=source_path, |
||||||
|
destination_class=io.NullOutput, destination=None, |
||||||
|
destination_path=destination_path, |
||||||
|
reader=None, reader_name='standalone', |
||||||
|
parser=None, parser_name='restructuredtext', |
||||||
|
writer=None, writer_name='null', |
||||||
|
settings=None, settings_spec=None, settings_overrides=overrides, |
||||||
|
config_section=None, enable_exit_status=None) |
||||||
|
return pub.writer.document, pub |
@ -0,0 +1,859 @@ |
|||||||
|
# $Id: frontend.py 8126 2017-06-23 09:34:28Z milde $ |
||||||
|
# Author: David Goodger <goodger@python.org> |
||||||
|
# Copyright: This module has been placed in the public domain. |
||||||
|
|
||||||
|
""" |
||||||
|
Command-line and common processing for Docutils front-end tools. |
||||||
|
|
||||||
|
Exports the following classes: |
||||||
|
|
||||||
|
* `OptionParser`: Standard Docutils command-line processing. |
||||||
|
* `Option`: Customized version of `optparse.Option`; validation support. |
||||||
|
* `Values`: Runtime settings; objects are simple structs |
||||||
|
(``object.attribute``). Supports cumulative list settings (attributes). |
||||||
|
* `ConfigParser`: Standard Docutils config file processing. |
||||||
|
|
||||||
|
Also exports the following functions: |
||||||
|
|
||||||
|
* Option callbacks: `store_multiple`, `read_config_file`. |
||||||
|
* Setting validators: `validate_encoding`, |
||||||
|
`validate_encoding_error_handler`, |
||||||
|
`validate_encoding_and_error_handler`, |
||||||
|
`validate_boolean`, `validate_ternary`, `validate_threshold`, |
||||||
|
`validate_colon_separated_string_list`, |
||||||
|
`validate_comma_separated_string_list`, |
||||||
|
`validate_dependency_file`. |
||||||
|
* `make_paths_absolute`. |
||||||
|
* SettingSpec manipulation: `filter_settings_spec`. |
||||||
|
""" |
||||||
|
|
||||||
|
__docformat__ = 'reStructuredText' |
||||||
|
|
||||||
|
import os |
||||||
|
import os.path |
||||||
|
import sys |
||||||
|
import warnings |
||||||
|
import ConfigParser as CP |
||||||
|
import codecs |
||||||
|
import optparse |
||||||
|
from optparse import SUPPRESS_HELP |
||||||
|
import docutils |
||||||
|
import docutils.utils |
||||||
|
import docutils.nodes |
||||||
|
from docutils.utils.error_reporting import (locale_encoding, SafeString, |
||||||
|
ErrorOutput, ErrorString) |
||||||
|
|
||||||
|
|
||||||
|
def store_multiple(option, opt, value, parser, *args, **kwargs): |
||||||
|
""" |
||||||
|
Store multiple values in `parser.values`. (Option callback.) |
||||||
|
|
||||||
|
Store `None` for each attribute named in `args`, and store the value for |
||||||
|
each key (attribute name) in `kwargs`. |
||||||
|
""" |
||||||
|
for attribute in args: |
||||||
|
setattr(parser.values, attribute, None) |
||||||
|
for key, value in kwargs.items(): |
||||||
|
setattr(parser.values, key, value) |
||||||
|
|
||||||
|
def read_config_file(option, opt, value, parser): |
||||||
|
""" |
||||||
|
Read a configuration file during option processing. (Option callback.) |
||||||
|
""" |
||||||
|
try: |
||||||
|
new_settings = parser.get_config_file_settings(value) |
||||||
|
except ValueError, error: |
||||||
|
parser.error(error) |
||||||
|
parser.values.update(new_settings, parser) |
||||||
|
|
||||||
|
def validate_encoding(setting, value, option_parser, |
||||||
|
config_parser=None, config_section=None): |
||||||
|
try: |
||||||
|
codecs.lookup(value) |
||||||
|
except LookupError: |
||||||
|
raise (LookupError('setting "%s": unknown encoding: "%s"' |
||||||
|
% (setting, value)), |
||||||
|
None, sys.exc_info()[2]) |
||||||
|
return value |
||||||
|
|
||||||
|
def validate_encoding_error_handler(setting, value, option_parser, |
||||||
|
config_parser=None, config_section=None): |
||||||
|
try: |
||||||
|
codecs.lookup_error(value) |
||||||
|
except LookupError: |
||||||
|
raise (LookupError( |
||||||
|
'unknown encoding error handler: "%s" (choices: ' |
||||||
|
'"strict", "ignore", "replace", "backslashreplace", ' |
||||||
|
'"xmlcharrefreplace", and possibly others; see documentation for ' |
||||||
|
'the Python ``codecs`` module)' % value), |
||||||
|
None, sys.exc_info()[2]) |
||||||
|
return value |
||||||
|
|
||||||
|
def validate_encoding_and_error_handler( |
||||||
|
setting, value, option_parser, config_parser=None, config_section=None): |
||||||
|
""" |
||||||
|
Side-effect: if an error handler is included in the value, it is inserted |
||||||
|
into the appropriate place as if it was a separate setting/option. |
||||||
|
""" |
||||||
|
if ':' in value: |
||||||
|
encoding, handler = value.split(':') |
||||||
|
validate_encoding_error_handler( |
||||||
|
setting + '_error_handler', handler, option_parser, |
||||||
|
config_parser, config_section) |
||||||
|
if config_parser: |
||||||
|
config_parser.set(config_section, setting + '_error_handler', |
||||||
|
handler) |
||||||
|
else: |
||||||
|
setattr(option_parser.values, setting + '_error_handler', handler) |
||||||
|
else: |
||||||
|
encoding = value |
||||||
|
validate_encoding(setting, encoding, option_parser, |
||||||
|
config_parser, config_section) |
||||||
|
return encoding |
||||||
|
|
||||||
|
def validate_boolean(setting, value, option_parser, |
||||||
|
config_parser=None, config_section=None): |
||||||
|
"""Check/normalize boolean settings: |
||||||
|
True: '1', 'on', 'yes', 'true' |
||||||
|
False: '0', 'off', 'no','false', '' |
||||||
|
""" |
||||||
|
if isinstance(value, bool): |
||||||
|
return value |
||||||
|
try: |
||||||
|
return option_parser.booleans[value.strip().lower()] |
||||||
|
except KeyError: |
||||||
|
raise (LookupError('unknown boolean value: "%s"' % value), |
||||||
|
None, sys.exc_info()[2]) |
||||||
|
|
||||||
|
def validate_ternary(setting, value, option_parser, |
||||||
|
config_parser=None, config_section=None): |
||||||
|
"""Check/normalize three-value settings: |
||||||
|
True: '1', 'on', 'yes', 'true' |
||||||
|
False: '0', 'off', 'no','false', '' |
||||||
|
any other value: returned as-is. |
||||||
|
""" |
||||||
|
if isinstance(value, bool) or value is None: |
||||||
|
return value |
||||||
|
try: |
||||||
|
return option_parser.booleans[value.strip().lower()] |
||||||
|
except KeyError: |
||||||
|
return value |
||||||
|
|
||||||
|
def validate_nonnegative_int(setting, value, option_parser, |
||||||
|
config_parser=None, config_section=None): |
||||||
|
value = int(value) |
||||||
|
if value < 0: |
||||||
|
raise ValueError('negative value; must be positive or zero') |
||||||
|
return value |
||||||
|
|
||||||
|
def validate_threshold(setting, value, option_parser, |
||||||
|
config_parser=None, config_section=None): |
||||||
|
try: |
||||||
|
return int(value) |
||||||
|
except ValueError: |
||||||
|
try: |
||||||
|
return option_parser.thresholds[value.lower()] |
||||||
|
except (KeyError, AttributeError): |
||||||
|
raise (LookupError('unknown threshold: %r.' % value), |
||||||
|
None, sys.exc_info[2]) |
||||||
|
|
||||||
|
def validate_colon_separated_string_list( |
||||||
|
setting, value, option_parser, config_parser=None, config_section=None): |
||||||
|
if not isinstance(value, list): |
||||||
|
value = value.split(':') |
||||||
|
else: |
||||||
|
last = value.pop() |
||||||
|
value.extend(last.split(':')) |
||||||
|
return value |
||||||
|
|
||||||
|
def validate_comma_separated_list(setting, value, option_parser, |
||||||
|
config_parser=None, config_section=None): |
||||||
|
"""Check/normalize list arguments (split at "," and strip whitespace). |
||||||
|
""" |
||||||
|
# `value` is already a ``list`` when given as command line option |
||||||
|
# and "action" is "append" and ``unicode`` or ``str`` else. |
||||||
|
if not isinstance(value, list): |
||||||
|
value = [value] |
||||||
|
# this function is called for every option added to `value` |
||||||
|
# -> split the last item and append the result: |
||||||
|
last = value.pop() |
||||||
|
items = [i.strip(u' \t\n') for i in last.split(u',') if i.strip(u' \t\n')] |
||||||
|
value.extend(items) |
||||||
|
return value |
||||||
|
|
||||||
|
def validate_url_trailing_slash( |
||||||
|
setting, value, option_parser, config_parser=None, config_section=None): |
||||||
|
if not value: |
||||||
|
return './' |
||||||
|
elif value.endswith('/'): |
||||||
|
return value |
||||||
|
else: |
||||||
|
return value + '/' |
||||||
|
|
||||||
|
def validate_dependency_file(setting, value, option_parser, |
||||||
|
config_parser=None, config_section=None): |
||||||
|
try: |
||||||
|
return docutils.utils.DependencyList(value) |
||||||
|
except IOError: |
||||||
|
return docutils.utils.DependencyList(None) |
||||||
|
|
||||||
|
def validate_strip_class(setting, value, option_parser, |
||||||
|
config_parser=None, config_section=None): |
||||||
|
# value is a comma separated string list: |
||||||
|
value = validate_comma_separated_list(setting, value, option_parser, |
||||||
|
config_parser, config_section) |
||||||
|
# validate list elements: |
||||||
|
for cls in value: |
||||||
|
normalized = docutils.nodes.make_id(cls) |
||||||
|
if cls != normalized: |
||||||
|
raise ValueError('Invalid class value %r (perhaps %r?)' |
||||||
|
% (cls, normalized)) |
||||||
|
return value |
||||||
|
|
||||||
|
def validate_smartquotes_locales(setting, value, option_parser, |
||||||
|
config_parser=None, config_section=None): |
||||||
|
"""Check/normalize a comma separated list of smart quote definitions. |
||||||
|
|
||||||
|
Return a list of (language-tag, quotes) string tuples.""" |
||||||
|
|
||||||
|
# value is a comma separated string list: |
||||||
|
value = validate_comma_separated_list(setting, value, option_parser, |
||||||
|
config_parser, config_section) |
||||||
|
# validate list elements |
||||||
|
lc_quotes = [] |
||||||
|
for item in value: |
||||||
|
try: |
||||||
|
lang, quotes = item.split(':', 1) |
||||||
|
except AttributeError: |
||||||
|
# this function is called for every option added to `value` |
||||||
|
# -> ignore if already a tuple: |
||||||
|
lc_quotes.append(item) |
||||||
|
continue |
||||||
|
except ValueError: |
||||||
|
raise ValueError(u'Invalid value "%s".' |
||||||
|
' Format is "<language>:<quotes>".' |
||||||
|
% item.encode('ascii', 'backslashreplace')) |
||||||
|
# parse colon separated string list: |
||||||
|
quotes = quotes.strip() |
||||||
|
multichar_quotes = quotes.split(':') |
||||||
|
if len(multichar_quotes) == 4: |
||||||
|
quotes = multichar_quotes |
||||||
|
elif len(quotes) != 4: |
||||||
|
raise ValueError('Invalid value "%s". Please specify 4 quotes\n' |
||||||
|
' (primary open/close; secondary open/close).' |
||||||
|
% item.encode('ascii', 'backslashreplace')) |
||||||
|
lc_quotes.append((lang,quotes)) |
||||||
|
return lc_quotes |
||||||
|
|
||||||
|
def make_paths_absolute(pathdict, keys, base_path=None): |
||||||
|
""" |
||||||
|
Interpret filesystem path settings relative to the `base_path` given. |
||||||
|
|
||||||
|
Paths are values in `pathdict` whose keys are in `keys`. Get `keys` from |
||||||
|
`OptionParser.relative_path_settings`. |
||||||
|
""" |
||||||
|
if base_path is None: |
||||||
|
base_path = os.getcwdu() # type(base_path) == unicode |
||||||
|
# to allow combining non-ASCII cwd with unicode values in `pathdict` |
||||||
|
for key in keys: |
||||||
|
if key in pathdict: |
||||||
|
value = pathdict[key] |
||||||
|
if isinstance(value, list): |
||||||
|
value = [make_one_path_absolute(base_path, path) |
||||||
|
for path in value] |
||||||
|
elif value: |
||||||
|
value = make_one_path_absolute(base_path, value) |
||||||
|
pathdict[key] = value |
||||||
|
|
||||||
|
def make_one_path_absolute(base_path, path): |
||||||
|
return os.path.abspath(os.path.join(base_path, path)) |
||||||
|
|
||||||
|
def filter_settings_spec(settings_spec, *exclude, **replace): |
||||||
|
"""Return a copy of `settings_spec` excluding/replacing some settings. |
||||||
|
|
||||||
|
`settings_spec` is a tuple of configuration settings with a structure |
||||||
|
described for docutils.SettingsSpec.settings_spec. |
||||||
|
|
||||||
|
Optional positional arguments are names of to-be-excluded settings. |
||||||
|
Keyword arguments are option specification replacements. |
||||||
|
(See the html4strict writer for an example.) |
||||||
|
""" |
||||||
|
settings = list(settings_spec) |
||||||
|
# every third item is a sequence of option tuples |
||||||
|
for i in range(2, len(settings), 3): |
||||||
|
newopts = [] |
||||||
|
for opt_spec in settings[i]: |
||||||
|
# opt_spec is ("<help>", [<option strings>], {<keyword args>}) |
||||||
|
opt_name = [opt_string[2:].replace('-', '_') |
||||||
|
for opt_string in opt_spec[1] |
||||||
|
if opt_string.startswith('--') |
||||||
|
][0] |
||||||
|
if opt_name in exclude: |
||||||
|
continue |
||||||
|
if opt_name in replace.keys(): |
||||||
|
newopts.append(replace[opt_name]) |
||||||
|
else: |
||||||
|
newopts.append(opt_spec) |
||||||
|
settings[i] = tuple(newopts) |
||||||
|
return tuple(settings) |
||||||
|
|
||||||
|
|
||||||
|
class Values(optparse.Values): |
||||||
|
|
||||||
|
""" |
||||||
|
Updates list attributes by extension rather than by replacement. |
||||||
|
Works in conjunction with the `OptionParser.lists` instance attribute. |
||||||
|
""" |
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs): |
||||||
|
optparse.Values.__init__(self, *args, **kwargs) |
||||||
|
if (not hasattr(self, 'record_dependencies') |
||||||
|
or self.record_dependencies is None): |
||||||
|
# Set up dependency list, in case it is needed. |
||||||
|
self.record_dependencies = docutils.utils.DependencyList() |
||||||
|
|
||||||
|
def update(self, other_dict, option_parser): |
||||||
|
if isinstance(other_dict, Values): |
||||||
|
other_dict = other_dict.__dict__ |
||||||
|
other_dict = other_dict.copy() |
||||||
|
for setting in option_parser.lists.keys(): |
||||||
|
if (hasattr(self, setting) and setting in other_dict): |
||||||
|
value = getattr(self, setting) |
||||||
|
if value: |
||||||
|
value += other_dict[setting] |
||||||
|
del other_dict[setting] |
||||||
|
self._update_loose(other_dict) |
||||||
|
|
||||||
|
def copy(self): |
||||||
|
"""Return a shallow copy of `self`.""" |
||||||
|
return self.__class__(defaults=self.__dict__) |
||||||
|
|
||||||
|
|
||||||
|
class Option(optparse.Option): |
||||||
|
|
||||||
|
ATTRS = optparse.Option.ATTRS + ['validator', 'overrides'] |
||||||
|
|
||||||
|
def process(self, opt, value, values, parser): |
||||||
|
""" |
||||||
|
Call the validator function on applicable settings and |
||||||
|
evaluate the 'overrides' option. |
||||||
|
Extends `optparse.Option.process`. |
||||||
|
""" |
||||||
|
result = optparse.Option.process(self, opt, value, values, parser) |
||||||
|
setting = self.dest |
||||||
|
if setting: |
||||||
|
if self.validator: |
||||||
|
value = getattr(values, setting) |
||||||
|
try: |
||||||
|
new_value = self.validator(setting, value, parser) |
||||||
|
except Exception, error: |
||||||
|
raise (optparse.OptionValueError( |
||||||
|
'Error in option "%s":\n %s' |
||||||
|
% (opt, ErrorString(error))), |
||||||
|
None, sys.exc_info()[2]) |
||||||
|
setattr(values, setting, new_value) |
||||||
|
if self.overrides: |
||||||
|
setattr(values, self.overrides, None) |
||||||
|
return result |
||||||
|
|
||||||
|
|
||||||
|
class OptionParser(optparse.OptionParser, docutils.SettingsSpec): |
||||||
|
|
||||||
|
""" |
||||||
|
Parser for command-line and library use. The `settings_spec` |
||||||
|
specification here and in other Docutils components are merged to build |
||||||
|
the set of command-line options and runtime settings for this process. |
||||||
|
|
||||||
|
Common settings (defined below) and component-specific settings must not |
||||||
|
conflict. Short options are reserved for common settings, and components |
||||||
|
are restrict to using long options. |
||||||
|
""" |
||||||
|
|
||||||
|
standard_config_files = [ |
||||||
|
'/etc/docutils.conf', # system-wide |
||||||
|
'./docutils.conf', # project-specific |
||||||
|
'~/.docutils'] # user-specific |
||||||
|
"""Docutils configuration files, using ConfigParser syntax. Filenames |
||||||
|
will be tilde-expanded later. Later files override earlier ones.""" |
||||||
|
|
||||||
|
threshold_choices = 'info 1 warning 2 error 3 severe 4 none 5'.split() |
||||||
|
"""Possible inputs for for --report and --halt threshold values.""" |
||||||
|
|
||||||
|
thresholds = {'info': 1, 'warning': 2, 'error': 3, 'severe': 4, 'none': 5} |
||||||
|
"""Lookup table for --report and --halt threshold values.""" |
||||||
|
|
||||||
|
booleans={'1': True, 'on': True, 'yes': True, 'true': True, |
||||||
|
'0': False, 'off': False, 'no': False, 'false': False, '': False} |
||||||
|
"""Lookup table for boolean configuration file settings.""" |
||||||
|
|
||||||
|
default_error_encoding = getattr(sys.stderr, 'encoding', |
||||||
|
None) or locale_encoding or 'ascii' |
||||||
|
|
||||||
|
default_error_encoding_error_handler = 'backslashreplace' |
||||||
|
|
||||||
|
settings_spec = ( |
||||||
|
'General Docutils Options', |
||||||
|
None, |
||||||
|
(('Specify the document title as metadata.', |
||||||
|
['--title'], {}), |
||||||
|
('Include a "Generated by Docutils" credit and link.', |
||||||
|
['--generator', '-g'], {'action': 'store_true', |
||||||
|
'validator': validate_boolean}), |
||||||
|
('Do not include a generator credit.', |
||||||
|
['--no-generator'], {'action': 'store_false', 'dest': 'generator'}), |
||||||
|
('Include the date at the end of the document (UTC).', |
||||||
|
['--date', '-d'], {'action': 'store_const', 'const': '%Y-%m-%d', |
||||||
|
'dest': 'datestamp'}), |
||||||
|
('Include the time & date (UTC).', |
||||||
|
['--time', '-t'], {'action': 'store_const', |
||||||
|
'const': '%Y-%m-%d %H:%M UTC', |
||||||
|
'dest': 'datestamp'}), |
||||||
|
('Do not include a datestamp of any kind.', |
||||||
|
['--no-datestamp'], {'action': 'store_const', 'const': None, |
||||||
|
'dest': 'datestamp'}), |
||||||
|
('Include a "View document source" link.', |
||||||
|
['--source-link', '-s'], {'action': 'store_true', |
||||||
|
'validator': validate_boolean}), |
||||||
|
('Use <URL> for a source link; implies --source-link.', |
||||||
|
['--source-url'], {'metavar': '<URL>'}), |
||||||
|
('Do not include a "View document source" link.', |
||||||
|
['--no-source-link'], |
||||||
|
{'action': 'callback', 'callback': store_multiple, |
||||||
|
'callback_args': ('source_link', 'source_url')}), |
||||||
|
('Link from section headers to TOC entries. (default)', |
||||||
|
['--toc-entry-backlinks'], |
||||||
|
{'dest': 'toc_backlinks', 'action': 'store_const', 'const': 'entry', |
||||||
|
'default': 'entry'}), |
||||||
|
('Link from section headers to the top of the TOC.', |
||||||
|
['--toc-top-backlinks'], |
||||||
|
{'dest': 'toc_backlinks', 'action': 'store_const', 'const': 'top'}), |
||||||
|
('Disable backlinks to the table of contents.', |
||||||
|
['--no-toc-backlinks'], |
||||||
|
{'dest': 'toc_backlinks', 'action': 'store_false'}), |
||||||
|
('Link from footnotes/citations to references. (default)', |
||||||
|
['--footnote-backlinks'], |
||||||
|
{'action': 'store_true', 'default': 1, |
||||||
|
'validator': validate_boolean}), |
||||||
|
('Disable backlinks from footnotes and citations.', |
||||||
|
['--no-footnote-backlinks'], |
||||||
|
{'dest': 'footnote_backlinks', 'action': 'store_false'}), |
||||||
|
('Enable section numbering by Docutils. (default)', |
||||||
|
['--section-numbering'], |
||||||
|
{'action': 'store_true', 'dest': 'sectnum_xform', |
||||||
|
'default': 1, 'validator': validate_boolean}), |
||||||
|
('Disable section numbering by Docutils.', |
||||||
|
['--no-section-numbering'], |
||||||
|
{'action': 'store_false', 'dest': 'sectnum_xform'}), |
||||||
|
('Remove comment elements from the document tree.', |
||||||
|
['--strip-comments'], |
||||||
|
{'action': 'store_true', 'validator': validate_boolean}), |
||||||
|
('Leave comment elements in the document tree. (default)', |
||||||
|
['--leave-comments'], |
||||||
|
{'action': 'store_false', 'dest': 'strip_comments'}), |
||||||
|
('Remove all elements with classes="<class>" from the document tree. ' |
||||||
|
'Warning: potentially dangerous; use with caution. ' |
||||||
|
'(Multiple-use option.)', |
||||||
|
['--strip-elements-with-class'], |
||||||
|
{'action': 'append', 'dest': 'strip_elements_with_classes', |
||||||
|
'metavar': '<class>', 'validator': validate_strip_class}), |
||||||
|
('Remove all classes="<class>" attributes from elements in the ' |
||||||
|
'document tree. Warning: potentially dangerous; use with caution. ' |
||||||
|
'(Multiple-use option.)', |
||||||
|
['--strip-class'], |
||||||
|
{'action': 'append', 'dest': 'strip_classes', |
||||||
|
'metavar': '<class>', 'validator': validate_strip_class}), |
||||||
|
('Report system messages at or higher than <level>: "info" or "1", ' |
||||||
|
'"warning"/"2" (default), "error"/"3", "severe"/"4", "none"/"5"', |
||||||
|
['--report', '-r'], {'choices': threshold_choices, 'default': 2, |
||||||
|
'dest': 'report_level', 'metavar': '<level>', |
||||||
|
'validator': validate_threshold}), |
||||||
|
('Report all system messages. (Same as "--report=1".)', |
||||||
|
['--verbose', '-v'], {'action': 'store_const', 'const': 1, |
||||||
|
'dest': 'report_level'}), |
||||||
|
('Report no system messages. (Same as "--report=5".)', |
||||||
|
['--quiet', '-q'], {'action': 'store_const', 'const': 5, |
||||||
|
'dest': 'report_level'}), |
||||||
|
('Halt execution at system messages at or above <level>. ' |
||||||
|
'Levels as in --report. Default: 4 (severe).', |
||||||
|
['--halt'], {'choices': threshold_choices, 'dest': 'halt_level', |
||||||
|
'default': 4, 'metavar': '<level>', |
||||||
|
'validator': validate_threshold}), |
||||||
|
('Halt at the slightest problem. Same as "--halt=info".', |
||||||
|
['--strict'], {'action': 'store_const', 'const': 1, |
||||||
|
'dest': 'halt_level'}), |
||||||
|
('Enable a non-zero exit status for non-halting system messages at ' |
||||||
|
'or above <level>. Default: 5 (disabled).', |
||||||
|
['--exit-status'], {'choices': threshold_choices, |
||||||
|
'dest': 'exit_status_level', |
||||||
|
'default': 5, 'metavar': '<level>', |
||||||
|
'validator': validate_threshold}), |
||||||
|
('Enable debug-level system messages and diagnostics.', |
||||||
|
['--debug'], {'action': 'store_true', 'validator': validate_boolean}), |
||||||
|
('Disable debug output. (default)', |
||||||
|
['--no-debug'], {'action': 'store_false', 'dest': 'debug'}), |
||||||
|
('Send the output of system messages to <file>.', |
||||||
|
['--warnings'], {'dest': 'warning_stream', 'metavar': '<file>'}), |
||||||
|
('Enable Python tracebacks when Docutils is halted.', |
||||||
|
['--traceback'], {'action': 'store_true', 'default': None, |
||||||
|
'validator': validate_boolean}), |
||||||
|
('Disable Python tracebacks. (default)', |
||||||
|
['--no-traceback'], {'dest': 'traceback', 'action': 'store_false'}), |
||||||
|
('Specify the encoding and optionally the ' |
||||||
|
'error handler of input text. Default: <locale-dependent>:strict.', |
||||||
|
['--input-encoding', '-i'], |
||||||
|
{'metavar': '<name[:handler]>', |
||||||
|
'validator': validate_encoding_and_error_handler}), |
||||||
|
('Specify the error handler for undecodable characters. ' |
||||||
|
'Choices: "strict" (default), "ignore", and "replace".', |
||||||
|
['--input-encoding-error-handler'], |
||||||
|
{'default': 'strict', 'validator': validate_encoding_error_handler}), |
||||||
|
('Specify the text encoding and optionally the error handler for ' |
||||||
|
'output. Default: UTF-8:strict.', |
||||||
|
['--output-encoding', '-o'], |
||||||
|
{'metavar': '<name[:handler]>', 'default': 'utf-8', |
||||||
|
'validator': validate_encoding_and_error_handler}), |
||||||
|
('Specify error handler for unencodable output characters; ' |
||||||
|
'"strict" (default), "ignore", "replace", ' |
||||||
|
'"xmlcharrefreplace", "backslashreplace".', |
||||||
|
['--output-encoding-error-handler'], |
||||||
|
{'default': 'strict', 'validator': validate_encoding_error_handler}), |
||||||
|
('Specify text encoding and error handler for error output. ' |
||||||
|
'Default: %s:%s.' |
||||||
|
% (default_error_encoding, default_error_encoding_error_handler), |
||||||
|
['--error-encoding', '-e'], |
||||||
|
{'metavar': '<name[:handler]>', 'default': default_error_encoding, |
||||||
|
'validator': validate_encoding_and_error_handler}), |
||||||
|
('Specify the error handler for unencodable characters in ' |
||||||
|
'error output. Default: %s.' |
||||||
|
% default_error_encoding_error_handler, |
||||||
|
['--error-encoding-error-handler'], |
||||||
|
{'default': default_error_encoding_error_handler, |
||||||
|
'validator': validate_encoding_error_handler}), |
||||||
|
('Specify the language (as BCP 47 language tag). Default: en.', |
||||||
|
['--language', '-l'], {'dest': 'language_code', 'default': 'en', |
||||||
|
'metavar': '<name>'}), |
||||||
|
('Write output file dependencies to <file>.', |
||||||
|
['--record-dependencies'], |
||||||
|
{'metavar': '<file>', 'validator': validate_dependency_file, |
||||||
|
'default': None}), # default set in Values class |
||||||
|
('Read configuration settings from <file>, if it exists.', |
||||||
|
['--config'], {'metavar': '<file>', 'type': 'string', |
||||||
|
'action': 'callback', 'callback': read_config_file}), |
||||||
|
("Show this program's version number and exit.", |
||||||
|
['--version', '-V'], {'action': 'version'}), |
||||||
|
('Show this help message and exit.', |
||||||
|
['--help', '-h'], {'action': 'help'}), |
||||||
|
# Typically not useful for non-programmatical use: |
||||||
|
(SUPPRESS_HELP, ['--id-prefix'], {'default': ''}), |
||||||
|
(SUPPRESS_HELP, ['--auto-id-prefix'], {'default': 'id'}), |
||||||
|
# Hidden options, for development use only: |
||||||
|
(SUPPRESS_HELP, ['--dump-settings'], {'action': 'store_true'}), |
||||||
|
(SUPPRESS_HELP, ['--dump-internals'], {'action': 'store_true'}), |
||||||
|
(SUPPRESS_HELP, ['--dump-transforms'], {'action': 'store_true'}), |
||||||
|
(SUPPRESS_HELP, ['--dump-pseudo-xml'], {'action': 'store_true'}), |
||||||
|
(SUPPRESS_HELP, ['--expose-internal-attribute'], |
||||||
|
{'action': 'append', 'dest': 'expose_internals', |
||||||
|
'validator': validate_colon_separated_string_list}), |
||||||
|
(SUPPRESS_HELP, ['--strict-visitor'], {'action': 'store_true'}), |
||||||
|
)) |
||||||
|
"""Runtime settings and command-line options common to all Docutils front |
||||||
|
ends. Setting specs specific to individual Docutils components are also |
||||||
|
used (see `populate_from_components()`).""" |
||||||
|
|
||||||
|
settings_defaults = {'_disable_config': None, |
||||||
|
'_source': None, |
||||||
|
'_destination': None, |
||||||
|
'_config_files': None} |
||||||
|
"""Defaults for settings that don't have command-line option equivalents.""" |
||||||
|
|
||||||
|
relative_path_settings = ('warning_stream',) |
||||||
|
|
||||||
|
config_section = 'general' |
||||||
|
|
||||||
|
version_template = ('%%prog (Docutils %s%s, Python %s, on %s)' |
||||||
|
% (docutils.__version__, |
||||||
|
docutils.__version_details__ and |
||||||
|
' [%s]'%docutils.__version_details__ or '', |
||||||
|
sys.version.split()[0], sys.platform)) |
||||||
|
"""Default version message.""" |
||||||
|
|
||||||
|
def __init__(self, components=(), defaults=None, read_config_files=None, |
||||||
|
*args, **kwargs): |
||||||
|
""" |
||||||
|
`components` is a list of Docutils components each containing a |
||||||
|
``.settings_spec`` attribute. `defaults` is a mapping of setting |
||||||
|
default overrides. |
||||||
|
""" |
||||||
|
|
||||||
|
self.lists = {} |
||||||
|
"""Set of list-type settings.""" |
||||||
|
|
||||||
|
self.config_files = [] |
||||||
|
"""List of paths of applied configuration files.""" |
||||||
|
|
||||||
|
optparse.OptionParser.__init__( |
||||||
|
self, option_class=Option, add_help_option=None, |
||||||
|
formatter=optparse.TitledHelpFormatter(width=78), |
||||||
|
*args, **kwargs) |
||||||
|
if not self.version: |
||||||
|
self.version = self.version_template |
||||||
|
# Make an instance copy (it will be modified): |
||||||
|
self.relative_path_settings = list(self.relative_path_settings) |
||||||
|
self.components = (self,) + tuple(components) |
||||||
|
self.populate_from_components(self.components) |
||||||
|
self.set_defaults_from_dict(defaults or {}) |
||||||
|
if read_config_files and not self.defaults['_disable_config']: |
||||||
|
try: |
||||||
|
config_settings = self.get_standard_config_settings() |
||||||
|
except ValueError, error: |
||||||
|
self.error(SafeString(error)) |
||||||
|
self.set_defaults_from_dict(config_settings.__dict__) |
||||||
|
|
||||||
|
def populate_from_components(self, components): |
||||||
|
""" |
||||||
|
For each component, first populate from the `SettingsSpec.settings_spec` |
||||||
|
structure, then from the `SettingsSpec.settings_defaults` dictionary. |
||||||
|
After all components have been processed, check for and populate from |
||||||
|
each component's `SettingsSpec.settings_default_overrides` dictionary. |
||||||
|
""" |
||||||
|
for component in components: |
||||||
|
if component is None: |
||||||
|
continue |
||||||
|
settings_spec = component.settings_spec |
||||||
|
self.relative_path_settings.extend( |
||||||
|
component.relative_path_settings) |
||||||
|
for i in range(0, len(settings_spec), 3): |
||||||
|
title, description, option_spec = settings_spec[i:i+3] |
||||||
|
if title: |
||||||
|
group = optparse.OptionGroup(self, title, description) |
||||||
|
self.add_option_group(group) |
||||||
|
else: |
||||||
|
group = self # single options |
||||||
|
for (help_text, option_strings, kwargs) in option_spec: |
||||||
|
option = group.add_option(help=help_text, *option_strings, |
||||||
|
**kwargs) |
||||||
|
if kwargs.get('action') == 'append': |
||||||
|
self.lists[option.dest] = 1 |
||||||
|
if component.settings_defaults: |
||||||
|
self.defaults.update(component.settings_defaults) |
||||||
|
for component in components: |
||||||
|
if component and component.settings_default_overrides: |
||||||
|
self.defaults.update(component.settings_default_overrides) |
||||||
|
|
||||||
|
def get_standard_config_files(self): |
||||||
|
"""Return list of config files, from environment or standard.""" |
||||||
|
try: |
||||||
|
config_files = os.environ['DOCUTILSCONFIG'].split(os.pathsep) |
||||||
|
except KeyError: |
||||||
|
config_files = self.standard_config_files |
||||||
|
|
||||||
|
# If 'HOME' is not set, expandvars() requires the 'pwd' module which is |
||||||
|
# not available under certain environments, for example, within |
||||||
|
# mod_python. The publisher ends up in here, and we need to publish |
||||||
|
# from within mod_python. Therefore we need to avoid expanding when we |
||||||
|
# are in those environments. |
||||||
|
expand = os.path.expanduser |
||||||
|
if 'HOME' not in os.environ: |
||||||
|
try: |
||||||
|
import pwd |
||||||
|
except ImportError: |
||||||
|
expand = lambda x: x |
||||||
|
return [expand(f) for f in config_files if f.strip()] |
||||||
|
|
||||||
|
def get_standard_config_settings(self): |
||||||
|
settings = Values() |
||||||
|
for filename in self.get_standard_config_files(): |
||||||
|
settings.update(self.get_config_file_settings(filename), self) |
||||||
|
return settings |
||||||
|
|
||||||
|
def get_config_file_settings(self, config_file): |
||||||
|
"""Returns a dictionary containing appropriate config file settings.""" |
||||||
|
parser = ConfigParser() |
||||||
|
parser.read(config_file, self) |
||||||
|
self.config_files.extend(parser._files) |
||||||
|
base_path = os.path.dirname(config_file) |
||||||
|
applied = {} |
||||||
|
settings = Values() |
||||||
|
for component in self.components: |
||||||
|
if not component: |
||||||
|
continue |
||||||
|
for section in (tuple(component.config_section_dependencies or ()) |
||||||
|
+ (component.config_section,)): |
||||||
|
if section in applied: |
||||||
|
continue |
||||||
|
applied[section] = 1 |
||||||
|
settings.update(parser.get_section(section), self) |
||||||
|
make_paths_absolute( |
||||||
|
settings.__dict__, self.relative_path_settings, base_path) |
||||||
|
return settings.__dict__ |
||||||
|
|
||||||
|
def check_values(self, values, args): |
||||||
|
"""Store positional arguments as runtime settings.""" |
||||||
|
values._source, values._destination = self.check_args(args) |
||||||
|
make_paths_absolute(values.__dict__, self.relative_path_settings) |
||||||
|
values._config_files = self.config_files |
||||||
|
return values |
||||||
|
|
||||||
|
def check_args(self, args): |
||||||
|
source = destination = None |
||||||
|
if args: |
||||||
|
source = args.pop(0) |
||||||
|
if source == '-': # means stdin |
||||||
|
source = None |
||||||
|
if args: |
||||||
|
destination = args.pop(0) |
||||||
|
if destination == '-': # means stdout |
||||||
|
destination = None |
||||||
|
if args: |
||||||
|
self.error('Maximum 2 arguments allowed.') |
||||||
|
if source and source == destination: |
||||||
|
self.error('Do not specify the same file for both source and ' |
||||||
|
'destination. It will clobber the source file.') |
||||||
|
return source, destination |
||||||
|
|
||||||
|
def set_defaults_from_dict(self, defaults): |
||||||
|
self.defaults.update(defaults) |
||||||
|
|
||||||
|
def get_default_values(self): |
||||||
|
"""Needed to get custom `Values` instances.""" |
||||||
|
defaults = Values(self.defaults) |
||||||
|
defaults._config_files = self.config_files |
||||||
|
return defaults |
||||||
|
|
||||||
|
def get_option_by_dest(self, dest): |
||||||
|
""" |
||||||
|
Get an option by its dest. |
||||||
|
|
||||||
|
If you're supplying a dest which is shared by several options, |
||||||
|
it is undefined which option of those is returned. |
||||||
|
|
||||||
|
A KeyError is raised if there is no option with the supplied |
||||||
|
dest. |
||||||
|
""" |
||||||
|
for group in self.option_groups + [self]: |
||||||
|
for option in group.option_list: |
||||||
|
if option.dest == dest: |
||||||
|
return option |
||||||
|
raise KeyError('No option with dest == %r.' % dest) |
||||||
|
|
||||||
|
|
||||||
|
class ConfigParser(CP.RawConfigParser): |
||||||
|
|
||||||
|
old_settings = { |
||||||
|
'pep_stylesheet': ('pep_html writer', 'stylesheet'), |
||||||
|
'pep_stylesheet_path': ('pep_html writer', 'stylesheet_path'), |
||||||
|
'pep_template': ('pep_html writer', 'template')} |
||||||
|
"""{old setting: (new section, new setting)} mapping, used by |
||||||
|
`handle_old_config`, to convert settings from the old [options] section.""" |
||||||
|
|
||||||
|
old_warning = """ |
||||||
|
The "[option]" section is deprecated. Support for old-format configuration |
||||||
|
files may be removed in a future Docutils release. Please revise your |
||||||
|
configuration files. See <http://docutils.sf.net/docs/user/config.html>, |
||||||
|
section "Old-Format Configuration Files". |
||||||
|
""" |
||||||
|
|
||||||
|
not_utf8_error = """\ |
||||||
|
Unable to read configuration file "%s": content not encoded as UTF-8. |
||||||
|
Skipping "%s" configuration file. |
||||||
|
""" |
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs): |
||||||
|
CP.RawConfigParser.__init__(self, *args, **kwargs) |
||||||
|
|
||||||
|
self._files = [] |
||||||
|
"""List of paths of configuration files read.""" |
||||||
|
|
||||||
|
self._stderr = ErrorOutput() |
||||||
|
"""Wrapper around sys.stderr catching en-/decoding errors""" |
||||||
|
|
||||||
|
def read(self, filenames, option_parser): |
||||||
|
if type(filenames) in (str, unicode): |
||||||
|
filenames = [filenames] |
||||||
|
for filename in filenames: |
||||||
|
try: |
||||||
|
# Config files must be UTF-8-encoded: |
||||||
|
fp = codecs.open(filename, 'r', 'utf-8') |
||||||
|
except IOError: |
||||||
|
continue |
||||||
|
try: |
||||||
|
if sys.version_info < (3,2): |
||||||
|
CP.RawConfigParser.readfp(self, fp, filename) |
||||||
|
else: |
||||||
|
CP.RawConfigParser.read_file(self, fp, filename) |
||||||
|
except UnicodeDecodeError: |
||||||
|
self._stderr.write(self.not_utf8_error % (filename, filename)) |
||||||
|
fp.close() |
||||||
|
continue |
||||||
|
fp.close() |
||||||
|
self._files.append(filename) |
||||||
|
if self.has_section('options'): |
||||||
|
self.handle_old_config(filename) |
||||||
|
self.validate_settings(filename, option_parser) |
||||||
|
|
||||||
|
def handle_old_config(self, filename): |
||||||
|
warnings.warn_explicit(self.old_warning, ConfigDeprecationWarning, |
||||||
|
filename, 0) |
||||||
|
options = self.get_section('options') |
||||||
|
if not self.has_section('general'): |
||||||
|
self.add_section('general') |
||||||
|
for key, value in options.items(): |
||||||
|
if key in self.old_settings: |
||||||
|
section, setting = self.old_settings[key] |
||||||
|
if not self.has_section(section): |
||||||
|
self.add_section(section) |
||||||
|
else: |
||||||
|
section = 'general' |
||||||
|
setting = key |
||||||
|
if not self.has_option(section, setting): |
||||||
|
self.set(section, setting, value) |
||||||
|
self.remove_section('options') |
||||||
|
|
||||||
|
def validate_settings(self, filename, option_parser): |
||||||
|
""" |
||||||
|
Call the validator function and implement overrides on all applicable |
||||||
|
settings. |
||||||
|
""" |
||||||
|
for section in self.sections(): |
||||||
|
for setting in self.options(section): |
||||||
|
try: |
||||||
|
option = option_parser.get_option_by_dest(setting) |
||||||
|
except KeyError: |
||||||
|
continue |
||||||
|
if option.validator: |
||||||
|
value = self.get(section, setting) |
||||||
|
try: |
||||||
|
new_value = option.validator( |
||||||
|
setting, value, option_parser, |
||||||
|
config_parser=self, config_section=section) |
||||||
|
except Exception, error: |
||||||
|
raise (ValueError( |
||||||
|
'Error in config file "%s", section "[%s]":\n' |
||||||
|
' %s\n' |
||||||
|
' %s = %s' |
||||||
|
% (filename, section, ErrorString(error), |
||||||
|
setting, value)), None, sys.exc_info()[2]) |
||||||
|
self.set(section, setting, new_value) |
||||||
|
if option.overrides: |
||||||
|
self.set(section, option.overrides, None) |
||||||
|
|
||||||
|
def optionxform(self, optionstr): |
||||||
|
""" |
||||||
|
Transform '-' to '_' so the cmdline form of option names can be used. |
||||||
|
""" |
||||||
|
return optionstr.lower().replace('-', '_') |
||||||
|
|
||||||
|
def get_section(self, section): |
||||||
|
""" |
||||||
|
Return a given section as a dictionary (empty if the section |
||||||
|
doesn't exist). |
||||||
|
""" |
||||||
|
section_dict = {} |
||||||
|
if self.has_section(section): |
||||||
|
for option in self.options(section): |
||||||
|
section_dict[option] = self.get(section, option) |
||||||
|
return section_dict |
||||||
|
|
||||||
|
|
||||||
|
class ConfigDeprecationWarning(DeprecationWarning): |
||||||
|
"""Warning for deprecated configuration file features.""" |
@ -0,0 +1,490 @@ |
|||||||
|
# $Id: io.py 8129 2017-06-27 14:55:22Z grubert $ |
||||||
|
# Author: David Goodger <goodger@python.org> |
||||||
|
# Copyright: This module has been placed in the public domain. |
||||||
|
|
||||||
|
""" |
||||||
|
I/O classes provide a uniform API for low-level input and output. Subclasses |
||||||
|
exist for a variety of input/output mechanisms. |
||||||
|
""" |
||||||
|
|
||||||
|
__docformat__ = 'reStructuredText' |
||||||
|
|
||||||
|
import sys |
||||||
|
import os |
||||||
|
import re |
||||||
|
import codecs |
||||||
|
from docutils import TransformSpec |
||||||
|
from docutils._compat import b |
||||||
|
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput |
||||||
|
|
||||||
|
|
||||||
|
class InputError(IOError): pass |
||||||
|
class OutputError(IOError): pass |
||||||
|
|
||||||
|
def check_encoding(stream, encoding): |
||||||
|
"""Test, whether the encoding of `stream` matches `encoding`. |
||||||
|
|
||||||
|
Returns |
||||||
|
|
||||||
|
:None: if `encoding` or `stream.encoding` are not a valid encoding |
||||||
|
argument (e.g. ``None``) or `stream.encoding is missing. |
||||||
|
:True: if the encoding argument resolves to the same value as `encoding`, |
||||||
|
:False: if the encodings differ. |
||||||
|
""" |
||||||
|
try: |
||||||
|
return codecs.lookup(stream.encoding) == codecs.lookup(encoding) |
||||||
|
except (LookupError, AttributeError, TypeError): |
||||||
|
return None |
||||||
|
|
||||||
|
|
||||||
|
class Input(TransformSpec): |
||||||
|
|
||||||
|
""" |
||||||
|
Abstract base class for input wrappers. |
||||||
|
""" |
||||||
|
|
||||||
|
component_type = 'input' |
||||||
|
|
||||||
|
default_source_path = None |
||||||
|
|
||||||
|
def __init__(self, source=None, source_path=None, encoding=None, |
||||||
|
error_handler='strict'): |
||||||
|
self.encoding = encoding |
||||||
|
"""Text encoding for the input source.""" |
||||||
|
|
||||||
|
self.error_handler = error_handler |
||||||
|
"""Text decoding error handler.""" |
||||||
|
|
||||||
|
self.source = source |
||||||
|
"""The source of input data.""" |
||||||
|
|
||||||
|
self.source_path = source_path |
||||||
|
"""A text reference to the source.""" |
||||||
|
|
||||||
|
if not source_path: |
||||||
|
self.source_path = self.default_source_path |
||||||
|
|
||||||
|
self.successful_encoding = None |
||||||
|
"""The encoding that successfully decoded the source data.""" |
||||||
|
|
||||||
|
def __repr__(self): |
||||||
|
return '%s: source=%r, source_path=%r' % (self.__class__, self.source, |
||||||
|
self.source_path) |
||||||
|
|
||||||
|
def read(self): |
||||||
|
raise NotImplementedError |
||||||
|
|
||||||
|
def decode(self, data): |
||||||
|
""" |
||||||
|
Decode a string, `data`, heuristically. |
||||||
|
Raise UnicodeError if unsuccessful. |
||||||
|
|
||||||
|
The client application should call ``locale.setlocale`` at the |
||||||
|
beginning of processing:: |
||||||
|
|
||||||
|
locale.setlocale(locale.LC_ALL, '') |
||||||
|
""" |
||||||
|
if self.encoding and self.encoding.lower() == 'unicode': |
||||||
|
assert isinstance(data, unicode), ( |
||||||
|
'input encoding is "unicode" ' |
||||||
|
'but input is not a unicode object') |
||||||
|
if isinstance(data, unicode): |
||||||
|
# Accept unicode even if self.encoding != 'unicode'. |
||||||
|
return data |
||||||
|
if self.encoding: |
||||||
|
# We believe the user/application when the encoding is |
||||||
|
# explicitly given. |
||||||
|
encodings = [self.encoding] |
||||||
|
else: |
||||||
|
data_encoding = self.determine_encoding_from_data(data) |
||||||
|
if data_encoding: |
||||||
|
# If the data declares its encoding (explicitly or via a BOM), |
||||||
|
# we believe it. |
||||||
|
encodings = [data_encoding] |
||||||
|
else: |
||||||
|
# Apply heuristics only if no encoding is explicitly given and |
||||||
|
# no BOM found. Start with UTF-8, because that only matches |
||||||
|
# data that *IS* UTF-8: |
||||||
|
encodings = ['utf-8', 'latin-1'] |
||||||
|
if locale_encoding: |
||||||
|
encodings.insert(1, locale_encoding) |
||||||
|
for enc in encodings: |
||||||
|
try: |
||||||
|
decoded = unicode(data, enc, self.error_handler) |
||||||
|
self.successful_encoding = enc |
||||||
|
# Return decoded, removing BOMs. |
||||||
|
return decoded.replace(u'\ufeff', u'') |
||||||
|
except (UnicodeError, LookupError), err: |
||||||
|
error = err # in Python 3, the <exception instance> is |
||||||
|
# local to the except clause |
||||||
|
raise UnicodeError( |
||||||
|
'Unable to decode input data. Tried the following encodings: ' |
||||||
|
'%s.\n(%s)' % (', '.join([repr(enc) for enc in encodings]), |
||||||
|
ErrorString(error))) |
||||||
|
|
||||||
|
coding_slug = re.compile(b(r"coding[:=]\s*([-\w.]+)")) |
||||||
|
"""Encoding declaration pattern.""" |
||||||
|
|
||||||
|
byte_order_marks = ((codecs.BOM_UTF8, 'utf-8'), # 'utf-8-sig' new in v2.5 |
||||||
|
(codecs.BOM_UTF16_BE, 'utf-16-be'), |
||||||
|
(codecs.BOM_UTF16_LE, 'utf-16-le'),) |
||||||
|
"""Sequence of (start_bytes, encoding) tuples for encoding detection. |
||||||
|
The first bytes of input data are checked against the start_bytes strings. |
||||||
|
A match indicates the given encoding.""" |
||||||
|
|
||||||
|
def determine_encoding_from_data(self, data): |
||||||
|
""" |
||||||
|
Try to determine the encoding of `data` by looking *in* `data`. |
||||||
|
Check for a byte order mark (BOM) or an encoding declaration. |
||||||
|
""" |
||||||
|
# check for a byte order mark: |
||||||
|
for start_bytes, encoding in self.byte_order_marks: |
||||||
|
if data.startswith(start_bytes): |
||||||
|
return encoding |
||||||
|
# check for an encoding declaration pattern in first 2 lines of file: |
||||||
|
for line in data.splitlines()[:2]: |
||||||
|
match = self.coding_slug.search(line) |
||||||
|
if match: |
||||||
|
return match.group(1).decode('ascii') |
||||||
|
return None |
||||||
|
|
||||||
|
|
||||||
|
class Output(TransformSpec): |
||||||
|
|
||||||
|
""" |
||||||
|
Abstract base class for output wrappers. |
||||||
|
""" |
||||||
|
|
||||||
|
component_type = 'output' |
||||||
|
|
||||||
|
default_destination_path = None |
||||||
|
|
||||||
|
def __init__(self, destination=None, destination_path=None, |
||||||
|
encoding=None, error_handler='strict'): |
||||||
|
self.encoding = encoding |
||||||
|
"""Text encoding for the output destination.""" |
||||||
|
|
||||||
|
self.error_handler = error_handler or 'strict' |
||||||
|
"""Text encoding error handler.""" |
||||||
|
|
||||||
|
self.destination = destination |
||||||
|
"""The destination for output data.""" |
||||||
|
|
||||||
|
self.destination_path = destination_path |
||||||
|
"""A text reference to the destination.""" |
||||||
|
|
||||||
|
if not destination_path: |
||||||
|
self.destination_path = self.default_destination_path |
||||||
|
|
||||||
|
def __repr__(self): |
||||||
|
return ('%s: destination=%r, destination_path=%r' |
||||||
|
% (self.__class__, self.destination, self.destination_path)) |
||||||
|
|
||||||
|
def write(self, data): |
||||||
|
"""`data` is a Unicode string, to be encoded by `self.encode`.""" |
||||||
|
raise NotImplementedError |
||||||
|
|
||||||
|
def encode(self, data): |
||||||
|
if self.encoding and self.encoding.lower() == 'unicode': |
||||||
|
assert isinstance(data, unicode), ( |
||||||
|
'the encoding given is "unicode" but the output is not ' |
||||||
|
'a Unicode string') |
||||||
|
return data |
||||||
|
if not isinstance(data, unicode): |
||||||
|
# Non-unicode (e.g. bytes) output. |
||||||
|
return data |
||||||
|
else: |
||||||
|
return data.encode(self.encoding, self.error_handler) |
||||||
|
|
||||||
|
|
||||||
|
class FileInput(Input): |
||||||
|
|
||||||
|
""" |
||||||
|
Input for single, simple file-like objects. |
||||||
|
""" |
||||||
|
def __init__(self, source=None, source_path=None, |
||||||
|
encoding=None, error_handler='strict', |
||||||
|
autoclose=True, mode='rU', **kwargs): |
||||||
|
""" |
||||||
|
:Parameters: |
||||||
|
- `source`: either a file-like object (which is read directly), or |
||||||
|
`None` (which implies `sys.stdin` if no `source_path` given). |
||||||
|
- `source_path`: a path to a file, which is opened and then read. |
||||||
|
- `encoding`: the expected text encoding of the input file. |
||||||
|
- `error_handler`: the encoding error handler to use. |
||||||
|
- `autoclose`: close automatically after read (except when |
||||||
|
`sys.stdin` is the source). |
||||||
|
- `mode`: how the file is to be opened (see standard function |
||||||
|
`open`). The default 'rU' provides universal newline support |
||||||
|
for text files. |
||||||
|
""" |
||||||
|
Input.__init__(self, source, source_path, encoding, error_handler) |
||||||
|
self.autoclose = autoclose |
||||||
|
self._stderr = ErrorOutput() |
||||||
|
# deprecation warning |
||||||
|
for key in kwargs: |
||||||
|
if key == 'handle_io_errors': |
||||||
|
sys.stderr.write('deprecation warning: ' |
||||||
|
'io.FileInput() argument `handle_io_errors` ' |
||||||
|
'is ignored since "Docutils 0.10 (2012-12-16)" ' |
||||||
|
'and will soon be removed.') |
||||||
|
else: |
||||||
|
raise TypeError('__init__() got an unexpected keyword ' |
||||||
|
"argument '%s'" % key) |
||||||
|
|
||||||
|
if source is None: |
||||||
|
if source_path: |
||||||
|
# Specify encoding in Python 3 |
||||||
|
if sys.version_info >= (3,0): |
||||||
|
kwargs = {'encoding': self.encoding, |
||||||
|
'errors': self.error_handler} |
||||||
|
else: |
||||||
|
kwargs = {} |
||||||
|
|
||||||
|
try: |
||||||
|
self.source = open(source_path, mode, **kwargs) |
||||||
|
except IOError, error: |
||||||
|
raise InputError(error.errno, error.strerror, source_path) |
||||||
|
else: |
||||||
|
self.source = sys.stdin |
||||||
|
elif (sys.version_info >= (3,0) and |
||||||
|
check_encoding(self.source, self.encoding) is False): |
||||||
|
# TODO: re-open, warn or raise error? |
||||||
|
raise UnicodeError('Encoding clash: encoding given is "%s" ' |
||||||
|
'but source is opened with encoding "%s".' % |
||||||
|
(self.encoding, self.source.encoding)) |
||||||
|
if not source_path: |
||||||
|
try: |
||||||
|
self.source_path = self.source.name |
||||||
|
except AttributeError: |
||||||
|
pass |
||||||
|
|
||||||
|
def read(self): |
||||||
|
""" |
||||||
|
Read and decode a single file and return the data (Unicode string). |
||||||
|
""" |
||||||
|
try: # In Python < 2.5, try...except has to be nested in try...finally. |
||||||
|
try: |
||||||
|
if self.source is sys.stdin and sys.version_info >= (3,0): |
||||||
|
# read as binary data to circumvent auto-decoding |
||||||
|
data = self.source.buffer.read() |
||||||
|
# normalize newlines |
||||||
|
data = b('\n').join(data.splitlines()) + b('\n') |
||||||
|
else: |
||||||
|
data = self.source.read() |
||||||
|
except (UnicodeError, LookupError), err: # (in Py3k read() decodes) |
||||||
|
if not self.encoding and self.source_path: |
||||||
|
# re-read in binary mode and decode with heuristics |
||||||
|
b_source = open(self.source_path, 'rb') |
||||||
|
data = b_source.read() |
||||||
|
b_source.close() |
||||||
|
# normalize newlines |
||||||
|
data = b('\n').join(data.splitlines()) + b('\n') |
||||||
|
else: |
||||||
|
raise |
||||||
|
finally: |
||||||
|
if self.autoclose: |
||||||
|
self.close() |
||||||
|
return self.decode(data) |
||||||
|
|
||||||
|
def readlines(self): |
||||||
|
""" |
||||||
|
Return lines of a single file as list of Unicode strings. |
||||||
|
""" |
||||||
|
return self.read().splitlines(True) |
||||||
|
|
||||||
|
def close(self): |
||||||
|
if self.source is not sys.stdin: |
||||||
|
self.source.close() |
||||||
|
|
||||||
|
|
||||||
|
class FileOutput(Output): |
||||||
|
|
||||||
|
""" |
||||||
|
Output for single, simple file-like objects. |
||||||
|
""" |
||||||
|
|
||||||
|
mode = 'w' |
||||||
|
"""The mode argument for `open()`.""" |
||||||
|
# 'wb' for binary (e.g. OpenOffice) files (see also `BinaryFileOutput`). |
||||||
|
# (Do not use binary mode ('wb') for text files, as this prevents the |
||||||
|
# conversion of newlines to the system specific default.) |
||||||
|
|
||||||
|
def __init__(self, destination=None, destination_path=None, |
||||||
|
encoding=None, error_handler='strict', autoclose=True, |
||||||
|
handle_io_errors=None, mode=None): |
||||||
|
""" |
||||||
|
:Parameters: |
||||||
|
- `destination`: either a file-like object (which is written |
||||||
|
directly) or `None` (which implies `sys.stdout` if no |
||||||
|
`destination_path` given). |
||||||
|
- `destination_path`: a path to a file, which is opened and then |
||||||
|
written. |
||||||
|
- `encoding`: the text encoding of the output file. |
||||||
|
- `error_handler`: the encoding error handler to use. |
||||||
|
- `autoclose`: close automatically after write (except when |
||||||
|
`sys.stdout` or `sys.stderr` is the destination). |
||||||
|
- `handle_io_errors`: ignored, deprecated, will be removed. |
||||||
|
- `mode`: how the file is to be opened (see standard function |
||||||
|
`open`). The default is 'w', providing universal newline |
||||||
|
support for text files. |
||||||
|
""" |
||||||
|
Output.__init__(self, destination, destination_path, |
||||||
|
encoding, error_handler) |
||||||
|
self.opened = True |
||||||
|
self.autoclose = autoclose |
||||||
|
if mode is not None: |
||||||
|
self.mode = mode |
||||||
|
self._stderr = ErrorOutput() |
||||||
|
if destination is None: |
||||||
|
if destination_path: |
||||||
|
self.opened = False |
||||||
|
else: |
||||||
|
self.destination = sys.stdout |
||||||
|
elif (# destination is file-type object -> check mode: |
||||||
|
mode and hasattr(self.destination, 'mode') |
||||||
|
and mode != self.destination.mode): |
||||||
|
print >>self._stderr, ('Warning: Destination mode "%s" ' |
||||||
|
'differs from specified mode "%s"' % |
||||||
|
(self.destination.mode, mode)) |
||||||
|
if not destination_path: |
||||||
|
try: |
||||||
|
self.destination_path = self.destination.name |
||||||
|
except AttributeError: |
||||||
|
pass |
||||||
|
|
||||||
|
def open(self): |
||||||
|
# Specify encoding in Python 3. |
||||||
|
if sys.version_info >= (3,0) and 'b' not in self.mode: |
||||||
|
kwargs = {'encoding': self.encoding, |
||||||
|
'errors': self.error_handler} |
||||||
|
else: |
||||||
|
kwargs = {} |
||||||
|
try: |
||||||
|
self.destination = open(self.destination_path, self.mode, **kwargs) |
||||||
|
except IOError, error: |
||||||
|
raise OutputError(error.errno, error.strerror, |
||||||
|
self.destination_path) |
||||||
|
self.opened = True |
||||||
|
|
||||||
|
def write(self, data): |
||||||
|
"""Encode `data`, write it to a single file, and return it. |
||||||
|
|
||||||
|
With Python 3 or binary output mode, `data` is returned unchanged, |
||||||
|
except when specified encoding and output encoding differ. |
||||||
|
""" |
||||||
|
if not self.opened: |
||||||
|
self.open() |
||||||
|
if ('b' not in self.mode and sys.version_info < (3,0) |
||||||
|
or check_encoding(self.destination, self.encoding) is False |
||||||
|
): |
||||||
|
data = self.encode(data) |
||||||
|
if sys.version_info >= (3,0) and os.linesep != '\n': |
||||||
|
data = data.replace(b('\n'), b(os.linesep)) # fix endings |
||||||
|
|
||||||
|
try: # In Python < 2.5, try...except has to be nested in try...finally. |
||||||
|
try: |
||||||
|
self.destination.write(data) |
||||||
|
except TypeError, e: |
||||||
|
if sys.version_info >= (3,0) and isinstance(data, bytes): |
||||||
|
try: |
||||||
|
self.destination.buffer.write(data) |
||||||
|
except AttributeError: |
||||||
|
if check_encoding(self.destination, |
||||||
|
self.encoding) is False: |
||||||
|
raise ValueError('Encoding of %s (%s) differs \n' |
||||||
|
' from specified encoding (%s)' % |
||||||
|
(self.destination_path or 'destination', |
||||||
|
self.destination.encoding, self.encoding)) |
||||||
|
else: |
||||||
|
raise e |
||||||
|
except (UnicodeError, LookupError), err: |
||||||
|
raise UnicodeError( |
||||||
|
'Unable to encode output data. output-encoding is: ' |
||||||
|
'%s.\n(%s)' % (self.encoding, ErrorString(err))) |
||||||
|
finally: |
||||||
|
if self.autoclose: |
||||||
|
self.close() |
||||||
|
return data |
||||||
|
|
||||||
|
def close(self): |
||||||
|
if self.destination not in (sys.stdout, sys.stderr): |
||||||
|
self.destination.close() |
||||||
|
self.opened = False |
||||||
|
|
||||||
|
|
||||||
|
class BinaryFileOutput(FileOutput): |
||||||
|
""" |
||||||
|
A version of docutils.io.FileOutput which writes to a binary file. |
||||||
|
""" |
||||||
|
# Used by core.publish_cmdline_to_binary() which in turn is used by |
||||||
|
# rst2odt (OpenOffice writer) |
||||||
|
mode = 'wb' |
||||||
|
|
||||||
|
|
||||||
|
class StringInput(Input): |
||||||
|
|
||||||
|
""" |
||||||
|
Direct string input. |
||||||
|
""" |
||||||
|
|
||||||
|
default_source_path = '<string>' |
||||||
|
|
||||||
|
def read(self): |
||||||
|
"""Decode and return the source string.""" |
||||||
|
return self.decode(self.source) |
||||||
|
|
||||||
|
|
||||||
|
class StringOutput(Output): |
||||||
|
|
||||||
|
""" |
||||||
|
Direct string output. |
||||||
|
""" |
||||||
|
|
||||||
|
default_destination_path = '<string>' |
||||||
|
|
||||||
|
def write(self, data): |
||||||
|
"""Encode `data`, store it in `self.destination`, and return it.""" |
||||||
|
self.destination = self.encode(data) |
||||||
|
return self.destination |
||||||
|
|
||||||
|
|
||||||
|
class NullInput(Input): |
||||||
|
|
||||||
|
""" |
||||||
|
Degenerate input: read nothing. |
||||||
|
""" |
||||||
|
|
||||||
|
default_source_path = 'null input' |
||||||
|
|
||||||
|
def read(self): |
||||||
|
"""Return a null string.""" |
||||||
|
return u'' |
||||||
|
|
||||||
|
|
||||||
|
class NullOutput(Output): |
||||||
|
|
||||||
|
""" |
||||||
|
Degenerate output: write nothing. |
||||||
|
""" |
||||||
|
|
||||||
|
default_destination_path = 'null output' |
||||||
|
|
||||||
|
def write(self, data): |
||||||
|
"""Do nothing ([don't even] send data to the bit bucket).""" |
||||||
|
pass |
||||||
|
|
||||||
|
|
||||||
|
class DocTreeInput(Input): |
||||||
|
|
||||||
|
""" |
||||||
|
Adapter for document tree input. |
||||||
|
|
||||||
|
The document tree must be passed in the ``source`` parameter. |
||||||
|
""" |
||||||
|
|
||||||
|
default_source_path = 'doctree input' |
||||||
|
|
||||||
|
def read(self): |
||||||
|
"""Return the document tree.""" |
||||||
|
return self.source |
@ -0,0 +1,48 @@ |
|||||||
|
# $Id: __init__.py 7648 2013-04-18 07:36:22Z milde $ |
||||||
|
# Author: David Goodger <goodger@python.org> |
||||||
|
# Copyright: This module has been placed in the public domain. |
||||||
|
|
||||||
|
# Internationalization details are documented in |
||||||
|
# <http://docutils.sf.net/docs/howto/i18n.html>. |
||||||
|
|
||||||
|
""" |
||||||
|
This package contains modules for language-dependent features of Docutils. |
||||||
|
""" |
||||||
|
|
||||||
|
__docformat__ = 'reStructuredText' |
||||||
|
|
||||||
|
import sys |
||||||
|
|
||||||
|
from docutils.utils import normalize_language_tag |
||||||
|
if sys.version_info < (2,5): |
||||||
|
from docutils._compat import __import__ |
||||||
|
|
||||||
|
_languages = {} |
||||||
|
|
||||||
|
def get_language(language_code, reporter=None): |
||||||
|
"""Return module with language localizations. |
||||||
|
|
||||||
|
`language_code` is a "BCP 47" language tag. |
||||||
|
If there is no matching module, warn and fall back to English. |
||||||
|
""" |
||||||
|
# TODO: use a dummy module returning emtpy strings?, configurable? |
||||||
|
for tag in normalize_language_tag(language_code): |
||||||
|
tag = tag.replace('-','_') # '-' not valid in module names |
||||||
|
if tag in _languages: |
||||||
|
return _languages[tag] |
||||||
|
try: |
||||||
|
module = __import__(tag, globals(), locals(), level=1) |
||||||
|
except ImportError: |
||||||
|
try: |
||||||
|
module = __import__(tag, globals(), locals(), level=0) |
||||||
|
except ImportError: |
||||||
|
continue |
||||||
|
_languages[tag] = module |
||||||
|
return module |
||||||
|
if reporter is not None: |
||||||
|
reporter.warning( |
||||||
|
'language "%s" not supported: ' % language_code + |
||||||
|
'Docutils-generated text will be in English.') |
||||||
|
module = __import__('en', globals(), locals(), level=1) |
||||||
|
_languages[tag] = module # warn only one time! |
||||||
|
return module |
@ -0,0 +1,58 @@ |
|||||||
|
# $Id: af.py 4564 2006-05-21 20:44:42Z wiemann $ |
||||||
|
# Author: Jannie Hofmeyr <jhsh@sun.ac.za> |
||||||
|
# Copyright: This module has been placed in the public domain. |
||||||
|
|
||||||
|
# New language mappings are welcome. Before doing a new translation, please |
||||||
|
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be |
||||||
|
# translated for each language: one in docutils/languages, the other in |
||||||
|
# docutils/parsers/rst/languages. |
||||||
|
|
||||||
|
""" |
||||||
|
Afrikaans-language mappings for language-dependent features of Docutils. |
||||||
|
""" |
||||||
|
|
||||||
|
__docformat__ = 'reStructuredText' |
||||||
|
|
||||||
|
labels = { |
||||||
|
'author': 'Auteur', |
||||||
|
'authors': 'Auteurs', |
||||||
|
'organization': 'Organisasie', |
||||||
|
'address': 'Adres', |
||||||
|
'contact': 'Kontak', |
||||||
|
'version': 'Weergawe', |
||||||
|
'revision': 'Revisie', |
||||||
|
'status': 'Status', |
||||||
|
'date': 'Datum', |
||||||
|
'copyright': 'Kopiereg', |
||||||
|
'dedication': 'Opdrag', |
||||||
|
'abstract': 'Opsomming', |
||||||
|
'attention': 'Aandag!', |
||||||
|
'caution': 'Wees versigtig!', |
||||||
|
'danger': '!GEVAAR!', |
||||||
|
'error': 'Fout', |
||||||
|
'hint': 'Wenk', |
||||||
|
'important': 'Belangrik', |
||||||
|
'note': 'Nota', |
||||||
|
'tip': 'Tip', # hint and tip both have the same translation: wenk |
||||||
|
'warning': 'Waarskuwing', |
||||||
|
'contents': 'Inhoud'} |
||||||
|
"""Mapping of node class name to label text.""" |
||||||
|
|
||||||
|
bibliographic_fields = { |
||||||
|
'auteur': 'author', |
||||||
|
'auteurs': 'authors', |
||||||
|
'organisasie': 'organization', |
||||||
|
'adres': 'address', |
||||||
|
'kontak': 'contact', |
||||||
|
'weergawe': 'version', |
||||||
|
'revisie': 'revision', |
||||||
|
'status': 'status', |
||||||
|
'datum': 'date', |
||||||
|
'kopiereg': 'copyright', |
||||||
|
'opdrag': 'dedication', |
||||||
|
'opsomming': 'abstract'} |
||||||
|
"""Afrikaans (lowcased) to canonical name mapping for bibliographic fields.""" |
||||||
|
|
||||||
|
author_separators = [';', ','] |
||||||
|
"""List of separator strings for the 'Authors' bibliographic field. Tried in |
||||||
|
order.""" |
@ -0,0 +1,60 @@ |
|||||||
|
# $Id: ca.py 4564 2006-05-21 20:44:42Z wiemann $ |
||||||
|
# Author: Ivan Vilata i Balaguer <ivan@selidor.net> |
||||||
|
# Copyright: This module has been placed in the public domain. |
||||||
|
|
||||||
|
# New language mappings are welcome. Before doing a new translation, please |
||||||
|
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be |
||||||
|
# translated for each language: one in docutils/languages, the other in |
||||||
|
# docutils/parsers/rst/languages. |
||||||
|
|
||||||
|
""" |
||||||
|
Catalan-language mappings for language-dependent features of Docutils. |
||||||
|
""" |
||||||
|
|
||||||
|
__docformat__ = 'reStructuredText' |
||||||
|
|
||||||
|
labels = { |
||||||
|
# fixed: language-dependent |
||||||
|
'author': u'Autor', |
||||||
|
'authors': u'Autors', |
||||||
|
'organization': u'Organitzaci\u00F3', |
||||||
|
'address': u'Adre\u00E7a', |
||||||
|
'contact': u'Contacte', |
||||||
|
'version': u'Versi\u00F3', |
||||||
|
'revision': u'Revisi\u00F3', |
||||||
|
'status': u'Estat', |
||||||
|
'date': u'Data', |
||||||
|
'copyright': u'Copyright', |
||||||
|
'dedication': u'Dedicat\u00F2ria', |
||||||
|
'abstract': u'Resum', |
||||||
|
'attention': u'Atenci\u00F3!', |
||||||
|
'caution': u'Compte!', |
||||||
|
'danger': u'PERILL!', |
||||||
|
'error': u'Error', |
||||||
|
'hint': u'Suggeriment', |
||||||
|
'important': u'Important', |
||||||
|
'note': u'Nota', |
||||||
|
'tip': u'Consell', |
||||||
|
'warning': u'Av\u00EDs', |
||||||
|
'contents': u'Contingut'} |
||||||
|
"""Mapping of node class name to label text.""" |
||||||
|
|
||||||
|
bibliographic_fields = { |
||||||
|
# language-dependent: fixed |
||||||
|
u'autor': 'author', |
||||||
|
u'autors': 'authors', |
||||||
|
u'organitzaci\u00F3': 'organization', |
||||||
|
u'adre\u00E7a': 'address', |
||||||
|
u'contacte': 'contact', |
||||||
|
u'versi\u00F3': 'version', |
||||||
|
u'revisi\u00F3': 'revision', |
||||||
|
u'estat': 'status', |
||||||
|
u'data': 'date', |
||||||
|
u'copyright': 'copyright', |
||||||
|
u'dedicat\u00F2ria': 'dedication', |
||||||
|
u'resum': 'abstract'} |
||||||
|
"""Catalan (lowcased) to canonical name mapping for bibliographic fields.""" |
||||||
|
|
||||||
|
author_separators = [';', ','] |
||||||
|
"""List of separator strings for the 'Authors' bibliographic field. Tried in |
||||||
|
order.""" |
@ -0,0 +1,60 @@ |
|||||||
|
# $Id: cs.py 4564 2006-05-21 20:44:42Z wiemann $ |
||||||
|
# Author: Marek Blaha <mb@dat.cz> |
||||||
|
# Copyright: This module has been placed in the public domain. |
||||||
|
|
||||||
|
# New language mappings are welcome. Before doing a new translation, please |
||||||
|
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be |
||||||
|
# translated for each language: one in docutils/languages, the other in |
||||||
|
# docutils/parsers/rst/languages. |
||||||
|
|
||||||
|
""" |
||||||
|
Czech-language mappings for language-dependent features of Docutils. |
||||||
|
""" |
||||||
|
|
||||||
|
__docformat__ = 'reStructuredText' |
||||||
|
|
||||||
|
labels = { |
||||||
|
# fixed: language-dependent |
||||||
|
'author': u'Autor', |
||||||
|
'authors': u'Auto\u0159i', |
||||||
|
'organization': u'Organizace', |
||||||
|
'address': u'Adresa', |
||||||
|
'contact': u'Kontakt', |
||||||
|
'version': u'Verze', |
||||||
|
'revision': u'Revize', |
||||||
|
'status': u'Stav', |
||||||
|
'date': u'Datum', |
||||||
|
'copyright': u'Copyright', |
||||||
|
'dedication': u'V\u011Bnov\u00E1n\u00ED', |
||||||
|
'abstract': u'Abstrakt', |
||||||
|
'attention': u'Pozor!', |
||||||
|
'caution': u'Opatrn\u011B!', |
||||||
|
'danger': u'!NEBEZPE\u010C\u00CD!', |
||||||
|
'error': u'Chyba', |
||||||
|
'hint': u'Rada', |
||||||
|
'important': u'D\u016Fle\u017Eit\u00E9', |
||||||
|
'note': u'Pozn\u00E1mka', |
||||||
|
'tip': u'Tip', |
||||||
|
'warning': u'Varov\u00E1n\u00ED', |
||||||
|
'contents': u'Obsah'} |
||||||
|
"""Mapping of node class name to label text.""" |
||||||
|
|
||||||
|
bibliographic_fields = { |
||||||
|
# language-dependent: fixed |
||||||
|
u'autor': 'author', |
||||||
|
u'auto\u0159i': 'authors', |
||||||
|
u'organizace': 'organization', |
||||||
|
u'adresa': 'address', |
||||||
|
u'kontakt': 'contact', |
||||||
|
u'verze': 'version', |
||||||
|
u'revize': 'revision', |
||||||
|
u'stav': 'status', |
||||||
|
u'datum': 'date', |
||||||
|
u'copyright': 'copyright', |
||||||
|
u'v\u011Bnov\u00E1n\u00ED': 'dedication', |
||||||
|
u'abstrakt': 'abstract'} |
||||||
|
"""Czech (lowcased) to canonical name mapping for bibliographic fields.""" |
||||||
|
|
||||||
|
author_separators = [';', ','] |
||||||
|
"""List of separator strings for the 'Authors' bibliographic field. Tried in |
||||||
|
order.""" |
@ -0,0 +1,62 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
# $Id: da.py 7678 2013-07-03 09:57:36Z milde $ |
||||||
|
# Author: E D |
||||||
|
# Copyright: This module has been placed in the public domain. |
||||||
|
|
||||||
|
# New language mappings are welcome. Before doing a new translation, please |
||||||
|
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be |
||||||
|
# translated for each language: one in docutils/languages, the other in |
||||||
|
# docutils/parsers/rst/languages. |
||||||
|
|
||||||
|
""" |
||||||
|
Danish-language mappings for language-dependent features of Docutils. |
||||||
|
""" |
||||||
|
|
||||||
|
__docformat__ = 'reStructuredText' |
||||||
|
|
||||||
|
labels = { |
||||||
|
# fixed: language-dependent |
||||||
|
'author': u'Forfatter', |
||||||
|
'authors': u'Forfattere', |
||||||
|
'organization': u'Organisation', |
||||||
|
'address': u'Adresse', |
||||||
|
'contact': u'Kontakt', |
||||||
|
'version': u'Version', |
||||||
|
'revision': u'Revision', |
||||||
|
'status': u'Status', |
||||||
|
'date': u'Dato', |
||||||
|
'copyright': u'Copyright', |
||||||
|
'dedication': u'Dedikation', |
||||||
|
'abstract': u'Resumé', |
||||||
|
'attention': u'Giv agt!', |
||||||
|
'caution': u'Pas på!', |
||||||
|
'danger': u'!FARE!', |
||||||
|
'error': u'Fejl', |
||||||
|
'hint': u'Vink', |
||||||
|
'important': u'Vigtigt', |
||||||
|
'note': u'Bemærk', |
||||||
|
'tip': u'Tips', |
||||||
|
'warning': u'Advarsel', |
||||||
|
'contents': u'Indhold'} |
||||||
|
"""Mapping of node class name to label text.""" |
||||||
|
|
||||||
|
bibliographic_fields = { |
||||||
|
# language-dependent: fixed |
||||||
|
u'forfatter': 'author', |
||||||
|
u'forfattere': 'authors', |
||||||
|
u'organisation': 'organization', |
||||||
|
u'adresse': 'address', |
||||||
|
u'kontakt': 'contact', |
||||||
|
u'version': 'version', |
||||||
|
u'revision': 'revision', |
||||||
|
u'status': 'status', |
||||||
|
u'dato': 'date', |
||||||
|
u'copyright': 'copyright', |
||||||
|
u'dedikation': 'dedication', |
||||||
|
u'resume': 'abstract', |
||||||
|
u'resumé': 'abstract'} |
||||||
|
"""Danish (lowcased) to canonical name mapping for bibliographic fields.""" |
||||||
|
|
||||||
|
author_separators = [';', ','] |
||||||
|
"""List of separator strings for the 'Authors' bibliographic field. Tried in |
||||||
|
order.""" |
@ -0,0 +1,58 @@ |
|||||||
|
# $Id: de.py 4564 2006-05-21 20:44:42Z wiemann $ |
||||||
|
# Author: Gunnar Schwant <g.schwant@gmx.de> |
||||||
|
# Copyright: This module has been placed in the public domain. |
||||||
|
|
||||||
|
# New language mappings are welcome. Before doing a new translation, please |
||||||
|
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be |
||||||
|
# translated for each language: one in docutils/languages, the other in |
||||||
|
# docutils/parsers/rst/languages. |
||||||
|
|
||||||
|
""" |
||||||
|
German language mappings for language-dependent features of Docutils. |
||||||
|
""" |
||||||
|
|
||||||
|
__docformat__ = 'reStructuredText' |
||||||
|
|
||||||
|
labels = { |
||||||
|
'author': 'Autor', |
||||||
|
'authors': 'Autoren', |
||||||
|
'organization': 'Organisation', |
||||||
|
'address': 'Adresse', |
||||||
|
'contact': 'Kontakt', |
||||||
|
'version': 'Version', |
||||||
|
'revision': 'Revision', |
||||||
|
'status': 'Status', |
||||||
|
'date': 'Datum', |
||||||
|
'dedication': 'Widmung', |
||||||
|
'copyright': 'Copyright', |
||||||
|
'abstract': 'Zusammenfassung', |
||||||
|
'attention': 'Achtung!', |
||||||
|
'caution': 'Vorsicht!', |
||||||
|
'danger': '!GEFAHR!', |
||||||
|
'error': 'Fehler', |
||||||
|
'hint': 'Hinweis', |
||||||
|
'important': 'Wichtig', |
||||||
|
'note': 'Bemerkung', |
||||||
|
'tip': 'Tipp', |
||||||
|
'warning': 'Warnung', |
||||||
|
'contents': 'Inhalt'} |
||||||
|
"""Mapping of node class name to label text.""" |
||||||
|
|
||||||
|
bibliographic_fields = { |
||||||
|
'autor': 'author', |
||||||
|
'autoren': 'authors', |
||||||
|
'organisation': 'organization', |
||||||
|
'adresse': 'address', |
||||||
|
'kontakt': 'contact', |
||||||
|
'version': 'version', |
||||||
|
'revision': 'revision', |
||||||
|
'status': 'status', |
||||||
|
'datum': 'date', |
||||||
|
'copyright': 'copyright', |
||||||
|
'widmung': 'dedication', |
||||||
|
'zusammenfassung': 'abstract'} |
||||||
|
"""German (lowcased) to canonical name mapping for bibliographic fields.""" |
||||||
|
|
||||||
|
author_separators = [';', ','] |
||||||
|
"""List of separator strings for the 'Authors' bibliographic field. Tried in |
||||||
|
order.""" |
@ -0,0 +1,60 @@ |
|||||||
|
# $Id: en.py 4564 2006-05-21 20:44:42Z wiemann $ |
||||||
|
# Author: David Goodger <goodger@python.org> |
||||||
|
# Copyright: This module has been placed in the public domain. |
||||||
|
|
||||||
|
# New language mappings are welcome. Before doing a new translation, please |
||||||
|
# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be |
||||||
|
# translated for each language: one in docutils/languages, the other in |
||||||
|
# docutils/parsers/rst/languages. |
||||||
|
|
||||||
|
""" |
||||||
|
English-language mappings for language-dependent features of Docutils. |
||||||
|
""" |
||||||
|
|
||||||
|
__docformat__ = 'reStructuredText' |
||||||
|
|
||||||
|
labels = { |
||||||
|
# fixed: language-dependent |
||||||
|
'author': 'Author', |
||||||
|
'authors': 'Authors', |
||||||
|
'organization': 'Organization', |
||||||
|
'address': 'Address', |
||||||
|
'contact': 'Contact', |
||||||
|
'version': 'Version', |
||||||
|
'revision': 'Revision', |
||||||
|
'status': 'Status', |
||||||
|
'date': 'Date', |
||||||
|
'copyright': 'Copyright', |
||||||
|
'dedication': 'Dedication', |
||||||
|
'abstract': 'Abstract', |
||||||
|
'attention': 'Attention!', |
||||||
|
'caution': 'Caution!', |
||||||
|
'danger': '!DANGER!', |
||||||
|
'error': 'Error', |
||||||
|
'hint': 'Hint', |
||||||
|
'important': 'Important', |
||||||
|
'note': 'Note', |
||||||
|
'tip': 'Tip', |
||||||
|
'warning': 'Warning', |
||||||
|
'contents': 'Contents'} |
||||||
|
"""Mapping of node class name to label text.""" |
||||||
|
|
||||||
|
bibliographic_fields = { |
||||||
|
# language-dependent: fixed |
||||||
|
'author': 'author', |
||||||
|
'authors': 'authors', |
||||||
|
'organization': 'organization', |
||||||
|
'address': 'address', |
||||||
|
'contact': 'contact', |
||||||
|
'version': 'version', |
||||||
|
'revision': 'revision', |
||||||
|
'status': 'status', |
||||||
|
'date': 'date', |
||||||
|
'copyright': 'copyright', |
||||||
|
'dedication': 'dedication', |
||||||
|
'abstract': 'abstract'} |
||||||
|
"""English (lowcased) to canonical name mapping for bibliographic fields.""" |
||||||
|
|
||||||
|
author_separators = [';', ','] |
||||||
|
"""List of separator strings for the 'Authors' bibliographic field. Tried in |
||||||
|
order.""" |