-
Notifications
You must be signed in to change notification settings - Fork 184
/
write_components_doc.py
78 lines (56 loc) · 1.52 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
import inspect
import pathlib
import gdsfactory as gf
from gdsfactory.serialization import clean_value_json
filepath = pathlib.Path(__file__).parent.absolute() / "pcells.rst"
skip = {}
skip_plot = [
"component_lattice",
"component_sequence",
"extend_port",
"extend_ports_list",
]
skip_settings = {"vias"}
with open(filepath, "w+") as f:
f.write(
"""
Here are some generic Parametric cells.
You can customize them your fab or use them as an inspiration to build your own.
Parametric cells
=============================
"""
)
for name in sorted(gf.pcells.cells.keys()):
if name in skip or name.startswith("_"):
continue
print(name)
sig = inspect.signature(gf.pcells.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.pcells.{name}
"""
)
else:
f.write(
f"""
{name}
----------------------------------------------------
.. autofunction:: gdsfactory.pcells.{name}
.. plot::
:include-source:
import gdsfactory as gf
c = gf.pcells.{name}({kwargs})
c.plot_matplotlib()
"""
)