I am using VuePress for documentation, but find the more precise formatting and support for Python code in reStructured Text useful at times.
How can I use Sphinx and/or reStructuredText to generate fragments of HTML that I will later integrate?
How can I programmatically drive Sphinx autodoc directives is basically what my question is about. I saw something from 2003 about Sphinx parts, but what's the current way to do it?
Example:
given file test.rst:
######
.. autoclass:: mymodule.MyClass
:members: __init__, process
######
And mymodule.py
class MyClass:
def __init__(self, *args, **kwargs):
""" init """
def process(self, f_out : "file"):
"process"
print("I am processing")
I can generate html documentation with
sphinx-build -a . ./out
and opening the generated out/test.html gives me:
where the part that I am interested in is really only:
<dl class="class">
<dt id="mymodule.MyClass">
<em class="property">class </em><code class="sig-prename descclassname">mymodule.</code><code
class="sig-name descname">MyClass</code><span class="sig-paren">(</span><em class="sig-param">*args</em>,
<em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="headerlink"
href="#mymodule.MyClass" title="Permalink to this definition">¶</a></dt>
<dd>
✂️✂️✂️✂️
</dd>
</dl>