Debian Codegraph @

docs/user/tools.rst

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