Skip to content

Commit 7ce7b16

Browse files
committed
improve docs
1 parent bc7220d commit 7ce7b16

10 files changed

Lines changed: 84 additions & 8 deletions

File tree

doc/_static/css/custom.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,12 @@ a:hover {
55
.wy-menu-vertical p.caption {
66
color: #d2b48c;
77
}
8+
9+
.sphinx-codeautolink-a{
10+
border-bottom-color: #d2b48c;
11+
border-bottom-style: solid;
12+
border-bottom-width: 1px;
13+
}
14+
.sphinx-codeautolink-a:hover{
15+
color: #888888;
16+
}

doc/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
"sphinx.ext.viewcode",
4646
# Mermaid diagrams
4747
"sphinxcontrib.mermaid",
48+
# Documentation links in code blocks
49+
"sphinx_codeautolink",
4850
]
4951
mermaid_d3_zoom = True
5052
napoleon_google_docstring = True
@@ -73,6 +75,7 @@
7375
html_css_files = [
7476
"css/custom.css",
7577
]
78+
html_logo = "logo.svg"
7679

7780
autoclass_content = "init"
7881
myst_heading_anchors = 7

doc/contributing.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ You can also use `uv pip install -e .[dev]` if you have the [`uv`](https://docs.
1616

1717
## Linting
1818

19-
Linting is performed by `ruff` (formatting & linting) and `pyright` (type-checking).
19+
Linting is performed by [ruff](https://docs.astral.sh/ruff/) (formatting & linting) and
20+
[pyright](https://github.com/microsoft/pyright) (type-checking).
2021

2122
```shell
2223
ruff format
@@ -26,8 +27,8 @@ pyright
2627

2728
## Documentation
2829

29-
Documentation is built using `sphinx`. To get a local development build of the docs, use
30-
`sphinx-autobuild doc _build --watch src`.
30+
Documentation is built using [sphinx](https://www.sphinx-doc.org/en/master/).
31+
To get a local development build of the docs, use `sphinx-autobuild doc _build --watch src`.
3132

3233
Spell checking is run automatically in CI - if a word is correctly spelt but the spellchecker flags it,
3334
add the word to `doc/spelling_wordlist.txt`.

doc/logo.svg

Lines changed: 18 additions & 0 deletions
Loading

doc/transports/epics_ca.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ raw mode; set {py:obj}`SecopQuirks.raw_struct <fastcs_secop.SecopQuirks.raw_stru
2424
{py:obj}`SecopQuirks.raw_matrix <fastcs_secop.SecopQuirks.raw_matrix>` is also recommended, as only 1-D matrices are
2525
supported by CA.
2626

27+
{#example_ca_ioc}
2728
## Example CA IOC
2829

2930
:::python

doc/transports/epics_pva.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Other data types can only be read or written in 'raw' mode.
2727
SECoP modules can be found under the top-level PVI structure, while SECoP accessibles can be found under
2828
`module_name:PVI`. This means that the IOC is self-describing to downstream clients.
2929

30+
{#example_pva_ioc}
3031
## Example PVA IOC
3132

3233
:::python

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ doc = [
3737
"sphinx_rtd_theme",
3838
"myst_parser",
3939
"sphinx-autobuild",
40+
"sphinx-codeautolink",
4041
"sphinxcontrib-mermaid",
4142
"sphinxcontrib-spelling",
4243
]

src/fastcs_secop/_controllers.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def __init__(
3737
) -> None:
3838
"""Subcontroller for a SECoP command.
3939
40+
This class is automatically added as a subcontroller by
41+
:py:obj:`SecopModuleController` for command-type parameters.
42+
4043
Args:
4144
connection: The connection to use.
4245
module_name: The module in which this command is defined.
@@ -134,8 +137,8 @@ def __init__(
134137
) -> None:
135138
"""FastCS controller for a SECoP module.
136139
137-
Instances of this class are added as subcontrollers by
138-
:py:obj:`SecopController`.
140+
This class is automatically added as a subcontroller by
141+
:py:obj:`SecopController` for each present SECoP module.
139142
140143
Args:
141144
connection: The connection to use.
@@ -217,6 +220,29 @@ class SecopController(Controller):
217220
def __init__(self, settings: IPConnectionSettings, quirks: SecopQuirks | None = None) -> None:
218221
"""FastCS Controller for a SECoP node.
219222
223+
The intended usage is via :py:obj:`fastcs.control_system.FastCS`:
224+
225+
.. code-block:: python
226+
227+
from fastcs_secop import SecopController, SecopQuirks
228+
from fastcs.control_system import FastCS
229+
230+
controller = SecopController(
231+
settings=IPConnectionSettings(ip="127.0.0.1", port=1234),
232+
quirks=SecopQuirks(...),
233+
)
234+
235+
transports = [...]
236+
237+
fastcs = FastCS(
238+
controller,
239+
transports,
240+
)
241+
fastcs.run()
242+
243+
See Also:
244+
:ref:`example_ca_ioc` and :ref:`example_pva_ioc` for examples of full configurations
245+
220246
Args:
221247
settings: The communication settings (e.g. IP address, port) at which
222248
the SECoP node is reachable.

src/fastcs_secop/_io.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ async def send(self, attr: AttrW[T, SecopAttributeIORef], value: T) -> None:
212212
encoded_value,
213213
)
214214
# Ugly, but I can't find a public alternative...
215+
# https://github.com/DiamondLightSource/FastCS/pull/292
215216
await attr._call_sync_setpoint_callbacks(value) # noqa: SLF001
216217
except ConnectionError:
217218
# Reconnect will be attempted in a periodic scan task
@@ -223,8 +224,8 @@ async def send(self, attr: AttrW[T, SecopAttributeIORef], value: T) -> None:
223224
class SecopRawAttributeIO(AttributeIO[str, SecopRawAttributeIORef]):
224225
"""Raw IO for a SECoP parameter of any type other than 'command'.
225226
226-
For "raw" IO, no serialization/deserialization is performed. All values are transmitted
227-
to/from FastCS as strings. It is up to the client to interpret those strings correctly.
227+
For "raw" IO, all values are transmitted to/from FastCS as strings.
228+
It is up to the client to interpret those strings correctly.
228229
229230
This is intended as a fallback mode for transports which cannot represent complex
230231
data types.
@@ -262,6 +263,7 @@ async def send(self, attr: AttrW[str, SecopRawAttributeIORef], value: str) -> No
262263
value,
263264
)
264265
# Ugly, but I can't find a public alternative...
266+
# https://github.com/DiamondLightSource/FastCS/pull/292
265267
await attr._call_sync_setpoint_callbacks(value) # noqa: SLF001
266268
except ConnectionError:
267269
# Reconnect will be attempted in a periodic scan task

src/fastcs_secop/_util.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,40 @@ class SecopQuirks:
2828
"""Skip creating any listed ``(module_name, accessible_name)`` tuples."""
2929

3030
raw_accessibles: Collection[tuple[str, str]] = field(default_factory=list)
31-
"""Create any listed ``(module_name, accessible_name)`` tuples in 'raw' mode."""
31+
"""Create any listed ``(module_name, accessible_name)`` tuples in raw mode.
32+
33+
JSON for the specified accessibles will be treated as strings.
34+
"""
3235

3336
raw_array: bool = False
3437
"""If the accessible has an array type, read it in raw mode.
38+
39+
JSON values for any array-type accessible will be treated as strings.
3540
"""
3641

3742
raw_matrix: bool = False
3843
"""If the accessible has a matrix type, read it in raw mode.
44+
45+
JSON values for any matrix-type accessible will be treated as strings.
46+
47+
This is useful for transports which cannot represent arbitrary N-dimensional
48+
arrays.
3949
"""
4050

4151
raw_tuple: bool = False
4252
"""If the accessible has a tuple type, read it in raw mode.
4353
54+
JSON values for any tuple-type accessible will be treated as strings.
55+
4456
This is useful for transports which do not support the FastCS
4557
:py:obj:`~fastcs.datatypes.table.Table` type.
4658
"""
4759

4860
raw_struct: bool = False
4961
"""If the accessible has a struct type, read it in raw mode.
5062
63+
JSON values for any struct-type accessible will be treated as strings.
64+
5165
This is useful for transports which do not support the FastCS
5266
:py:obj:`~fastcs.datatypes.table.Table` type.
5367
"""

0 commit comments

Comments
 (0)