summaryrefslogtreecommitdiff
path: root/doc/markup/code.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-03-16 11:19:26 +0000
committerGeorg Brandl <georg@python.org>2008-03-16 11:19:26 +0000
commitca528099f673fcc98c36004a56cff6a21b5c61e4 (patch)
tree24bd20c728be044d2acf74d1426ea3624b8e8e8e /doc/markup/code.rst
parent14da7605e4be71f6370e80375a33d6f4ab012b74 (diff)
downloadsphinx-git-ca528099f673fcc98c36004a56cff6a21b5c61e4.tar.gz
Update documentation, add more content.
Diffstat (limited to 'doc/markup/code.rst')
-rw-r--r--doc/markup/code.rst25
1 files changed, 19 insertions, 6 deletions
diff --git a/doc/markup/code.rst b/doc/markup/code.rst
index ab1420c2c..bceafb4c0 100644
--- a/doc/markup/code.rst
+++ b/doc/markup/code.rst
@@ -3,6 +3,9 @@
Showing code examples
---------------------
+.. index:: pair: code; examples
+ single: sourcecode
+
Examples of Python source code or interactive sessions are represented using
standard reST literal blocks. They are started by a ``::`` at the end of the
preceding paragraph and delimited by indentation.
@@ -78,14 +81,24 @@ on line numbers for the individual block::
Includes
^^^^^^^^
-Longer displays of verbatim text may be included by storing the example text in
-an external file containing only plain text. The file may be included using the
-``literalinclude`` directive. [1]_ For example, to include the Python source file
-:file:`example.py`, use::
+.. directive:: .. literalinclude:: filename
+
+ Longer displays of verbatim text may be included by storing the example text in
+ an external file containing only plain text. The file may be included using the
+ ``literalinclude`` directive. [1]_ For example, to include the Python source file
+ :file:`example.py`, use::
+
+ .. literalinclude:: example.py
- .. literalinclude:: example.py
+ The file name is relative to the current file's path.
-The file name is relative to the current file's path.
+ The directive also supports the ``linenos`` flag option to switch on line
+ numbers, and a ``language`` option to select a language different from the
+ current file's standard language. Example with options::
+
+ .. literalinclude:: example.rb
+ :language: ruby
+ :linenos:
.. rubric:: Footnotes