Skip to content
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 support for Python type parameter lists #366

Merged
merged 1 commit into from
Jul 21, 2024
Merged

Conversation

jbms
Copy link
Owner

@jbms jbms commented Jul 10, 2024

Sphinx has partial support for type parameter lists: they are supported by the Python domain in signatures, but are not supported by autodoc.

This adds the following support:

  • Sphinx Python domain for type parameter fields in docstrings, with sphinx.ext.napoleon support as well.

  • Support for type parameters as Sphinx objects, with cross-linking, like the existing support for function parameters as Sphinx objects.

  • Support in apigen for PEP 695 type parameters, and for displaying pre-PEP 695 separately-defined TypeVar types as PEP 695 type parameters.

@jbms jbms requested a review from 2bndy5 July 10, 2024 20:55
@jbms jbms force-pushed the feat-python-type-parameters branch from a11336f to 3da9c2d Compare July 10, 2024 21:09
@jbms
Copy link
Owner Author

jbms commented Jul 10, 2024

This is basically feature complete but still needs some work on documentation and testing.

@jbms jbms force-pushed the feat-python-type-parameters branch 3 times, most recently from ea315d9 to 4d8f8d5 Compare July 10, 2024 22:43
@jbms
Copy link
Owner Author

jbms commented Jul 10, 2024

The build failure due to undefined reference T is odd --- the build succeeds on readthedocs and I also can't reproduce the issue locally. I will have to investigate more.

Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 62.72727% with 123 lines in your changes missing coverage. Please review.

Project coverage is 63.87%. Comparing base (7796775) to head (76ab811).

Files Patch % Lines
sphinx_immaterial/apidoc/python/apigen.py 32.50% 54 Missing ⚠️
...phinx_immaterial/apidoc/python/type_param_utils.py 74.26% 35 Missing ⚠️
...hinx_immaterial/apidoc/python/parameter_objects.py 72.11% 29 Missing ⚠️
...terial/apidoc/python/type_annotation_transforms.py 50.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #366      +/-   ##
==========================================
- Coverage   63.91%   63.87%   -0.05%     
==========================================
  Files          67       68       +1     
  Lines        8068     8359     +291     
==========================================
+ Hits         5157     5339     +182     
- Misses       2911     3020     +109     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jbms
Copy link
Owner Author

jbms commented Jul 19, 2024

CI now passes.

@jbms jbms force-pushed the feat-python-type-parameters branch from 28ef75d to 76ab811 Compare July 20, 2024 05:18
sphinx_immaterial/apidoc/python/apigen.py Outdated Show resolved Hide resolved
sphinx_immaterial/apidoc/python/parameter_objects.py Outdated Show resolved Hide resolved
@jbms jbms force-pushed the feat-python-type-parameters branch from e11db38 to 81b5961 Compare July 21, 2024 07:00
@jbms jbms requested a review from 2bndy5 July 21, 2024 07:00
Sphinx has partial support for type parameter lists: they are supported
by the Python domain in signatures, but are not supported by autodoc.

This adds the following support:

- Sphinx Python domain for type parameter fields in docstrings, with
  sphinx.ext.napoleon support as well.

- Support for type parameters as Sphinx objects, with cross-linking, like
  the existing support for function parameters as Sphinx objects.

- Support in apigen for PEP 695 type parameters, and for displaying
  pre-PEP 695 separately-defined TypeVar types as PEP 695 type parameters.

Co-authored-by: Brendan <2bndy5@gmail.com>
@jbms jbms force-pushed the feat-python-type-parameters branch from 81b5961 to 640b5c7 Compare July 21, 2024 21:28
@jbms jbms merged commit 7e2d559 into main Jul 21, 2024
60 checks passed
@jbms jbms deleted the feat-python-type-parameters branch July 21, 2024 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants