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

Custom parser for type hints #10

Closed
1 task
araffin opened this issue May 9, 2020 · 2 comments · Fixed by #169
Closed
1 task

Custom parser for type hints #10

araffin opened this issue May 9, 2020 · 2 comments · Fixed by #169
Labels
enhancement New feature or request help wanted Help from contributors is welcomed
Milestone

Comments

@araffin
Copy link
Member

araffin commented May 9, 2020

Type hints are nice to check the code but it makes the documentation hard to read.
We should write a custom parser to display the hints in a cleaner way.

Related: https://michaelgoerz.net/notes/extending-sphinx-napoleon-docstring-sections.html

and https://github.com/agronholm/sphinx-autodoc-typehints

Update after #167: Above added. Remaining TODOs:

  • Clean up parentheses in the type hinting (they are formatted as standard text, not in code-style).

Regex used:

(:((param)|(return))\s*[a-zA_z_0-9]*:) (\([a-zA-Z_\[\]\s,\.0-9]+\))

and replace with $1.

@araffin araffin added enhancement New feature or request help wanted Help from contributors is welcomed labels May 9, 2020
@araffin araffin added this to the v1.0 milestone May 9, 2020
@AdamGleave
Copy link
Collaborator

Similar issue we should probably fix at the same time: a lot of the docstrings still have types in them, even though the function has type annotations. This causes the types to appear twice in the generated documentation: once in the signature, and once in the parameter description.

@araffin
Copy link
Member Author

araffin commented May 11, 2020

This causes the types to appear twice in the generated documentation: once in the signature, and once in the parameter description.

Good point. In fact, at first, I started removing all type hints from the docstrings and using sphinx type hint plugin, but I stopped because it made the doc quite ugly.
Also, because of that, there are inconsistencies between docstrings and type hints... (that's also what I meant by "cleaning the docstrings")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Help from contributors is welcomed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants