Skip to content

Commit

Permalink
Add docstrings without breaking type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed Jan 29, 2025
1 parent e5e9df0 commit e2faf90
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
30 changes: 16 additions & 14 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
https://www.sphinx-doc.org/en/master/usage/configuration.html
"""

import os
import sys
from pathlib import Path
from subprocess import check_output
from typing import TypeVar

import requests

import ophyd_async

# Override location of typevars just for sphinx
ophyd_async.core.SignalDatatypeT.__module__ = "ophyd_async.core"
for k in ophyd_async.core.__all__:
v = getattr(ophyd_async.core, k)
if isinstance(v, TypeVar):
v.__module__ = "ophyd_async.core"

# -- General configuration ------------------------------------------------
sys.path.insert(0, os.path.abspath("../../src"))
# General information about the project.
project = "ophyd-async"
copyright = "2014, Brookhaven National Lab"
Expand Down Expand Up @@ -81,16 +82,17 @@
# domain name if present. Example entries would be ('py:func', 'int') or
# ('envvar', 'LD_LIBRARY_PATH').
nitpick_ignore = [
# builtins
("py:class", "NoneType"),
("py:class", "'str'"),
("py:class", "'float'"),
("py:class", "'int'"),
("py:class", "'bool'"),
("py:class", "'object'"),
("py:class", "'id'"),
# typing
("py:class", "typing_extensions.Literal"),
("py:class", "ophyd_async.core._utils.T"),
# # builtins
# ("py:class", "NoneType"),
# ("py:class", "'str'"),
# ("py:class", "'float'"),
# ("py:class", "'int'"),
# ("py:class", "'bool'"),
# ("py:class", "'object'"),
# ("py:class", "'id'"),
# # typing
# ("py:class", "typing_extensions.Literal"),
]

# Order the members by the order they appear in the source code
Expand Down
23 changes: 12 additions & 11 deletions src/ophyd_async/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The building blocks for making devices."""

from typing import TYPE_CHECKING

from ._detector import (
Expand Down Expand Up @@ -84,18 +85,18 @@
from ._yaml_settings import YamlSettingsProvider

# Docstrings must be added here for sphinx
if not TYPE_CHECKING:
SignalDatatypeT = SignalDatatypeT
"""The supported `Signal` datatypes:
SignalDatatypeT = SignalDatatypeT
"""The supported `Signal` datatypes:
- A python primitive `bool`, `int`, `float`, `str`
- A `StrictEnum` or `SubsetEnum` subclass
- A fixed datatype `Array1D` of numpy bool, signed and unsigned integers or float
- A `np.ndarray` which can change dimensions and datatype at runtime
- A `Sequence` of `str`
- A `Sequence` of `StrictEnum` or `SubsetEnum` subclass
- A `Table` subclass
"""
- A python primitive `bool`, `int`, `float`, `str`
- A `StrictEnum` or `SubsetEnum` subclass
- A fixed datatype `Array1D` of numpy bool, signed and unsigned integers or float
- A `np.ndarray` which can change dimensions and datatype at runtime
- A `Sequence` of `str`
- A `Sequence` of `StrictEnum` or `SubsetEnum` subclass
- A `Table` subclass
"""


__all__ = [
Expand Down

0 comments on commit e2faf90

Please sign in to comment.