https://github.com/SoftwareHeritage/swh-model
Revision 76b744e08fbf37d5a5313987b1e7a7ad1870125d authored by Valentin Lorentz on 14 December 2020, 16:38:29 UTC, committed by Valentin Lorentz on 15 December 2020, 13:10:04 UTC
Unfortunately, sphinx (actually, autodoc) only picks up attributes if
they fall in any of these cases:

1. are enum variants
2. are in slots
3. are in __dict__
4. have an annotation
5. are found using its custom parser

(see get_object_members in sphinx/ext/autodoc/importer.py)

In theory, option 5 should work for us; unfortunately, autodoc only
asks the parser the list of members with a comment.
And it's not easy to adapt it to ask the parser for all members,
because said parser (sphinx/pycode/parser.py) does not return the class
qualname (aka. namespace) for members without comments.

So, as I don't want to change the interface of sphinx.pycode.parser,
this commit switches to relying on option 3, by adding __slots__ for
all attr classes.

Additionally, this might have some performance/memory improvement
(though I did not check) and will further avoid mutation of these
objects.
1 parent a3b6a64
History
Tip revision: 76b744e08fbf37d5a5313987b1e7a7ad1870125d authored by Valentin Lorentz on 14 December 2020, 16:38:29 UTC
model: Make all classes slotted.
Tip revision: 76b744e
File Mode Size
bin
docs
swh
.gitignore -rw-r--r-- 137 bytes
.pre-commit-config.yaml -rw-r--r-- 1021 bytes
AUTHORS -rw-r--r-- 112 bytes
CODE_OF_CONDUCT.md -rw-r--r-- 3.3 KB
CONTRIBUTORS -rw-r--r-- 45 bytes
LICENSE -rw-r--r-- 34.3 KB
MANIFEST.in -rw-r--r-- 157 bytes
Makefile -rw-r--r-- 163 bytes
Makefile.local -rw-r--r-- 24 bytes
README.md -rw-r--r-- 620 bytes
mypy.ini -rw-r--r-- 571 bytes
pyproject.toml -rw-r--r-- 237 bytes
pytest.ini -rw-r--r-- 135 bytes
requirements-cli.txt -rw-r--r-- 30 bytes
requirements-test.txt -rw-r--r-- 26 bytes
requirements.txt -rw-r--r-- 318 bytes
setup.cfg -rw-r--r-- 247 bytes
setup.py -rwxr-xr-x 2.5 KB
tox.ini -rw-r--r-- 488 bytes

README.md

back to top