Debian Codegraph @

test/expensive_benchmarks/docutils_data/docs/user/tools.txt

raw
1 ==========================
2 Docutils Front-End Tools
3 ==========================
4
5 :Author: David Goodger
6 :Contact: [email protected]
7 :Revision: $Revision$
8 :Date: $Date$
9 :Copyright: This document has been placed in the public domain.
10
11 .. contents::
12
13
14 --------------
15 Introduction
16 --------------
17
18 Once the Docutils package is unpacked, you will discover a ``tools/``
19 directory containing several front ends for common Docutils
20 processing.
21 In addition to the `generic command line front end`_, Docutils has
22 many small front ends, each specialized for a specific "Reader" (which
23 knows how to interpret a file in context), a "Parser" (which
24 understands the syntax of the text), and a "Writer" (which knows how
25 to generate a specific data format).
26
27 Most [#]_ front ends have common options and the same command-line usage
28 pattern (see `the tools`_ below for concrete examples)::
29
30 toolname [options] [<source> [<destination>]]
31
32 Each tool has a "``--help``" option which lists the
33 `command-line options`_ and arguments it supports.
34 Processing can also be customized with `configuration files`_.
35
36 The two arguments, "source" and "destination", are optional. If only
37 one argument (source) is specified, the standard output (stdout) is
38 used for the destination. If no arguments are specified, the standard
39 input (stdin) is used for the source.
40
41 .. note::
42 Docutils front-end tool support is currently under discussion.
43 Tool names, install details and the set of auto-installed tools
44 may change in future Docutils versions.
45
46 .. [#] The exceptions are buildhtml.py_ and rst2odt_prepstyles.py_.
47
48 Getting Help
49 ============
50
51 First, try the "``--help``" option each front-end tool has.
52
53 Command line options and their corresponding configuration file entries
54 are detailed in `Docutils Configuration`_.
55
56 Users who have questions or need assistance with Docutils or
57 reStructuredText should post a message to the Docutils-users_ mailing
58 list.
59
60 .. _Docutils-users: mailing-lists.html#docutils-users
61
62
63 -----------
64 The Tools
65 -----------
66
67 Generic Command Line Front End
68 ==============================
69
70 :Readers: Standalone, PEP
71 :Parsers: reStructuredText, Markdown (requires 3rd party packages)
72 :Writers: html_, html4css1_, html5_, latex__, manpage_,
73 odt_, pep_html_, pseudo-xml_, s5_html_, xelatex_, xml_,
74 :Config_: See `[docutils application]`_
75
76 The generic front end allows combining "reader", "parser", and
77 "writer" components from the Docutils package or 3rd party plug-ins.
78
79 Since Docutils 0.19, it can be called by Python's ``-m`` option,
80 the ``docutils`` script installed in the binary PATH, or the
81 ``docutils-cli.py`` script in the ``tools/`` directory.
82
83 For example, to process a Markdown_ file "``test.md``" into
84 Pseudo-XML_ ::
85
86 python3 -m docutils --parser=markdown --writer=pseudoxml\
87 test.md test.txt
88
89 Use the "--help" option together with the component-selection options
90 to get the correct list of supported command-line options. Example::
91
92 docutils --parser=markdown --writer=xml --help
93
94
95
96 __
97 .. _latex2e:
98 .. _Generating LaTeX with Docutils: latex.html
99 .. _manpage: manpage.html
100 .. _Markdown: https://www.markdownguide.org/
101 .. _[docutils application]: config.html#docutils-application
102
103
104 HTML-Generating Tools
105 =====================
106
107 buildhtml.py
108 ------------
109
110 :Readers: Standalone, PEP
111 :Parser: reStructuredText
112 :Writers: html_, html5_, pep_html_
113 :Config_: `[buildhtml application]`_
114
115 Use ``buildhtml.py`` to generate ``*.html`` from all the ``*.txt`` files
116 (including PEPs) in each <directory> given, and their subdirectories
117 too. (Use the ``--local`` option to skip subdirectories.)
118
119 Usage::
120
121 buildhtml.py [options] [<directory> ...]
122
123 After unpacking the Docutils package, the following shell commands
124 will generate HTML for all included documentation::
125
126 cd docutils/tools
127 buildhtml.py ..
128
129 For official releases, the directory may be called "docutils-X.Y",
130 where "X.Y" is the release version. Alternatively::
131
132 cd docutils
133 tools/buildhtml.py --config=tools/docutils.conf
134
135 The current directory (and all subdirectories) is chosen by default if
136 no directory is named. Some files may generate system messages
137 (docs/user/rst/demo.txt contains intentional errors); use the
138 ``--quiet`` option to suppress all warnings. The ``--config`` option
139 ensures that the correct settings are in place (a ``docutils.conf``
140 `configuration file`_ in the current directory is picked up
141 automatically). Command-line options may be used to override config
142 file settings or replace them altogether.
143
144 .. _[buildhtml application]: config.html#buildhtml-application
145 .. _configuration file: `configuration files`_
146
147
148 rst2html.py
149 -----------
150
151 :Reader: Standalone
152 :Parser: reStructuredText
153 :Writer: html_
154
155 `rst2html.py` is the front-end for the default Docutils HTML writer.
156 The default writer may change with the development of HTML, browsers,
157 Docutils, and the web. Currently, it is html4css1_.
158
159 .. caution::
160 Use a specific front end like rst2html4.py_ or rst2html5.py_,
161 if you depend on stability of the generated HTML code
162 (e.g., because you use a custom style sheet or post-processing
163 that may break otherwise).
164
165
166 rst2html4.py
167 ------------
168
169 :Reader: Standalone
170 :Parser: reStructuredText
171 :Writer: html4css1_
172
173 The ``rst2html4.py`` front end reads standalone reStructuredText source
174 files and produces `XHTML 1.0 Transitional`_ output.
175 A CSS stylesheet is required for proper rendering; a simple but
176 complete stylesheet is installed and used by default (see Stylesheets_
177 below).
178
179 For example, to process a reStructuredText file "``test.txt``" into
180 HTML::
181
182 rst2html.py test.txt test.html
183
184 Now open the "``test.html``" file in your favorite browser to see the
185 results. To get a footer with a link to the source file, date & time
186 of processing, and links to the Docutils project, add some options::
187
188 rst2html.py -stg test.txt test.html
189
190
191 Stylesheets
192 ```````````
193
194 ``rst2html.py`` inserts into the generated HTML a cascading stylesheet
195 (or a link to a stylesheet, when passing the "``--link-stylesheet``"
196 option). A stylesheet is required for proper rendering. The default
197 stylesheet (``docutils/writers/html4css1/html4css1.css``, located in
198 the installation directory) is provided for basic use. To use
199 different stylesheet(s), specify the stylesheets' location(s)
200 as comma-separated list with the "``--stylesheet``" (for a URL)
201 or "``--stylesheet-path``" (for a local file) command-line option,
202 or with `configuration file`_ settings (e.g. ``./docutils.conf``
203 or ``~/.docutils``). To experiment with styles, please see the
204 `guide to writing HTML (CSS) stylesheets for Docutils`__.
205
206 __ ../howto/html-stylesheets.html
207 .. _html4css1: html.html#html4css1
208 .. _html: html.html#html
209
210
211 rst2html5.py
212 ------------
213
214 :Reader: Standalone
215 :Parser: reStructuredText
216 :Writer: html5_
217
218 The ``rst2html5.py`` front end reads standalone reStructuredText source
219 files and produces `HTML 5`_ output.
220 Correct rendering of elements not directly supported by HTML depends on a
221 CSS style sheet. The provided style sheets ``minimal.css`` and ``plain.css``
222 define required and optional styling rules respectively.
223
224 .. _html5: html.html#html5-polyglot
225
226 rstpep2html.py
227 --------------
228
229 :Reader: PEP
230 :Parser: reStructuredText
231 :Writer: pep_html_
232
233 ``rstpep2html.py`` reads a new-style PEP (marked up with reStructuredText)
234 and produces `XHTML 1.0 Transitional`_. It requires a template file and a
235 stylesheet. By default, it makes use of a "``pep-html-template``" file and
236 the "``pep.css``" stylesheet (both in the ``docutils/writers/pep_html/``
237 directory), but these can be overridden by command-line options or
238 configuration files.
239
240 For example, to process a PEP into HTML::
241
242 cd <path-to-docutils>/docs/peps
243 rstpep2html.py pep-0287.txt pep-0287.html
244
245 .. _pep_html: html.html#pep-html
246
247 rst2s5.py
248 ---------
249
250 :Reader: Standalone
251 :Parser: reStructuredText
252 :Writer: s5_html_
253
254 The ``rst2s5.py`` front end reads standalone reStructuredText source
255 files and produces (X)HTML output compatible with S5_, the "Simple
256 Standards-based Slide Show System" by Eric Meyer. A theme is required
257 for proper rendering; several are distributed with Docutils and others
258 are available; see Themes_ below.
259
260 For example, to process a reStructuredText file "``slides.txt``" into
261 S5/HTML::
262
263 rst2s5.py slides.txt slides.html
264
265 Now open the "``slides.html``" file in your favorite browser, switch
266 to full-screen mode, and enjoy the results.
267
268 .. _S5: http://meyerweb.com/eric/tools/s5/
269 .. _s5_html: html.html#s5-html
270
271 Themes
272 ``````
273
274 Each S5 theme consists of a directory containing several files:
275 stylesheets, JavaScript, and graphics. These are copied into a
276 ``ui/<theme>`` directory beside the generated HTML. A theme is chosen
277 using the "``--theme``" option (for themes that come with Docutils) or
278 the "``--theme-url``" option (for themes anywhere). For example, the
279 "medium-black" theme can be specified as follows::
280
281 rst2s5.py --theme medium-black slides.txt slides.html
282
283 The theme will be copied to the ``ui/medium-black`` directory.
284
285 Several themes are included with Docutils:
286
287 ``default``
288 This is a simplified version of S5's default theme.
289
290 :Main content: black serif text on a white background
291 :Text capacity: about 13 lines
292 :Headers: light blue, bold sans-serif text on a dark blue
293 background; titles are limited to one line
294 :Footers: small, gray, bold sans-serif text on a dark blue
295 background
296
297 ``small-white``
298 (Small text on a white background.)
299
300 :Main content: black serif text on a white background
301 :Text capacity: about 15 lines
302 :Headers: black, bold sans-serif text on a white background;
303 titles wrap
304 :Footers: small, dark gray, bold sans-serif text on a white
305 background
306
307 ``small-black``
308 :Main content: white serif text on a black background
309 :Text capacity: about 15 lines
310 :Headers: white, bold sans-serif text on a black background;
311 titles wrap
312 :Footers: small, light gray, bold sans-serif text on a black
313 background
314
315 ``medium-white``
316 :Main content: black serif text on a white background
317 :Text capacity: about 9 lines
318 :Headers: black, bold sans-serif text on a white background;
319 titles wrap
320 :Footers: small, dark gray, bold sans-serif text on a white
321 background
322
323 ``medium-black``
324 :Main content: white serif text on a black background
325 :Text capacity: about 9 lines
326 :Headers: white, bold sans-serif text on a black background;
327 titles wrap
328 :Footers: small, light gray, bold sans-serif text on a black
329 background
330
331 ``big-white``
332 :Main content: black, bold sans-serif text on a white background
333 :Text capacity: about 5 lines
334 :Headers: black, bold sans-serif text on a white background;
335 titles wrap
336 :Footers: not displayed
337
338 ``big-black``
339 :Main content: white, bold sans-serif text on a black background
340 :Text capacity: about 5 lines
341 :Headers: white, bold sans-serif text on a black background;
342 titles wrap
343 :Footers: not displayed
344
345 If a theme directory contains a file named ``__base__``, the name of
346 the theme's base theme will be read from it. Files are accumulated
347 from the named theme, any base themes, and the "default" theme (which
348 is the implicit base of all themes).
349
350 For details, please see `Easy Slide Shows With reStructuredText &
351 S5 <slide-shows.html>`_.
352
353
354 .. _HTML 5: https://www.w3.org/TR/html5/
355 .. _HTML 4.1: https://www.w3.org/TR/html401/
356 .. _XHTML 1.0 Transitional: https://www.w3.org/TR/xhtml1/
357 .. _XHTML 1.1: https://www.w3.org/TR/xhtml1/
358
359
360 LaTeX-Generating Tools
361 ======================
362
363 rst2latex.py
364 ------------
365
366 :Reader: Standalone
367 :Parser: reStructuredText
368 :Writer: latex2e_
369
370 The ``rst2latex.py`` front end reads standalone reStructuredText
371 source files and produces LaTeX_ output. For example, to process a
372 reStructuredText file "``test.txt``" into LaTeX::
373
374 rst2latex.py test.txt test.tex
375
376 The output file "``test.tex``" should then be processed with ``latex``
377 or ``pdflatex`` to get a document in DVI, PostScript or PDF format for
378 printing or on-screen viewing.
379
380 For details see `Generating LaTeX with Docutils`_.
381
382 rst2xetex.py
383 ------------
384
385 :Reader: Standalone
386 :Parser: reStructuredText
387 :Writer: _`xelatex`
388
389 The ``rst2xetex.py`` front end reads standalone reStructuredText source
390 files and produces `LaTeX` output for processing with Unicode-aware
391 TeX engines (`LuaTeX`_ or `XeTeX`_). For example, to process a
392 reStructuredText file "``test.txt``" into LaTeX::
393
394 rst2xetex.py test.txt test.tex
395
396 The output file "``test.tex``" should then be processed with ``xelatex`` or
397 ``lualatex`` to get a document in PDF format for printing or on-screen
398 viewing.
399
400 For details see `Generating LaTeX with Docutils`_.
401
402 .. _LaTeX: https://en.wikipedia.org/wiki/LaTeX
403 .. _XeTeX: https://en.wikipedia.org/wiki/XeTeX
404 .. _LuaTeX: https://en.wikipedia.org/wiki/LuaTeX
405
406
407 Man-Page-Generating Tools
408 =========================
409
410 rst2man.py
411 ----------
412
413 :Reader: Standalone
414 :Parser: reStructuredText
415 :Writer: manpage_
416
417 The ``rst2man.py`` front end reads standalone reStructuredText source
418 files and produces troff_ sources for Unix man pages.
419
420 .. _troff: https://troff.org/
421
422
423 ODF/OpenOffice-Generating Tools
424 ===============================
425
426 rst2odt.py
427 ----------
428
429 :Reader: Standalone
430 :Parser: reStructuredText
431 :Writer: odt_
432
433 The ``rst2odt.py`` front end reads standalone reStructuredText
434 source files and produces ODF/.odt files that can be read, edited,
435 printed, etc with OpenOffice_ ``oowriter`` or LibreOffice_ ``lowriter``.
436 A stylesheet file is required. A
437 stylesheet file is an OpenOffice .odt file containing definitions
438 of the styles required for ``rst2odt.py``.
439 For details, see `Odt Writer for Docutils`_.
440
441 .. _OpenOffice: https://www.openoffice.org/
442 .. _LibreOffice: https://www.libreoffice.org/
443 .. _odt:
444 .. _Odt Writer for Docutils: odt.html
445
446 rst2odt_prepstyles.py
447 `````````````````````
448
449 A helper tool to fix a word-processor-generated STYLE_FILE.odt for
450 odtwriter use::
451
452 rst2odt_prepstyles STYLE_FILE.odt
453
454 See `Odt Writer for Docutils`__ for details.
455
456 __ odt.html#page-size
457
458
459 reStructuredText-Generating Tools
460 =================================
461
462 Currently, there is no reStructuredText writer in Docutils and therefore
463 an ``rst2rst.py`` tool is still missing.
464
465 To generate reStructuredText documents with Docutils, you can use
466 the XML (Docutils native) writer and the xml2rst_ processor.
467
468
469 XML-Generating Tools
470 ====================
471
472 rst2xml.py
473 ----------
474
475 :Reader: Standalone
476 :Parser: reStructuredText
477 :Writer: _`XML` (Docutils native)
478
479 The ``rst2xml.py`` front end produces Docutils-native XML output.
480 This can be transformed with standard XML tools such as XSLT
481 processors into arbitrary final forms. An example is the xml2rst_ processor
482 in the Docutils sandbox.
483
484 .. _xml2rst: ../../../sandbox/xml2rst
485
486
487 Testing/Debugging Tools
488 =======================
489
490 rst2pseudoxml.py
491 ----------------
492
493 :Reader: Standalone
494 :Parser: reStructuredText
495 :Writer: _`Pseudo-XML`
496
497 ``rst2pseudoxml.py`` is used for debugging the Docutils "Reader to
498 Transform to Writer" pipeline. It produces a compact pretty-printed
499 "pseudo-XML", where nesting is indicated by indentation (no end-tags).
500 External attributes for all elements are output, and internal
501 attributes for any leftover "pending" elements are also given.
502
503
504 quicktest.py
505 ------------
506
507 :Reader: N/A
508 :Parser: reStructuredText
509 :Writer: N/A
510
511 The ``quicktest.py`` tool is used for testing the reStructuredText
512 parser. It does not use a Docutils Reader or Writer or the standard
513 Docutils command-line options. Rather, it does its own I/O and calls
514 the parser directly. No transforms are applied to the parsed
515 document. Possible output forms output include:
516
517 --pretty Pretty-printed pseudo-XML (default)
518
519 --test Test data (Python list of input and pseudo-XML output strings;
520 useful for creating new test cases)
521 --xml Pretty-printed native XML
522 --rawxml Raw native XML (with or without a stylesheet reference)
523 --help Usage hint and complete list of supported options.
524
525
526 ---------------
527 Customization
528 ---------------
529
530 Most front-end tools support the options/settings from the generic
531 `configuration file sections`_ plus the sections of their components
532 (reader, writer, parser). [#]_
533 Some front-end tools also add application-specific settings.
534
535 .. [#] The exceptions are quicktest.py_ and rst2odt_prepstyles.py_.
536
537
538 Command-Line Options
539 ====================
540
541 Command-line options are intended for one-off customization.
542 They take priority over configuration file settings.
543
544 Use the "--help" option on each of the front ends to list the
545 command-line options it supports.
546
547
548 Configuration Files
549 ===================
550
551 Configuration files are used for persistent customization; they can be
552 set once and take effect every time you use a front-end tool.
553
554 Command-line options and their corresponding configuration file entry
555 names are listed in the `Docutils Configuration`_ document.
556
557 .. _Docutils Configuration: config.html
558 .. _Config:
559 .. _configuration file sections:
560 config.html#configuration-file-sections-entries
561
562
563 ..
564 Local Variables:
565 mode: indented-text
566 indent-tabs-mode: nil
567 sentence-end-double-space: t
568 fill-column: 70
569 End: