blob: 8ba781d51fb224b996cfff12e57f3ca0228dadff [file] [log] [blame]
Ethan Mahintorabi208389b2021-11-17 12:38:35 -08001# -*- 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' Ansell1ed57502021-11-23 08:02:34 -080017
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080018#
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' Ansell1ed57502021-11-23 08:02:34 -080024
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080025# -- Path setup --------------------------------------------------------------
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -080026
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080027# 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#
31import docutils
32import os
33import re
34# import sys
35# sys.path.insert(0, os.path.abspath('.'))
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -080036
37
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080038# -- Project information -----------------------------------------------------
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -080039
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080040project = 'SkyWater SKY130 PDK'
41copyright = '2020, SkyWater PDK Authors'
42author = 'SkyWater PDK Authors'
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -080043
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080044# The short X.Y version
45version = ''
46# The full version, including alpha/beta/rc tags
47release = ''
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -080048
49
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080050# -- General configuration ---------------------------------------------------
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -080051
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080052# If your documentation needs a minimal Sphinx version, state it here.
53#
54# needs_sphinx = '1.0'
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -080055
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080056# 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.
59extensions = [
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' Ansell1ed57502021-11-23 08:02:34 -080069
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080070# Add any paths that contain templates here, relative to this directory.
71templates_path = ['_templates']
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -080072
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080073# The suffix(es) of source filenames.
74# You can specify multiple suffix as a list of string:
75#
76# source_suffix = ['.rst', '.md']
77source_suffix = '.rst'
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -080078
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080079# The master toctree document.
80master_doc = 'index'
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -080081
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080082# Enable github links when not on readthedocs
83on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
84if 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 }
92else:
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' Ansell1ed57502021-11-23 08:02:34 -080098
Ethan Mahintorabi208389b2021-11-17 12:38:35 -080099# 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.
104release = re.sub('^v', '', os.popen('git describe ').read().strip())
105# The short X.Y version.
106version = release
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800107
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800108# 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.
113language = None
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800114
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800115# 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.
118exclude_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' Ansell1ed57502021-11-23 08:02:34 -0800127 'rules/summary/*-key.rst',
128 'rules/layers/*-key.rst',
129 'rules/hv/*-key.rst',
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800130]
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800131
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800132# The name of the Pygments (syntax highlighting) style to use.
133pygments_style = None
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800134
135
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800136# -- Options for HTML output -------------------------------------------------
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800137
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800138# 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' Ansell1ed57502021-11-23 08:02:34 -0800143
144
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800145# -- Options for HTML output -------------------------------------------------
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800146
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800147# The theme to use for HTML and HTML Help pages. See the documentation for
148# a list of builtin themes.
149#
150html_theme = "sphinx_symbiflow_theme"
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800151
152html_logo = "_static/skywater-pdk-logo-top.png"
153
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800154# 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' Ansell1ed57502021-11-23 08:02:34 -0800157# https://sphinx-symbiflow-theme.readthedocs.io/en/latest/customization.html
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800158html_theme_options = {
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800159 '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 Mahintorabi208389b2021-11-17 12:38:35 -0800171 # Hide the symbiflow links
172 'hide_symbiflow_links': True,
173 'license_url' : 'https://www.apache.org/licenses/LICENSE-2.0',
174}
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800175
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800176# 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".
179html_static_path = ['_static']
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800180
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800181# 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' Ansell1ed57502021-11-23 08:02:34 -0800188
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800189# -- Options for HTMLHelp output ---------------------------------------------
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800190
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800191# Output file base name for HTML help builder.
192htmlhelp_basename = 'skywater-pdk-doc'
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800193
194
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800195# -- Options for LaTeX output ------------------------------------------------
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800196
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800197latex_elements = {
198 # The paper size ('letterpaper' or 'a4paper').
199 #
200 # 'papersize': 'letterpaper',
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800201
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800202 # The font size ('10pt', '11pt' or '12pt').
203 #
204 # 'pointsize': '10pt',
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800205
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800206 # Additional stuff for the LaTeX preamble.
207 #
208 # 'preamble': '',
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800209
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800210 # Latex figure (float) alignment
211 #
212 # 'figure_align': 'htbp',
213}
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800214
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800215# 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]).
218latex_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' Ansell1ed57502021-11-23 08:02:34 -0800232
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800233# -- Options for manual page output ------------------------------------------
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800234
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800235# One entry per manual page. List of tuples
236# (source start file, name, description, authors, manual section).
237man_pages = [
238 (master_doc, 'skywater-pdk', 'SkyWater SKY130 PDK Documentation',
239 [author], 1)
240]
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800241
242
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800243# -- Options for Texinfo output ----------------------------------------------
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800244
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800245# Grouping the document tree into Texinfo files. List of tuples
246# (source start file, target name, title, author,
247# dir menu entry, description, category)
248texinfo_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' Ansell1ed57502021-11-23 08:02:34 -0800266
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800267# -- Options for Epub output -------------------------------------------------
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800268
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800269# Bibliographic Dublin Core info.
270epub_title = project
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800271
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800272# The unique identifier of the text. This can be a ISBN number
273# or the project homepage.
274#
275# epub_identifier = ''
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800276
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800277# A unique identification for the text.
278#
279# epub_uid = ''
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800280
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800281# A list of files that should not be packed into the epub file.
282epub_exclude_files = ['search.html']
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800283
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800284# Enable the figures and numbers
285numfig = True
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800286
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800287# -- Extension configuration -------------------------------------------------
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800288
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800289# -- Options for todo extension ----------------------------------------------
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800290
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800291# If true, `todo` and `todoList` produce output, else they produce nothing.
292todo_include_todos = True
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800293
294
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800295import re
296from docutils.parsers.rst import directives, roles, nodes
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800297
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800298LIB_REGEX = re.compile('sky130_(?P<lib_src>[^_\s]*)_(?P<lib_type>[^_\s]*)(_(?P<lib_name>[^_\s]*))?')
299CELL_REGEX = re.compile('sky130_(?P<lib_src>[^_\s]*)_(?P<lib_type>[^_\s]*)(_(?P<lib_name>[^_\s]*))?__(?P<cell_name>[^\s]*)')
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800300
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800301def 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' Ansell1ed57502021-11-23 08:02:34 -0800309
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800310 #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' Ansell1ed57502021-11-23 08:02:34 -0800318
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800319 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' Ansell1ed57502021-11-23 08:02:34 -0800329
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800330 return r, []
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800331
332
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800333def 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' Ansell1ed57502021-11-23 08:02:34 -0800341
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800342 #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' Ansell1ed57502021-11-23 08:02:34 -0800351
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800352 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' Ansell1ed57502021-11-23 08:02:34 -0800364
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800365 return r, []
Tim 'mithro' Ansell1ed57502021-11-23 08:02:34 -0800366
367
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800368def 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' Ansell1ed57502021-11-23 08:02:34 -0800374
375
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800376def 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' Ansell1ed57502021-11-23 08:02:34 -0800387
Ethan Mahintorabi208389b2021-11-17 12:38:35 -0800388 app.add_role('lib', lib_role)
389 app.add_role('cell', cell_role)
390 app.add_role('model', cell_role)