-
Notifications
You must be signed in to change notification settings - Fork 183
/
write_components_doc.py
79 lines (57 loc) · 1.74 KB
/
write_components_doc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import inspect
import gdsfactory as gf
from gdsfactory.config import PATH
from gdsfactory.serialization import clean_value_json
filepath = PATH.repo / "docs" / "components.rst"
skip = {}
skip_plot = [
"component_lattice",
"component_sequence",
"extend_port",
"extend_ports_list",
]
skip_settings = {"vias"}
with open(filepath, "w+") as f:
f.write(
"""
Generic PDK
=============================
Parametric Cells for the Generic PDK.
Consider them a foundation from which you can draw inspiration. Feel free to modify their cross-sections and layers to tailor a unique PDK suited for any foundry of your choice.
By doing so, you'll possess a versatile, retargetable PDK, empowering you to design your circuits with speed and flexibility.
"""
)
for name in sorted(gf.components.cells.keys()):
if name in skip or name.startswith("_"):
continue
print(name)
sig = inspect.signature(gf.components.cells[name])
kwargs = ", ".join(
[
f"{p}={repr(clean_value_json(sig.parameters[p].default))}"
for p in sig.parameters
if isinstance(sig.parameters[p].default, int | float | str | tuple)
and p not in skip_settings
]
)
if name in skip_plot:
f.write(
f"""
{name}
----------------------------------------------------
.. autofunction:: gdsfactory.components.{name}
"""
)
else:
f.write(
f"""
{name}
----------------------------------------------------
.. autofunction:: gdsfactory.components.{name}
.. plot::
:include-source:
import gdsfactory as gf
c = gf.components.{name}({kwargs})
c.plot()
"""
)