Skip to content

Create different documents from the same ReST sources (conditional text)

  1. Install Sphinx, and make:

    Terminal window
    $ sudo apt install python-sphinx make
  2. Create a Sphinx project using the default options:

    Terminal window
    $ sphinx-quickstart
  3. Add the following content to the index.rst file, maintaining the correct indentations:

    .. only:: electrician
    .. admonition:: Danger for electricians
    Risk of electric shock
    Do not touch electrical wires.
    .. only:: plumber
    .. admonition:: Danger for plumbers
    Risk of drowning
    Do not dive into the pool.
  4. To control the display of content intended for electricians or plumbers, uncomment or comment the following lines in the conf.py configuration file:

    tags.add('electrician')
    tags.add('plumber')
  5. Generate your content:

    Terminal window
    $ make html
  6. Open the _build/html/index.html file in a browser to view your content.