Skip to content

Commit 64d0c96

Browse files
authored
docs: Show documentation for tket.extensions module (#1872)
Fixes #1844 . I could not find any way to make sphinx's `autosummary` include the module-level constants (`argument` etc) imported from `tket_exts`, so this is a compromise soltution: - Export the class definitions from `tket_exts` (`ArgumentExtension` etc) so that these and their methods are documented. - Extend the module documentation so that it explains how the extensions can be imported directly. The main `extensions` page now looks like this: <img width="1131" height="2006" alt="image" src="https://github.com/user-attachments/assets/ad10ebf3-2ef9-4c52-b9f4-f9843217d51f" /> And if you click on `ArgumentExtension` (for example) you see this: <img width="1324" height="1676" alt="image" src="https://github.com/user-attachments/assets/d409889c-02da-4ba5-9a46-46a3ef711fd9" />
1 parent a5a2ad3 commit 64d0c96

1 file changed

Lines changed: 68 additions & 1 deletion

File tree

‎tket-py/tket/extensions/__init__.py‎

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
"""HUGR extension definitions for tket circuits.
2+
3+
Extensions may be imported directly as follows:
4+
5+
>>> import tket.extensions as ext
6+
>>>
7+
>>> argument_extension = ext.argument()
8+
>>> debug_extension = ext.debug()
9+
>>> futures_extension = ext.futures()
10+
>>> global_phase_extension = ext.global_phase()
11+
>>> gpu_extension = ext.gpu()
12+
>>> guppy_extension = ext.guppy()
13+
>>> measurement_extension = ext.measurement()
14+
>>> modifier_extension = ext.modifier()
15+
>>> qsystem_extension = ext.qsystem()
16+
>>> qsystem_helios_extension = ext.qsystem_helios()
17+
>>> qsystem_sol_extension = ext.qsystem_sol()
18+
>>> qsystem_random_extension = ext.qsystem_random()
19+
>>> qsystem_utils_extension = ext.qsystem_utils()
20+
>>> quantum_extension = ext.quantum()
21+
>>> result_extension = ext.result()
22+
>>> rotation_extension = ext.rotation()
23+
>>> wasm_extension = ext.wasm()
24+
>>>
25+
>>> read_arg_op = argument_extension.get_op("read_arg")
26+
OpDef(name='read_arg', signature=OpDefSig(poly_func=PolyFuncType(params=[StringParam(), TypeTypeParam(bound=TypeBound.Linear)], body=FunctionType([], [$1])), binary=False), description='Read a runtime argument of the given type identified by a string tag', misc={})
27+
>>> read_arg_op.description
28+
'Read a runtime argument of the given type identified by a string tag'
29+
>>> read_arg_op.signature
30+
OpDefSig(poly_func=PolyFuncType(params=[StringParam(), TypeTypeParam(bound=TypeBound.Linear)], body=FunctionType([], [$1])), binary=False)
31+
"""
32+
133
from tket_exts import (
234
argument,
335
debug,
@@ -17,7 +49,25 @@
1749
rotation,
1850
wasm,
1951
)
20-
52+
from tket_exts.tket.argument import ArgumentExtension
53+
from tket_exts.tket.debug import DebugExtension
54+
from tket_exts.tket.futures import FuturesExtension
55+
from tket_exts.tket.global_phase import GlobalPhaseExtension
56+
from tket_exts.tket.gpu import GpuExtension
57+
from tket_exts.tket.guppy import GuppyExtension
58+
from tket_exts.tket.measurement import MeasurementExtension
59+
from tket_exts.tket.modifier import ModifierExtension
60+
from tket_exts.tket.qsystem import (
61+
QSystemExtension,
62+
QSystemHeliosExtension,
63+
QSystemRandomExtension,
64+
QSystemSolExtension,
65+
QSystemUtilsExtension,
66+
)
67+
from tket_exts.tket.quantum import QuantumExtension
68+
from tket_exts.tket.result import ResultExtension
69+
from tket_exts.tket.rotation import RotationExtension
70+
from tket_exts.tket.wasm import WasmExtension
2171

2272
__all__ = [
2373
"argument",
@@ -37,4 +87,21 @@
3787
"result",
3888
"rotation",
3989
"wasm",
90+
"ArgumentExtension",
91+
"DebugExtension",
92+
"FuturesExtension",
93+
"GlobalPhaseExtension",
94+
"GpuExtension",
95+
"GuppyExtension",
96+
"MeasurementExtension",
97+
"ModifierExtension",
98+
"QSystemExtension",
99+
"QSystemHeliosExtension",
100+
"QSystemRandomExtension",
101+
"QSystemSolExtension",
102+
"QSystemUtilsExtension",
103+
"QuantumExtension",
104+
"ResultExtension",
105+
"RotationExtension",
106+
"WasmExtension",
40107
]

0 commit comments

Comments
 (0)