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 constants to API reference #240

Merged

Conversation

larshinueber
Copy link
Contributor

Hi all,

I was looking at how to document the constants module.
From what I found, I dont think it is possible to document a module attribute in the pybind11 exposure directly, since these are represented by variables in Python. When trying to document them in Sphinx using autodoc, the docstring will then just show the generic docstring of the variable type (e.g. float or complex), similar to what is returned by the help() function.

To avoid this, I would propose to overwrite these automatically-generated docstrings in Sphinx with just the type information and then add the docstrings in the .rst file. This breaks the philosophy of having the docstrings right next to the exposures, and creates a mismatch between the docstrings shown on the API reference and returned by the help() function (and in the future possible stubs/type-hints).

But since there is (seemingly) no way around this at the moment and the constants module doesn't change frequently, I would argue that this acceptable at the moment and outweighed by having a module documentation at all (?).

What do you think? See a draft version of the docs here:

image

@larshinueber larshinueber changed the title Feature/add api constants page Add constants to API reference Feb 16, 2025
@larshinueber larshinueber linked an issue Feb 16, 2025 that may be closed by this pull request
@DominicDirkx
Copy link
Member

I remember looking into this a while ago and also not finding any solution, so this is great!

One thing: could you remove the 'long' constants? They're no different than the regular ones in Python , and will just lead to confusion.

Thanks so much for setting this up!

@larshinueber
Copy link
Contributor Author

Yes, going through the pybind- and Sphinx-specifics was indeed a journey 😅

Long constants should be removed now :)

@DominicDirkx DominicDirkx merged commit fcb08c2 into tudat-team:develop Feb 16, 2025
1 of 2 checks passed
@DominicDirkx
Copy link
Member

And merged, great to have this finally 👏

@larshinueber larshinueber deleted the feature/add-api-constants-page branch February 16, 2025 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

Add API docs for the tudatpy.kernel.constants module
2 participants