summaryrefslogtreecommitdiff
path: root/doc/markup/code.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-22 19:23:23 +0100
committerGeorg Brandl <georg@python.org>2009-01-22 19:23:23 +0100
commit388277ae83ef94de163905144138d9ca6fe0dc7c (patch)
treed2f80659cdf358e02acf33c040df461d84ff3e74 /doc/markup/code.rst
parent41199791234037ce6bf2f9d4afa7248df5b118c7 (diff)
parenta7bb180ba708ffef173d0741a56ea41b8de1de06 (diff)
downloadsphinx-388277ae83ef94de163905144138d9ca6fe0dc7c.tar.gz
merge with 0.5
Diffstat (limited to 'doc/markup/code.rst')
-rw-r--r--doc/markup/code.rst27
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/markup/code.rst b/doc/markup/code.rst
index 299ab0bc..0bf8343b 100644
--- a/doc/markup/code.rst
+++ b/doc/markup/code.rst
@@ -113,8 +113,35 @@ Includes
.. literalinclude:: example.py
:encoding: latin-1
+ The directive also supports including only parts of the file. If it is a
+ Python module, you can select a class, function or method to include using
+ the ``pyobject`` option::
+
+ .. literalinclude:: example.py
+ :pyobject: Timer.start
+
+ This would only include the code lines belonging to the ``start()`` method in
+ the ``Timer`` class within the file.
+
+ Alternately, you can specify exactly which lines to include by giving a
+ ``lines`` option::
+
+ .. literalinclude:: example.py
+ :lines: 1,3,5-10,20-
+
+ This includes the lines 1, 3, 5 to 10 and lines 20 to the last line.
+
+ Another way to control which part of the file is included is to use the
+ ``start-after`` and ``end-before`` options (or only one of them). If
+ ``start-after`` is given as a string option, only lines that follow the first
+ line containing that string are included. If ``end-before`` is given as a
+ string option, only lines that precede the first lines containing that string
+ are included.
+
.. versionadded:: 0.4.3
The ``encoding`` option.
+ .. versionadded:: 0.6
+ The ``pyobject``, ``lines``, ``start-after`` and ``end-before`` options.
.. rubric:: Footnotes