Linux@BFH.ch Styleguide

Document Structure and index

Index.rst and table of contents

A document structure consists of a folder, a index.rst and subdocuments. Subdocuments are refered in the index.rst with the toctree directive. All subdocuments have a document title (= chars below and on upper line). These titles will be shown in toc’s (table of contents) as well by crossreferencing documents.

=====================
Example Documentation
=====================

Example introdution text.

.. toctree::
   :maxdepth: 2

   installation
   configuration
   usage
   best-practice
   ressources

This example has several subsections in files named installation.rst etc.

Crossreferencing to a another document

FIXME

This is a sample reference to another :doc:`document </software/gnupg/index>` and has the title :doc:`/software/gnupg/index`.
Usage of direct document titles is as well possible :doc:`index`.

This is a sample reference to another document and has the title GnuPG. Usage of direct document title is as well possible Sphinx.

Referencing to a section

FIXME

.. _my-reference-label:

Section to cross-reference
--------------------------

This is the text of the section.

It refers to the section itself, see :ref:`my-reference-label`.

Inline Objects

Code or other monospaced objects

Inline paths or files can use of the code directive:

This file is at :code:`/etc/hosts`.

This file is at /etc/hosts.


Or by using double apostrophe:

This file is at ``/etc/hosts``.

This file is at /etc/hosts.

Raw html

How to insert inline raw html:

Here is some |stuff|.

.. |stuff| raw:: html

   <em>emphasized text containing a
   <a href="http://example.org">hyperlink</a> and
   <tt>inline literals</tt></em>

Here is some emphasized text containing a hyperlink and inline literals.

Footnotes

For footnotes (ref), use [#name]_ to mark the footnote location, and add the footnote body at the bottom of the document after a “Footnotes” rubric heading, like so:

Lorem ipsum [#f1]_ dolor sit amet ... [#f2]_

.. rubric:: Footnotes

.. [#f1] Text of the first footnote.
.. [#f2] Text of the second footnote.

You can also explicitly number the footnotes ([1]_) or use auto-numbered footnotes without names ([#]_).

Symbols

.. include:: <isonum.txt>

 This is a foo |rarr| bar test.

This is a foo → bar test.

HTML

Pure HTML can be embedded by the .. raw:: directive.

.. raw:: html

   <div class="col-lg-4">
       dingens
   </div>

Block Objects

Code

By a preceeding block and double colons:

By a preceeding block and double colons::

rm -Rf *

By a preceeding block and double colons:

rm -Rf *

By a a preceeding directive:

.. code-block:: bash

   rm -Rf *
rm -Rf *

Horizontal rule

A horizontal line (<hr />):

A block of text.

----

A second block of text.

A block of text.


A second block of text.

Admonitions

Usage of specific admonitions like “attention”, “caution”, “danger”, “error”, “hint”, “important”, “note”, “tip”, “warning”, “admonition”:

.. NOTE:: Beware of killer rabbits

Note

Beware of killer rabbits


Usage by your own title:

.. admonition:: Example

   foo bar

Example

foo bar

Custom CSS

Inline (span element)

.. role:: small

This is a example :small:`small span` text.

This is a example small span text.

Block

.. rst-class:: small

   This is a example small text block.

This is a example small text block.