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 custom docstring sections for hardware objects #947

Conversation

fabcor-maxiv
Copy link
Contributor

No description provided.

@fabcor-maxiv fabcor-maxiv self-assigned this Jun 27, 2024
@fabcor-maxiv
Copy link
Contributor Author

This adds two custom docstring sections:

  • Emits
  • Hardware object properties

I believe there is some "bikeshedding" to be made:

  • the names are inconsistent, I feel like we should get rid of the Hardware object prefix.
  • I do not know if Properties is the best choice of word here
  • Maybe Emits could be replaces by Signals

The Emits was actually introduced in #866 which is not merged yet (cc @meguiraun, see below).

The Hardware object properties was requested by @elmjag for a change that is not in GitHub (yet), and I believe it is a good idea.

@meguiraun for info, I also reused the AbstractActuator changes that you made in #866 as base for an example on how to use these in docstrings. But now, this might cause merge conflict...

You can preview how it renders at:

@fabcor-maxiv fabcor-maxiv force-pushed the docs-napoleon-custom-sections branch 2 times, most recently from d714841 to f064ad3 Compare June 27, 2024 14:32
@fabcor-maxiv fabcor-maxiv force-pushed the docs-napoleon-custom-sections branch from f064ad3 to 3911ebb Compare June 27, 2024 14:41
@marcus-oscarsson
Copy link
Member

Nice, we should be careful with the Hardware object properties because the configuration will be defined by a Pydantic model and the properties accessed via .config or directly via the hardware object it self (if its a role). In this case the Hardware object properties would be on the configuration object I guess.

I don't mind if we add this in the mean time, but it does mean that we will, probably, need to change it later.

@fabcor-maxiv
Copy link
Contributor Author

Nice, we should be careful with the Hardware object properties because the configuration will be defined by a Pydantic model and the properties accessed via .config or directly via the hardware object it self (if its a role). In this case the Hardware object properties would be on the configuration object I guess.

I don't mind if we add this in the mean time, but it does mean that we will, probably, need to change it later.

Right... I did not have the Pydantic story fully in mind. I am still not clear on how it will look like. But maybe with the Pydantic models, it will be self-documenting somehow... I do not know. I would be interested in seeing concrete examples.

I guess I do not mind changing it back to something else when it is time, and anyway I doubt anyone will have time/energy to write many such docstrings before the migration : D

@rhfogh
Copy link
Collaborator

rhfogh commented Jun 27, 2024

I agree with @marcus-oscarsson

@marcus-oscarsson
Copy link
Member

Its still a very preliminary draft but it would/could look something like this:

HOConfig = AbstractDetectorConfiguration

The model could be better specified through Field and given a description as well (which is not yet the case in the example). So it is indeed to a certain extent self describing but one could of course imagine a class level documentation of the model.

class AbstractDetectorConfiguration(BaseModel): # , extra=Extra.forbid):

@fabcor-maxiv
Copy link
Contributor Author

Seems like this could help, looks promising: https://pypi.org/project/autodoc_pydantic/

I close this pull request for now.

@marcus-oscarsson
Copy link
Member

Wow, thats seems nice. I think the emit documentation is still very nice though !

@fabcor-maxiv
Copy link
Contributor Author

I think the emit documentation is still very nice though !

I will try to take over #866 then, that would make more sense.

@marcus-oscarsson
Copy link
Member

Ok

fabcor-maxiv added a commit to fabcor-maxiv/mxcubecore that referenced this pull request Jan 30, 2025
General improvements to the docstrings of abstract hardware objects:

* Add an `Emits` custom section for Sphinx's Napoleon extension
* Fix docstrings formatting
* Document some emitted signals
* Move types from docstring to type hints when possible
* Som formatting with `black`

GitHub: supersedes mxcube#866
GitHub: supersedes mxcube#947
fabcor-maxiv added a commit to fabcor-maxiv/mxcubecore that referenced this pull request Jan 30, 2025
General improvements to the docstrings of abstract hardware objects:

* Add an `Emits` custom section for Sphinx's Napoleon extension
* Fix docstrings formatting
* Document some emitted signals
* Move types from docstring to type hints when possible
* Som formatting with `black`

GitHub: supersedes mxcube#866
GitHub: supersedes mxcube#947
fabcor-maxiv added a commit to fabcor-maxiv/mxcubecore that referenced this pull request Jan 31, 2025
General improvements to the docstrings of abstract hardware objects:

* Add an `Emits` custom section for Sphinx's Napoleon extension
* Fix docstrings formatting
* Document some emitted signals
* Move types from docstring to type hints when possible
* Som formatting with `black`

GitHub: supersedes mxcube#866
GitHub: supersedes mxcube#947
fabcor-maxiv added a commit to fabcor-maxiv/mxcubecore that referenced this pull request Jan 31, 2025
General improvements to the docstrings of abstract hardware objects:

* Add an `Emits` custom section for Sphinx's Napoleon extension
* Fix docstrings formatting
* Document some emitted signals
* Move types from docstring to type hints when possible
* Som formatting with `black`

GitHub: supersedes mxcube#866
GitHub: supersedes mxcube#947
fabcor-maxiv added a commit to fabcor-maxiv/mxcubecore that referenced this pull request Jan 31, 2025
General improvements to the docstrings of abstract hardware objects:

* Add an `Emits` custom section for Sphinx's Napoleon extension
* Fix docstrings formatting
* Document some emitted signals
* Move types from docstring to type hints when possible
* Som formatting with `black`

GitHub: supersedes mxcube#866
GitHub: supersedes mxcube#947
fabcor-maxiv added a commit to fabcor-maxiv/mxcubecore that referenced this pull request Jan 31, 2025
General improvements to the docstrings of abstract hardware objects:

* Add an `Emits` custom section for Sphinx's Napoleon extension
* Fix docstrings formatting
* Document some emitted signals
* Move types from docstring to type hints when possible
* Som formatting with `black`

GitHub: supersedes mxcube#866
GitHub: supersedes mxcube#947
marcus-oscarsson pushed a commit that referenced this pull request Jan 31, 2025
General improvements to the docstrings of abstract hardware objects:

* Add an `Emits` custom section for Sphinx's Napoleon extension
* Fix docstrings formatting
* Document some emitted signals
* Move types from docstring to type hints when possible
* Som formatting with `black`

GitHub: supersedes #866
GitHub: supersedes #947
@fabcor-maxiv
Copy link
Contributor Author

Done in #1116.

@fabcor-maxiv fabcor-maxiv deleted the docs-napoleon-custom-sections branch January 31, 2025 13:44
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.

3 participants