python - literalinclude : how to include only a variable using pyobject? -


i'm using sphinx document parts of python code.

i include variable class in documentation.

for example, tried without success :

.. literalinclude:: myclass.py     :pyobject: myclass.avariable     :language: python 

i see 1 solution if code change in next release line numbers of variable change :

.. literalinclude:: myclass.py     :language: python     :lines: 2-3 

is there solution filter variable ?

as workaround, use start-after , end-before options have add 2 comments in code before , after variables.

for example :

the class :

class myclass():     # start variables     avariable = {"a":123 , "b":456}     # end variables          def __init__(self):             pass 

the rst file :

.. literalinclude:: myclass.py     :start-after: # start variables      :end-before: # end variables      :language: python 

it's not perfect, works.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -