Enhance code samples chapter

Change-Id: I5c25f6ea8d97e7d4005c5e36dc54b763a52b4928
This commit is contained in:
chenxing 2018-05-30 20:58:04 +08:00
parent 96d6e4831d
commit d9e27ca387
3 changed files with 51 additions and 5 deletions

View File

@ -21,7 +21,9 @@ To insert a semantic markup into your document, use the syntax below.
.. code-block:: rst .. code-block:: rst
:markup:`inline text` :markup:`inline text`
.. end
Application Application
~~~~~~~~~~~ ~~~~~~~~~~~

View File

@ -53,7 +53,7 @@ syntax format.
* Example 2: Configure a configuration file. * Example 2: Configure a configuration file.
.. code-block:: none .. code-block:: rst
.. path /etc/keystone/keystone.conf .. path /etc/keystone/keystone.conf
.. code-block:: ini .. code-block:: ini
@ -68,7 +68,7 @@ syntax format.
* The ``only`` tags should be closed with ``endonly``. * The ``only`` tags should be closed with ``endonly``.
.. code-block:: none .. code-block:: rst
.. only:: ubuntu or debian .. only:: ubuntu or debian

View File

@ -79,7 +79,7 @@ files, ``console`` for console inputs and outputs, and so on.
**Input** **Input**
.. code-block:: none .. code-block:: rst
.. path /path/to/config/file .. path /path/to/config/file
.. code-block:: ini .. code-block:: ini
@ -92,6 +92,8 @@ files, ``console`` for console inputs and outputs, and so on.
.. end .. end
.. end
**Output** **Output**
.. code-block:: ini .. code-block:: ini
@ -102,6 +104,8 @@ files, ``console`` for console inputs and outputs, and so on.
[DEFAULT] [DEFAULT]
# List of directories to load filter definitions from (separated by ','). # List of directories to load filter definitions from (separated by ',').
.. end
.. note:: .. note::
When you write the command example, you should write the input and output When you write the command example, you should write the input and output
@ -109,6 +113,46 @@ files, ``console`` for console inputs and outputs, and so on.
not split them into input block and output block. not split them into input block and output block.
You can omit the output where appropriate. You can omit the output where appropriate.
Options of code-block directive
-------------------------------
You can add line numbers to code examples with the ``:linenos:`` parameter and
highlight some specific lines with the ``:emphasize-lines:`` parameter:
**Input**
.. code-block:: rst
.. code-block:: python
:linenos:
:emphasize-lines: 3,5-6
def some_function():
interesting = False
print 'This line is highlighted.'
print 'This one is not...'
print '...but this one is.'
print 'This one is highlighted too.'
.. end
.. end
**Output**
.. code-block:: python
:linenos:
:emphasize-lines: 3,5-6
def some_function():
interesting = False
print 'This line is highlighted.'
print 'This one is not...'
print '...but this one is.'
print 'This one is highlighted too.'
.. end
.. _remote-block: .. _remote-block:
Literal block using a remote file Literal block using a remote file
@ -133,7 +177,7 @@ content from a remote URL (``http`` or ``https``).
**Input** **Input**
.. code-block:: none .. code-block:: rst
.. path /path/to/config/file .. path /path/to/config/file
.. remote-code-block:: ini .. remote-code-block:: ini