~ubuntu-branches/ubuntu/jaunty/python-docutils/jaunty

« back to all changes in this revision

Viewing changes to docs/api/publisher.txt

  • Committer: Bazaar Package Importer
  • Author(s): Simon McVittie
  • Date: 2008-07-24 10:39:53 UTC
  • mfrom: (1.1.4 upstream) (3.1.7 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080724103953-8gh4uezg17g9ysgy
Tags: 0.5-2
* Upload docutils 0.5 to unstable
* Update rst.el to upstream Subversion r5596, which apparently fixes
  all its performance problems (17_speed_up_rst_el.dpatch, closes: #474941)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
:Author: David Goodger
6
6
:Contact: goodger@python.org
7
 
:Date: $Date: 2005-06-27 13:25:47 +0200 (Mon, 27 Jun 2005) $
8
 
:Revision: $Revision: 3599 $
 
7
:Date: $Date: 2008-06-25 08:54:03 +0200 (Mit, 25 Jun 2008) $
 
8
:Revision: $Revision: 5576 $
9
9
:Copyright: This document has been placed in the public domain.
10
10
 
11
11
.. contents::
12
12
 
13
13
 
 
14
The ``docutils.core.Publisher`` class is the core of Docutils,
 
15
managing all the processing and relationships between components.  See
 
16
`PEP 258`_ for an overview of Docutils components.
 
17
 
 
18
The ``docutils.core.publish_*`` convenience functions are the normal
 
19
entry points for using Docutils as a library.
 
20
 
 
21
See `Inside A Docutils Command-Line Front-End Tool`_ for an overview
 
22
of a typical Docutils front-end tool, including how the Publisher
 
23
class is used.
 
24
 
 
25
.. _PEP 258: ../peps/pep-0258.html
 
26
.. _Inside A Docutils Command-Line Front-End Tool: ./cmdline-tool.html
 
27
 
 
28
 
14
29
Publisher Convenience Functions
15
30
===============================
16
31
 
17
32
Each of these functions set up a ``docutils.core.Publisher`` object,
18
33
then call its ``publish`` method.  ``docutils.core.Publisher.publish``
19
 
handles everything else.  There are five convenience functions in the
20
 
``docutils.core`` module:
 
34
handles everything else.  There are several convenience functions in
 
35
the ``docutils.core`` module:
21
36
 
22
37
:_`publish_cmdline`: for command-line front-end tools, like
23
38
  ``rst2html.py``.  There are several examples in the ``tools/``
39
54
 
40
55
  There are usage examples in the `docutils/examples.py`_ module.
41
56
 
 
57
:_`publish_doctree`: for programmatic use with string input; returns a
 
58
  Docutils document tree data structure (doctree).  The doctree can be
 
59
  modified, pickled & unpickled, etc., and then reprocessed with
 
60
  `publish_from_doctree`_.
 
61
 
 
62
:_`publish_from_doctree`: for programmatic use to render from an
 
63
  existing document tree data structure (doctree); returns the encoded
 
64
  output as a string.
 
65
 
42
66
:_`publish_programmatically`: for custom programmatic use.  This
43
67
  function implements common code and is used by ``publish_file``,
44
68
  ``publish_string``, and ``publish_parts``.  It returns a 2-tuple:
90
114
and values are Unicode strings.
91
115
 
92
116
Each Writer component may publish a different set of document parts,
93
 
described below.  Currently only the HTML Writer implements more than
94
 
the "whole" part.
 
117
described below.  Not all writers implement all parts.
95
118
 
96
119
 
97
120
Parts Provided By All Writers
98
121
-----------------------------
99
122
 
 
123
_`encoding`
 
124
    The output encoding setting.
 
125
 
 
126
_`version`
 
127
    The version of Docutils used.
 
128
 
100
129
_`whole`
101
130
    ``parts['whole']`` contains the entire formatted document.
102
131
 
103
132
 
 
133
.. _HTML writer:
 
134
 
104
135
Parts Provided By the HTML Writer
105
136
---------------------------------
106
137
 
108
139
    ``parts['body']`` is equivalent to parts['fragment_'].  It is
109
140
    *not* equivalent to parts['html_body_'].
110
141
 
 
142
_`body_prefix`
 
143
    ``parts['body_prefix']`` contains::
 
144
 
 
145
        </head>
 
146
        <body>
 
147
        <div class="document" ...>
 
148
 
 
149
    and, if applicable::
 
150
 
 
151
        <div class="header">
 
152
        ...
 
153
        </div>
 
154
 
 
155
_`body_pre_docinfo`
 
156
    ``parts['body_pre_docinfo]`` contains (as applicable)::
 
157
 
 
158
        <h1 class="title">...</h1>
 
159
        <h2 class="subtitle" id="...">...</h2>
 
160
 
 
161
_`body_suffix`
 
162
    ``parts['body_suffix']`` contains::
 
163
 
 
164
        </div>
 
165
 
 
166
    (the end-tag for ``<div class="document">``), the footer division
 
167
    if applicable::
 
168
 
 
169
        <div class="footer">
 
170
        ...
 
171
        </div>
 
172
 
 
173
    and::
 
174
 
 
175
        </body>
 
176
        </html>
 
177
 
111
178
_`docinfo`
112
 
    ``parts['docinfo']`` contains the document bibliographic data.
 
179
    ``parts['docinfo']`` contains the document bibliographic data, the
 
180
    docinfo field list rendered as a table.
113
181
 
114
182
_`footer`
115
183
    ``parts['footer']`` contains the document footer content, meant to
121
189
    ``<body>``).  In other words, it contains the entire document,
122
190
    less the document title, subtitle, docinfo, header, and footer.
123
191
 
 
192
_`head`
 
193
    ``parts['head']`` contains ``<meta ... />`` tags and the document
 
194
    ``<title>...</title>``.
 
195
 
 
196
_`head_prefix`
 
197
    ``parts['head_prefix']`` contains the XML declaration, the DOCTYPE
 
198
    declaration, the ``<html ...>`` start tag and the ``<head>`` start
 
199
    tag.
 
200
 
124
201
_`header`
125
202
    ``parts['header']`` contains the document header content, meant to
126
203
    appear at the top of a web page, or repeated at the top of every
163
240
    ``parts['meta']`` contains all ``<meta ... />`` tags.
164
241
 
165
242
_`stylesheet`
166
 
    ``parts['stylesheet']`` contains the document stylesheet link.
 
243
    ``parts['stylesheet']`` contains the embedded stylesheet or
 
244
    stylesheet link.
167
245
 
168
246
_`subtitle`
169
247
    ``parts['subtitle']`` contains the document subtitle text and any
174
252
    ``parts['title']`` contains the document title text and any inline
175
253
    markup.  It does not include the enclosing ``<h1>`` & ``</h1>``
176
254
    tags.
 
255
 
 
256
 
 
257
Parts Provided by the PEP/HTML Writer
 
258
`````````````````````````````````````
 
259
 
 
260
The PEP/HTML writer provides the same parts as the `HTML writer`_,
 
261
plus the following:
 
262
 
 
263
_`pepnum`
 
264
    ``parts['pepnum']`` contains
 
265
 
 
266
 
 
267
Parts Provided by the S5/HTML Writer
 
268
````````````````````````````````````
 
269
 
 
270
The S5/HTML writer provides the same parts as the `HTML writer`_.
 
271
 
 
272
Parts Provided by the LaTeX2e Writer
 
273
````````````````````````````````````
 
274
 
 
275
__`head_prefix`
 
276
    ``parts['head_prefix']`` contains the LaTeX document class, package 
 
277
    and stylesheet inclusion.
 
278
 
 
279
__`head`
 
280
    ``parts['head']`` currently is empty. 
 
281
 
 
282
__`body_prefix`
 
283
    ``parts['body_prefix']`` contains the LaTeX ``\begin{document}`` and
 
284
    title page. 
 
285
 
 
286
__`body`
 
287
    ``parts['body']`` contains the LaTeX document content, less
 
288
    the ``\begin{document}`` and ``\end{document}`` tags themselves.
 
289
 
 
290
__`body_suffix`
 
291
    ``parts['body_suffix']`` contains the LaTeX ``\end{document}``.
 
292
    
 
293