-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add type information to create_ and add_ method documentation #620
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #620 +/- ##
==========================================
+ Coverage 93.92% 93.94% +0.02%
==========================================
Files 95 95
Lines 5165 5184 +19
==========================================
+ Hits 4851 4870 +19
Misses 314 314
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I don't know why EDIT: This is a Sphinx bug, see sphinx-doc/sphinx#11207. Probably worth investigating if this can be easily fixed upstream. |
5d735e8
to
20a3e7d
Compare
For now, I have added a monkeypatch that simply uses the builtin |
Marked as draft because there is an issue with |
Provide type information for the parameters of the ``create_*`` and ``add_*`` methods in the documentation. The __signature__ of the methods is constructed from from the wrapped class's signature, only adding a 'self' parameter. The 'sphinx-autodoc-typehints' extension previously used does not support showing this dynamically created signature, so it was replaced by using the built-in type hint support of 'sphinx.ext.autodoc'. Return types are provided in the signature, but Sphinx incorrectly shows the generic type (e.g. CreatableTreeObject) instead of the one present in __signature__. Since this is not useful, the return type is hidden unless specifically documented. Closes #612
5c43235
to
836e1fb
Compare
e3fdf7b
to
df424ff
Compare
Provide type information for the parameters of the
create_*
andadd_*
methods in the documentation.The
__signature__
of the methods is constructed from from the wrapped class's signature, only adding a 'self' parameter.For the
add_*
methods, theParameters
block (and everything below it) is now also obtained from the class if present.The 'sphinx-autodoc-typehints' extension previously used does not support showing this dynamically created signature, so it was replaced by using the built-in type hint support of 'sphinx.ext.autodoc'. The only drawback is that defaults are now shown only in the signature, and no longer in the description.
Since 'sphinx.ext.autodoc' however overwrites the class parameter type hints with the class attribute type hints, the helper function used to generate the signature is monkeypatched.
Closes #612