Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | # Copyright 2020 SkyWater PDK Authors |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | # SPDX-License-Identifier: Apache-2.0 |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 17 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 18 | # |
| 19 | # Configuration file for the Sphinx documentation builder. |
| 20 | # |
| 21 | # This file does only contain a selection of the most common options. For a |
| 22 | # full list see the documentation: |
| 23 | # http://www.sphinx-doc.org/en/master/config |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 24 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 25 | # -- Path setup -------------------------------------------------------------- |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 26 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 27 | # If extensions (or modules to document with autodoc) are in another directory, |
| 28 | # add these directories to sys.path here. If the directory is relative to the |
| 29 | # documentation root, use os.path.abspath to make it absolute, like shown here. |
| 30 | # |
| 31 | import docutils |
| 32 | import os |
| 33 | import re |
| 34 | # import sys |
| 35 | # sys.path.insert(0, os.path.abspath('.')) |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 36 | |
| 37 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 38 | # -- Project information ----------------------------------------------------- |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 39 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 40 | project = 'SkyWater SKY130 PDK' |
| 41 | copyright = '2020, SkyWater PDK Authors' |
| 42 | author = 'SkyWater PDK Authors' |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 43 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 44 | # The short X.Y version |
| 45 | version = '' |
| 46 | # The full version, including alpha/beta/rc tags |
| 47 | release = '' |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 48 | |
| 49 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 50 | # -- General configuration --------------------------------------------------- |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 51 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 52 | # If your documentation needs a minimal Sphinx version, state it here. |
| 53 | # |
| 54 | # needs_sphinx = '1.0' |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 55 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 56 | # Add any Sphinx extension module names here, as strings. They can be |
| 57 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom |
| 58 | # ones. |
| 59 | extensions = [ |
| 60 | 'sphinx.ext.autodoc', |
| 61 | 'sphinx.ext.autosectionlabel', |
| 62 | 'sphinx.ext.githubpages', |
| 63 | 'sphinx.ext.ifconfig', |
| 64 | 'sphinx.ext.mathjax', |
| 65 | 'sphinx.ext.napoleon', |
| 66 | 'sphinx.ext.todo', |
| 67 | 'sphinxcontrib_hdl_diagrams', |
| 68 | ] |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 69 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 70 | # Add any paths that contain templates here, relative to this directory. |
| 71 | templates_path = ['_templates'] |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 72 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 73 | # The suffix(es) of source filenames. |
| 74 | # You can specify multiple suffix as a list of string: |
| 75 | # |
| 76 | # source_suffix = ['.rst', '.md'] |
| 77 | source_suffix = '.rst' |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 78 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 79 | # The master toctree document. |
| 80 | master_doc = 'index' |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 81 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 82 | # Enable github links when not on readthedocs |
| 83 | on_rtd = os.environ.get('READTHEDOCS', None) == 'True' |
| 84 | if not on_rtd: |
| 85 | html_context = { |
| 86 | "display_github": True, # Integrate GitHub |
| 87 | "github_user": "google", # Username |
| 88 | "github_repo": "skywater-pdk", # Repo name |
| 89 | "github_version": "master", # Version |
| 90 | "conf_py_path": "/doc/", |
| 91 | } |
| 92 | else: |
| 93 | docs_dir = os.path.abspath(os.path.dirname(__file__)) |
| 94 | print("Docs dir is:", docs_dir) |
| 95 | import subprocess |
| 96 | subprocess.call('git fetch origin --unshallow', cwd=docs_dir, shell=True) |
| 97 | subprocess.check_call('git fetch origin --tags', cwd=docs_dir, shell=True) |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 98 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 99 | # The version info for the project you're documenting, acts as replacement for |
| 100 | # |version| and |release|, also used in various other places throughout the |
| 101 | # built documents. |
| 102 | # |
| 103 | # The full version, including alpha/beta/rc tags. |
| 104 | release = re.sub('^v', '', os.popen('git describe ').read().strip()) |
| 105 | # The short X.Y version. |
| 106 | version = release |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 107 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 108 | # The language for content autogenerated by Sphinx. Refer to documentation |
| 109 | # for a list of supported languages. |
| 110 | # |
| 111 | # This is also used if you do content translation via gettext catalogs. |
| 112 | # Usually you set "language" from the command line for these cases. |
| 113 | language = None |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 114 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 115 | # List of patterns, relative to source directory, that match files and |
| 116 | # directories to ignore when looking for source files. |
| 117 | # This pattern also affects html_static_path and html_extra_path. |
| 118 | exclude_patterns = [ |
| 119 | '_build', |
| 120 | 'env', |
| 121 | 'Thumbs.db', |
| 122 | '.DS_Store', |
| 123 | # Files included in other rst files. |
| 124 | 'code-of-conduct.rst', |
| 125 | 'rules/periphery-rules.rst', |
| 126 | 'rules/device-details/*/index.rst', |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 127 | 'rules/summary/*-key.rst', |
| 128 | 'rules/layers/*-key.rst', |
| 129 | 'rules/hv/*-key.rst', |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 130 | ] |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 131 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 132 | # The name of the Pygments (syntax highlighting) style to use. |
| 133 | pygments_style = None |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 134 | |
| 135 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 136 | # -- Options for HTML output ------------------------------------------------- |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 137 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 138 | # Prefix each section label with the name of the document it is in, followed by |
| 139 | # a colon. For example, index:Introduction for a section called Introduction |
| 140 | # that appears in document index.rst. Useful for avoiding ambiguity when the |
| 141 | # same section heading appears in different documents. |
| 142 | #autosectionlabel_prefix_document = True |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 143 | |
| 144 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 145 | # -- Options for HTML output ------------------------------------------------- |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 146 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 147 | # The theme to use for HTML and HTML Help pages. See the documentation for |
| 148 | # a list of builtin themes. |
| 149 | # |
| 150 | html_theme = "sphinx_symbiflow_theme" |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 151 | |
| 152 | html_logo = "_static/skywater-pdk-logo-top.png" |
| 153 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 154 | # Theme options are theme-specific and customize the look and feel of a theme |
| 155 | # further. For a list of options available for each theme, see the |
| 156 | # documentation. |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 157 | # https://sphinx-symbiflow-theme.readthedocs.io/en/latest/customization.html |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 158 | html_theme_options = { |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 159 | 'nav_title': 'SkyWater ReRAM 130nm PDK', |
| 160 | |
| 161 | 'color_primary': 'light-green', |
| 162 | 'color_accent': 'teal', |
| 163 | |
| 164 | # Set the repo location to get a badge with stats |
| 165 | 'github_url': 'https://github.com/google/skywater-pdk-libs-sky130_fd_pr_reram', |
| 166 | 'repo_name': 'google/skywater-pdk-libs-sky130_fd_pr_reram', |
| 167 | |
| 168 | 'globaltoc_depth': 4, |
| 169 | 'globaltoc_collapse': False, |
| 170 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 171 | # Hide the symbiflow links |
| 172 | 'hide_symbiflow_links': True, |
| 173 | 'license_url' : 'https://www.apache.org/licenses/LICENSE-2.0', |
| 174 | } |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 175 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 176 | # Add any paths that contain custom static files (such as style sheets) here, |
| 177 | # relative to this directory. They are copied after the builtin static files, |
| 178 | # so a file named "default.css" will overwrite the builtin "default.css". |
| 179 | html_static_path = ['_static'] |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 180 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 181 | # Custom sidebar templates, must be a dictionary that maps document names |
| 182 | # to template names. |
| 183 | # |
| 184 | # The default sidebars (for documents that don't match any pattern) are |
| 185 | # defined by theme itself. Builtin themes are using these templates by |
| 186 | # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', |
| 187 | # 'searchbox.html']``. |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 188 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 189 | # -- Options for HTMLHelp output --------------------------------------------- |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 190 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 191 | # Output file base name for HTML help builder. |
| 192 | htmlhelp_basename = 'skywater-pdk-doc' |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 193 | |
| 194 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 195 | # -- Options for LaTeX output ------------------------------------------------ |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 196 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 197 | latex_elements = { |
| 198 | # The paper size ('letterpaper' or 'a4paper'). |
| 199 | # |
| 200 | # 'papersize': 'letterpaper', |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 201 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 202 | # The font size ('10pt', '11pt' or '12pt'). |
| 203 | # |
| 204 | # 'pointsize': '10pt', |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 205 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 206 | # Additional stuff for the LaTeX preamble. |
| 207 | # |
| 208 | # 'preamble': '', |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 209 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 210 | # Latex figure (float) alignment |
| 211 | # |
| 212 | # 'figure_align': 'htbp', |
| 213 | } |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 214 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 215 | # Grouping the document tree into LaTeX files. List of tuples |
| 216 | # (source start file, target name, title, |
| 217 | # author, documentclass [howto, manual, or own class]). |
| 218 | latex_documents = [ |
| 219 | ( |
| 220 | # source start file |
| 221 | master_doc, |
| 222 | # target name |
| 223 | 'skywater-pdk.tex', |
| 224 | # title |
| 225 | 'SkyWater SKY130 PDK Documentation', |
| 226 | # author |
| 227 | author, |
| 228 | # document class |
| 229 | 'manual', |
| 230 | ), |
| 231 | ] |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 232 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 233 | # -- Options for manual page output ------------------------------------------ |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 234 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 235 | # One entry per manual page. List of tuples |
| 236 | # (source start file, name, description, authors, manual section). |
| 237 | man_pages = [ |
| 238 | (master_doc, 'skywater-pdk', 'SkyWater SKY130 PDK Documentation', |
| 239 | [author], 1) |
| 240 | ] |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 241 | |
| 242 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 243 | # -- Options for Texinfo output ---------------------------------------------- |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 244 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 245 | # Grouping the document tree into Texinfo files. List of tuples |
| 246 | # (source start file, target name, title, author, |
| 247 | # dir menu entry, description, category) |
| 248 | texinfo_documents = [ |
| 249 | ( |
| 250 | # source start file |
| 251 | master_doc, |
| 252 | # target name |
| 253 | 'skywater-pdk', |
| 254 | # title |
| 255 | 'SkyWater SKY130 PDK Documentation', |
| 256 | # author |
| 257 | author, |
| 258 | # dir menu entry |
| 259 | 'SkyWater SKY130 PDK', |
| 260 | # description |
| 261 | 'Documentation for open source PDK targetting SkyWater SKY130 process node.', |
| 262 | # category |
| 263 | 'Miscellaneous', |
| 264 | ), |
| 265 | ] |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 266 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 267 | # -- Options for Epub output ------------------------------------------------- |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 268 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 269 | # Bibliographic Dublin Core info. |
| 270 | epub_title = project |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 271 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 272 | # The unique identifier of the text. This can be a ISBN number |
| 273 | # or the project homepage. |
| 274 | # |
| 275 | # epub_identifier = '' |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 276 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 277 | # A unique identification for the text. |
| 278 | # |
| 279 | # epub_uid = '' |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 280 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 281 | # A list of files that should not be packed into the epub file. |
| 282 | epub_exclude_files = ['search.html'] |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 283 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 284 | # Enable the figures and numbers |
| 285 | numfig = True |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 286 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 287 | # -- Extension configuration ------------------------------------------------- |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 288 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 289 | # -- Options for todo extension ---------------------------------------------- |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 290 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 291 | # If true, `todo` and `todoList` produce output, else they produce nothing. |
| 292 | todo_include_todos = True |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 293 | |
| 294 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 295 | import re |
| 296 | from docutils.parsers.rst import directives, roles, nodes |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 297 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 298 | LIB_REGEX = re.compile('sky130_(?P<lib_src>[^_\s]*)_(?P<lib_type>[^_\s]*)(_(?P<lib_name>[^_\s]*))?') |
| 299 | CELL_REGEX = re.compile('sky130_(?P<lib_src>[^_\s]*)_(?P<lib_type>[^_\s]*)(_(?P<lib_name>[^_\s]*))?__(?P<cell_name>[^\s]*)') |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 300 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 301 | def lib_role(name, rawtext, text, lineno, inliner, options={}, content=[]): |
| 302 | """Library name which gets colorized.""" |
| 303 | m = LIB_REGEX.match(text) |
| 304 | if not m: |
| 305 | msg = inliner.reporter.error("Malformed library name of "+repr(text), line=lineno) |
| 306 | prb = inliner.problematic(rawtext, rawtext, msg) |
| 307 | return [prb], [msg] |
| 308 | app = inliner.document.settings.env.app |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 309 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 310 | #lib_process_role = roles.role('lib_src', inliner.language, lineno, inliner.reporter) |
| 311 | #lib_src_role = roles.role('lib_src', inliner.language, lineno, inliner.reporter) |
| 312 | #lib_type_role = roles.role('lib_src', inliner.language, lineno, inliner.reporter) |
| 313 | #lib_name_role = roles.role('lib_src', inliner.language, lineno, inliner.reporter) |
| 314 | lib_process = 'sky130' |
| 315 | lib_src = m.group('lib_src') |
| 316 | lib_type = m.group('lib_type') |
| 317 | lib_name = m.group('lib_name') |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 318 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 319 | r = [ |
| 320 | nodes.inline(lib_process, lib_process, classes=['lib-process']), |
| 321 | nodes.inline('_', '_', options=options), |
| 322 | nodes.inline(lib_src, lib_src, classes=['lib-src']), |
| 323 | nodes.inline('_', '_', options=options), |
| 324 | nodes.inline(lib_type, lib_type, classes=['lib-type']), |
| 325 | ] |
| 326 | if lib_name: |
| 327 | r.append(nodes.inline('_', '_', options=options)) |
| 328 | r.append(nodes.inline(lib_name, lib_name, classes=['lib-name'])) |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 329 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 330 | return r, [] |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 331 | |
| 332 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 333 | def cell_role(name, rawtext, text, lineno, inliner, options={}, content=[]): |
| 334 | """Cell name which gets colorized.""" |
| 335 | m = CELL_REGEX.match(text) |
| 336 | if not m: |
| 337 | msg = inliner.reporter.error("Malformed cell name of "+repr(text), line=lineno) |
| 338 | prb = inliner.problematic(rawtext, rawtext, msg) |
| 339 | return [prb], [msg] |
| 340 | app = inliner.document.settings.env.app |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 341 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 342 | #lib_process_role = roles.role('lib_src', inliner.language, lineno, inliner.reporter) |
| 343 | #lib_src_role = roles.role('lib_src', inliner.language, lineno, inliner.reporter) |
| 344 | #lib_type_role = roles.role('lib_src', inliner.language, lineno, inliner.reporter) |
| 345 | #lib_name_role = roles.role('lib_src', inliner.language, lineno, inliner.reporter) |
| 346 | lib_process = 'sky130' |
| 347 | lib_src = m.group('lib_src') |
| 348 | lib_type = m.group('lib_type') |
| 349 | lib_name = m.group('lib_name') |
| 350 | cell_name = m.group('cell_name') |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 351 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 352 | r = [ |
| 353 | nodes.inline(lib_process, lib_process, classes=['lib-process']), |
| 354 | nodes.inline('_', '_', options=options), |
| 355 | nodes.inline(lib_src, lib_src, classes=['lib-src']), |
| 356 | nodes.inline('_', '_', options=options), |
| 357 | nodes.inline(lib_type, lib_type, classes=['lib-type']), |
| 358 | ] |
| 359 | if lib_name: |
| 360 | r.append(nodes.inline('_', '_', options=options)) |
| 361 | r.append(nodes.inline(lib_name, lib_name, classes=['lib-name'])) |
| 362 | r.append(nodes.inline('__', '__', options=options)) |
| 363 | r.append(nodes.inline(cell_name, cell_name, classes=['cell-name'])) |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 364 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 365 | return r, [] |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 366 | |
| 367 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 368 | def add_role(app, new_role_name): |
| 369 | options = { |
| 370 | 'class': directives.class_option(new_role_name), |
| 371 | } |
| 372 | role = roles.CustomRole(new_role_name, roles.generic_custom_role, options, "") |
| 373 | app.add_role(new_role_name, role) |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 374 | |
| 375 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 376 | def setup(app): |
| 377 | app.add_css_file('extra.css') |
| 378 | add_role(app, 'cell_name') |
| 379 | add_role(app, 'lib_process') |
| 380 | add_role(app, 'lib_src') |
| 381 | add_role(app, 'lib_type') |
| 382 | add_role(app, 'lib_name') |
| 383 | add_role(app, 'drc_rule') |
| 384 | add_role(app, 'drc_tag') |
| 385 | add_role(app, 'drc_flag') |
| 386 | add_role(app, 'layer') |
Tim 'mithro' Ansell | 1ed5750 | 2021-11-23 08:02:34 -0800 | [diff] [blame^] | 387 | |
Ethan Mahintorabi | 208389b | 2021-11-17 12:38:35 -0800 | [diff] [blame] | 388 | app.add_role('lib', lib_role) |
| 389 | app.add_role('cell', cell_role) |
| 390 | app.add_role('model', cell_role) |