Skip to content

Commit

Permalink
better docs
Browse files Browse the repository at this point in the history
  • Loading branch information
joamatab committed May 4, 2024
1 parent 0a73a37 commit cdd6457
Show file tree
Hide file tree
Showing 15 changed files with 474 additions and 278 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from cspdk.si220 import _cells as cells
from cspdk.si220.config import PATH

filepath = PATH.repo / "docs" / "cells.rst"
filepath = PATH.repo / "docs" / "cells_si220.rst"

skip = {}

Expand Down
65 changes: 65 additions & 0 deletions .github/write_cells_sin300.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import inspect

from cspdk.sin300 import _cells as cells
from cspdk.sin300.config import PATH

filepath = PATH.repo / "docs" / "cells_sin300.rst"

skip = {}

skip_plot: tuple[str, ...] = ("",)
skip_settings: tuple[str, ...] = ()


with open(filepath, "w+") as f:
f.write(
"""
Cells SiN300
=============================
"""
)

for name in sorted(cells.keys()):
if name in skip or name.startswith("_"):
continue
print(name)
sig = inspect.signature(cells[name])
kwargs = ", ".join(
[
f"{p}={repr(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:: cspdk.si220.cells.{name}
"""
)
else:
f.write(
f"""
{name}
----------------------------------------------------
.. autofunction:: cspdk.si220.cells.{name}
.. plot::
:include-source:
import cspdk
c = cspdk.si220.cells.{name}({kwargs})
c.plot()
"""
)
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.7"
rev: "v0.4.1"
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- id: ruff-format

- repo: https://github.com/shellcheck-py/shellcheck-py
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ notebooks:
jupytext docs/**/*.py --to ipynb

docs:
python .github/write_cells_si220.py
python .github/write_cells_sin300.py
jb build docs

.PHONY: drc doc docs
2 changes: 1 addition & 1 deletion cspdk/si220/import_pdk.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" From a list of GDS files, generate a script to import the cells from a pdk """
"""From a list of GDS files, generate a script to import the cells from a pdk"""

import gdsfactory as gf

Expand Down
2 changes: 1 addition & 1 deletion cspdk/si220/samples/get_route_sc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""`get_route` returns a Manhattan route between two ports. """
"""`get_route` returns a Manhattan route between two ports."""

import gdsfactory as gf

Expand Down
1 change: 1 addition & 0 deletions cspdk/si220/samples/mode_solver_r.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Silicon rib mode solver."""

import gplugins.tidy3d as gt

nm = 1e-3
Expand Down
1 change: 1 addition & 0 deletions cspdk/si220/samples/mode_solver_s.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Silicon mode solver."""

import gplugins.tidy3d as gt

nm = 1e-3
Expand Down
2 changes: 1 addition & 1 deletion cspdk/sin300/import_pdk.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" From a list of GDS files, generate a script to import the cells from a pdk """
"""From a list of GDS files, generate a script to import the cells from a pdk"""

import gdsfactory as gf

Expand Down
2 changes: 1 addition & 1 deletion cspdk/sin300/samples/get_route_nc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""`get_route` returns a Manhattan route between two ports. """
"""`get_route` returns a Manhattan route between two ports."""

import gdsfactory as gf

Expand Down
1 change: 1 addition & 0 deletions cspdk/sin300/samples/mode_solver_n.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nitride mode solver."""

import gplugins.tidy3d as gt

nm = 1e-3
Expand Down
3 changes: 2 additions & 1 deletion docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ parts:
# - file: notebooks/demo
- caption: Reference
chapters:
- file: cells
- file: cells_si220
- file: cells_sin300
- file: changelog
Loading

0 comments on commit cdd6457

Please sign in to comment.