
1. Adds the following subsections: * Introduction to RST * Tables * Images * Profiling * Lists * Inline markups * Decorations * Commenting 2. Restructures the toc 3. Creates separate files for each subsection included in the RST-related folder for simpler maintenance. Change-Id: I08568fb37755109552edf9692b8f259660550a69
3.3 KiB
3.3 KiB
Code samples
Format code snippets as standalone literal blocks. There are several ways to define a code-block within an RST file.
Standard literal block
Directive | :: or code |
Arguments | none |
Options | none |
Description |
|
Use ::
or code
directive if you provide the
code snippets written in one programming language within one file. By
default, the code-block formatted this way is shown in a Python
highlighting mode.
To define another highlighting language, use the
code-block
directive as described in the non-standard-block
section.
Input
Add logging statements::
from nova.openstack.common import log as logging
LOG = logging.getLogger(__name__)
Output
Add logging statements:
from nova.openstack.common import log as logging
LOG = logging.getLogger(__name__)
Non-standard literal block
Directive | code-block |
Arguments | python (default), ruby , c ,
console , ini , and others |
Options | linenos , emphasize-lines |
Description |
|
To optimize the output of code for a specific programming language,
specify the corresponding argument with code-block
. Use
ini
for configuration files, console
for
console inputs and outputs, and so on.
Input
.. code-block:: ini
# Configuration for nova-rootwrap
# This file should be owned by (and only-writeable by) the root user
[DEFAULT]
# List of directories to load filter definitions from (separated by ',').
Output
# Configuration for nova-rootwrap
# This file should be owned by (and only-writeable by) the root user
[DEFAULT]
# List of directories to load filter definitions from (separated by ',').