Support variable definitions in literalinclude's pyobject option
#6.119 aberto em 1 de mar. de 2019
Métricas do repositório
- Stars
- (5.625 stars)
- Métricas de merge de PR
- (Mesclagem média 10d 11h) (11 fundiu PRs em 30d)
Description
The :pyobject: option of the literalinclude directive is great for including only a specific definition of a module. Currently (Sphinx 1.8.4), it supports class and function definitions. I suggest to extend this to also support module-level variable definitions.
An example from my personal use case: I use collections.namedtuple in my code for creating simple record-like classes:
MyClass = namedtuple('MyClass', 'attribute1, attribute2')
Since they don't use a "real" class definition, I cannot show their definition using :pyobject:.
A possible alternative to supporting variable definitions in :pyobject: which might be more flexible would be to support grepping lines using a regex. I could then do
.. literalinclude:: my_module.py
:regex: ^MyClass\s*=