mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Rename "object" to "pyobject" and document it.
This commit is contained in:
parent
ddee927c46
commit
c80dc58ac1
@ -113,8 +113,20 @@ Includes
|
|||||||
.. literalinclude:: example.py
|
.. literalinclude:: example.py
|
||||||
:encoding: latin-1
|
: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
|
.. versionadded:: 0.4.3
|
||||||
The ``encoding`` option.
|
The ``encoding`` option.
|
||||||
|
.. versionadded:: 0.6
|
||||||
|
The ``pyobject`` option.
|
||||||
|
|
||||||
|
|
||||||
.. rubric:: Footnotes
|
.. rubric:: Footnotes
|
||||||
|
@ -69,7 +69,7 @@ def literalinclude_directive(name, arguments, options, content, lineno,
|
|||||||
fn = path.normpath(path.join(source_dir, rel_fn))
|
fn = path.normpath(path.join(source_dir, rel_fn))
|
||||||
|
|
||||||
fromline = toline = None
|
fromline = toline = None
|
||||||
objectname = options.get('object')
|
objectname = options.get('pyobject')
|
||||||
if objectname is not None:
|
if objectname is not None:
|
||||||
from sphinx.pycode import ModuleAnalyzer
|
from sphinx.pycode import ModuleAnalyzer
|
||||||
analyzer = ModuleAnalyzer.for_file(fn, '')
|
analyzer = ModuleAnalyzer.for_file(fn, '')
|
||||||
@ -109,7 +109,7 @@ def literalinclude_directive(name, arguments, options, content, lineno,
|
|||||||
literalinclude_directive.options = {'linenos': directives.flag,
|
literalinclude_directive.options = {'linenos': directives.flag,
|
||||||
'language': directives.unchanged_required,
|
'language': directives.unchanged_required,
|
||||||
'encoding': directives.encoding,
|
'encoding': directives.encoding,
|
||||||
'object': directives.unchanged_required,
|
'pyobject': directives.unchanged_required,
|
||||||
#'lines': directives.unchanged_required,
|
#'lines': directives.unchanged_required,
|
||||||
#'start-after': directives.unchanged_required,
|
#'start-after': directives.unchanged_required,
|
||||||
#'end-before': directives.unchanged_required,
|
#'end-before': directives.unchanged_required,
|
||||||
|
Loading…
Reference in New Issue
Block a user