Skip to content

Commit

Permalink
Improve docstrings for abstract hardware objects
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fabcor-maxiv authored and marcus-oscarsson committed Jan 31, 2025
1 parent 88fd83a commit 4fb8498
Show file tree
Hide file tree
Showing 9 changed files with 947 additions and 404 deletions.
10 changes: 9 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@

extensions.append("sphinx.ext.napoleon")

napoleon_custom_sections = [
("Emits", "params_style"),
]

napoleon_numpy_docstring = False


Expand All @@ -99,7 +103,11 @@

extensions.append("myst_parser")

myst_enable_extensions = ("fieldlist",)
myst_enable_extensions = (
"attrs_block",
"colon_fence",
"fieldlist",
)


# -- Options for sphinxcontrib.mermaid
Expand Down
21 changes: 21 additions & 0 deletions docs/source/dev/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,27 @@ extension is enabled to handle docstrings within the Python code
and it is configured for
[Google-style docstrings](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings).

#### Custom sections for docstrings

A
[custom section](https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html#confval-napoleon_custom_sections)
title for docstrings is available to document *hardware objects*:

* `Emits` for signals emitted by *hardware objects*

It can be used like in this example:

```python
class Thing(HardwareObject):
"""Some thing.
Emits:
isReady (bool):
Emitted when the readiness state changes.
"""
```


### Diagrams

The
Expand Down
Loading

0 comments on commit 4fb8498

Please sign in to comment.