reStructuredText: Source Code Blocks

Source Code

Source code will be formatted by the directive code-block.


.. code-block:: sh
   :caption: CaptionHere

   Line 1
   Line 2


Listing 2 CaptionHere
Line 1
Line 2

Valid values for the highlighting language are:

  • none (no highlighting)

  • python (the default)

  • bareosconfig (Bareos configuration files or parts thereof)

  • bconsole (Bareos console (bconsole) sessions)

  • bareoslog (Bareos log files)

  • bareosmessage (Bareos messages)

  • sh (Shell scripts)

  • shell-session (Shell sessions)

  • dosbatch (DOS/Windows Batch file)

  • doscon (MSDOS sessions)

  • cfg (Generic configuration file, mostly INI files)

  • sql (Generic SQL commands)

  • registry (Windows Registry files produced by regedit)

  • guess (let Pygments guess the lexer based on contents, only works with certain well-recognizable languages)

  • rest

  • c

  • … and any other lexer alias that Pygments supports.

If the text resides in a seperate file, use:

.. literalinclude:: /bareos/include/config/backup-client1.cfg
   :language: bareosconfig

All included files should be located under /include.

The beginning / means, root directory of the documenation source directory. Without it, the path is relative to the directory of the including file.

Configuration files should be located under /bareos/include/config/.

Last change: Tue, 03 Aug 2021 10:25 PM UTC