diff options
| author | Georg Brandl <georg@python.org> | 2008-12-30 15:45:02 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2008-12-30 15:45:02 +0100 |
| commit | c9d52ded703813ca16c75702bd18b9fcbd2e751d (patch) | |
| tree | a1967015d2937d9b771ddc9f9139db08b3cf8627 | |
| parent | 2cfbedc3766a17d9991589f482eadc76e4b3d687 (diff) | |
| download | sphinx-c9d52ded703813ca16c75702bd18b9fcbd2e751d.tar.gz | |
Rename "object" to "pyobject" and document it.
| -rw-r--r-- | doc/markup/code.rst | 12 | ||||
| -rw-r--r-- | sphinx/directives/code.py | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/doc/markup/code.rst b/doc/markup/code.rst index 299ab0bc..2fd51c84 100644 --- a/doc/markup/code.rst +++ b/doc/markup/code.rst @@ -113,8 +113,20 @@ 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. + .. versionadded:: 0.4.3 The ``encoding`` option. + .. versionadded:: 0.6 + The ``pyobject`` option. .. rubric:: Footnotes diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index 7ac9a1c3..cc74566d 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -69,7 +69,7 @@ def literalinclude_directive(name, arguments, options, content, lineno, fn = path.normpath(path.join(source_dir, rel_fn)) fromline = toline = None - objectname = options.get('object') + objectname = options.get('pyobject') if objectname is not None: from sphinx.pycode import ModuleAnalyzer analyzer = ModuleAnalyzer.for_file(fn, '') @@ -109,7 +109,7 @@ def literalinclude_directive(name, arguments, options, content, lineno, literalinclude_directive.options = {'linenos': directives.flag, 'language': directives.unchanged_required, 'encoding': directives.encoding, - 'object': directives.unchanged_required, + 'pyobject': directives.unchanged_required, #'lines': directives.unchanged_required, #'start-after': directives.unchanged_required, #'end-before': directives.unchanged_required, |
