astropy / astropy/sphinx-automodapi

Module-level variable "docstrings" not picked up

Open
#36 1 comment 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
Python
Stars
67
Forks
48
Avg merge
11h 52m
Merged PRs (30d)
1

Description

@mhvk - I see you've implemented an option to add module-level variables to automodapi in #24 .
This is something I've wanted for Gammapy for a long time, thank you!

One question I have is how one should document those variables.
In the test case you add in #24 you have
```
PARROT_STATE = 'dead'
"""The global state of the parrot."""
```
and I would have expected `"""The global state of the parrot."""` to show up in the HTML docs.
But instead this is shown: `str(object=’‘) -> str`.
So apparently `PARROT_STATE.__doc__` is used directly.

What should we do here?
Change Sphinx to find and use the string following the variable in the output?
Or just write "variable docstrings" like this?
```
PARROT_STATE = 'dead'
PARROT_STATE.__doc__ = """The global state of the parrot."""
```

Whatever decision is made, I think this should be mentioned in the docs, and maybe even the test should be changed to make sure `PARROT_STATE.__doc__` is picked up correctly by Sphinx.

cc @astrofrog - Maybe you have an opinion here as well?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the module-level-variable implementation and test case introduced in #24, then compare the generated HTML with the variable's following string and its __doc__ value. Decide which documentation convention Sphinx should support, update the documentation to describe it, and change or add the test so the chosen variable documentation appears correctly in the HTML output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.