Add a Sphinx extension to document cached properties of slots classes#1519
Add a Sphinx extension to document cached properties of slots classes#1519clayote wants to merge 35 commits intopython-attrs:mainfrom
Conversation
6fce05b to
365bc5c
Compare
|
I wrote a test for this, but it won't run in CI currently, because that test requires Sphinx to be installed. That's why the pre-commit check is failing. |
1daa5c1 to
b21e641
Compare
|
I need to make sure the |
|
I haven't a clue what's going on with those |
on a quick look I see two tests without docstrings |
|
Checks are passing, I think it's ready @hynek |
c824181 to
672bfb7
Compare
|
@clayote Your actions create a lot of noise and many notifications. It would be helpful if you did more work offline and and only post updates and questions when really needed. This would make it easier for reviewers/maintainers to help you. |
Sphinx looks at the cached properties first for these...
Overkill? Yeah, whatever
for more information, see https://pre-commit.ci
5858047 to
a31031b
Compare
for more information, see https://pre-commit.ci
|
@clayote: feel free to ping me when it's ready for me to test 👌🏼 |
|
@AdrianSosic Please do |
|
Huh, I guess I'd better write documentation for the extension. It's not part of the API, really? Where should it go... |
Thanks @webknjaz Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
And not its `__slots__` Thanks @webknjaz
Now that the `test` dependency group includes `docs`, the mark does nothing. Thanks @webknjaz
for more information, see https://pre-commit.ci
…inx-attr-getter-ext # Conflicts: # tests/test_slots.py
for more information, see https://pre-commit.ci
Summary
This is a small extension for Sphinx, the documentation generator that attrs uses. Where cached properties on slots classes were missing previously (#1325), this extension restores them.
I added a dictionary to slotted class objects,
__attrs_cached_properties__, where they keep the cached property objects for Sphinx.I wrapped the
__slots__tuple itself in a customcollections.abc.Sequencethat acts exactly like its tuple, but isn't considered one for the purposes ofisinstance(), because, currently, I have to do that in order to make Sphinx use the extension on slots. I have a PR for Sphinx open to make that unnecessary.To use the extension, add
"attrs.sphinx_cached_property"toextensionsin your Sphinxconf.py.Pull Request Check List
mainbranch – use a separate branch!Our CI fails if coverage is not 100%.
.pyi).typing-examples/baseline.pyor, if necessary,typing-examples/mypy.py.attr/__init__.pyi, they've also been re-imported inattrs/__init__.pyi.docs/api.rstby hand.@attr.s()and@attrs.define()have to be added by hand too.versionadded,versionchanged, ordeprecateddirectives.The next version is the second number in the current release + 1.
The first number represents the current year.
So if the current version on PyPI is 22.2.0, the next version is gonna be 22.3.0.
If the next version is the first in the new year, it'll be 23.1.0.
attrs.define()andattr.s(), you have to add version directives to both..rstand.mdfiles is written using semantic newlines.changelog.d.