Sphinx/autodoc does not generate enum variant doc-strings
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.2k
- Forks
- 1k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 66
Description
Hi,
Great library! I'm currently documenting our python extension, and I've found that docstrings of the enum variants specifically are not captured by autodoc. I've adapted the maturin starter example on my fork (https://github.com/hbierlee/pyo3/blob/feature/enum-variant-doc-string/examples/maturin-starter/src/lib.rs) to show the issue:
#[pyclass(eq, eq_int)]
#[derive(Clone, Copy, Debug, PartialEq)]
/// Some example enum
enum ExampleEnum {
/// Variant A
A,
/// Variant B
B,
}
After setting up sphinx and autodoc, running make html generates html documentation including the following snippet with the general enum docstring (i.e. /// Some example enum), but not those of the variants (e.g. /// Variant A):
<dl class="py class">
<dt class="sig sig-object py" id="maturin_starter.ExampleEnum">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">maturin_starter.</span></span><span class="sig-name descname"><span class="pre">ExampleEnum</span></span><a class="headerlink" href="#maturin_starter.ExampleEnum" title="Link to this definition">¶</a></dt>
<dd><p>Some example enum</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="maturin_starter.ExampleEnum.A">
<span class="sig-name descname"><span class="pre">A</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">ExampleEnum.A</span></em><a class="headerlink" href="#maturin_starter.ExampleEnum.A" title="Link to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="maturin_starter.ExampleEnum.B">
<span class="sig-name descname"><span class="pre">B</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">ExampleEnum.B</span></em><a class="headerlink" href="#maturin_starter.ExampleEnum.B" title="Link to this definition">¶</a></dt>
<dd></dd></dl>
Is this a bug or perhaps a missing feature?
Cheers,
Henk
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with examples/maturin-starter/src/lib.rs and reproduce the issue by setting up Sphinx/autodoc and running make html. Inspect the generated HTML for the enum and its variants; done means the Variant A and Variant B docstrings appear alongside the enum documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100