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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
import datetime
import sys
import os
from pathlib import Path
if sys.version_info < (3, 11):
import tomli as tomllib
else:
import tomllib
# The standard library importlib.metadata returns duplicate entrypoints
# for all python versions up to and including 3.11
# https://github.com/python/importlib_metadata/issues/410#issuecomment-1304258228
# see PR https://github.com/asdf-format/asdf/pull/1260
# see issue https://github.com/asdf-format/asdf/issues/1254
if sys.version_info >= (3, 12):
from importlib.metadata import distribution
else:
from importlib_metadata import distribution
# Get configuration information from `pyproject.toml`
with open(Path(__file__).parent.parent / "pyproject.toml", "rb") as configuration_file:
conf = tomllib.load(configuration_file)
configuration = conf["project"]
# -- Project information ------------------------------------------------------
project = configuration["name"]
author = configuration["authors"][0]["name"]
copyright = f"{datetime.datetime.now().year}, {author}"
release = os.environ['DEB_VERSION_UPSTREAM']
# for example take major/minor
version = ".".join(release.split(".")[:2])
# -- Options for HTML output ---------------------------------------------------
html_title = f"{project} v{release}"
# Output file base name for HTML help builder.
htmlhelp_basename = project + "doc"
# -- Options for LaTeX output --------------------------------------------------
latex_documents = [("index", project + ".tex", project + " Documentation", author, "manual")]
# -- Options for manual page output --------------------------------------------
man_pages = [("index", project.lower(), project + " Documentation", [author], 1)]
# Enable nitpicky mode - which ensures that all references in the docs
# resolve.
nitpicky = True
# ignore a few pyyaml docs links since they don't appear to support intersphinx
nitpick_ignore = [
("py:class", "yaml.representer.RepresenterError"),
("py:class", "yaml.error.YAMLError"),
]
# Add intersphinx mappings
intersphinx_mapping = {
"numpy": ("https://numpy.org/doc/stable/", None),
"pypa-packaging": ("https://packaging.python.org/en/latest/", None),
"pytest": ("https://docs.pytest.org/en/latest/", None),
"python": ("https://docs.python.org/3/", None),
"semantic_version": ("https://python-semanticversion.readthedocs.io/en/latest/", None),
"stdatamodels": ("https://stdatamodels.readthedocs.io/en/latest/", None),
}
# Docs are hosted as a "subproject" under the main project's domain: https://www.asdf-format.org/projects
# This requires including links to main project (asdf-website) and the other asdf subprojects
# See https://docs.readthedocs.io/en/stable/guides/intersphinx.html#using-intersphinx
subprojects = {
# main project
"asdf-website": ("https://www.asdf-format.org/en/latest", None),
# other subprojects
"asdf-standard": ("https://www.asdf-format.org/projects/asdf-standard/en/latest/", None),
"asdf-coordinates-schemas": ("https://www.asdf-format.org/projects/asdf-coordinates-schemas/en/latest/", None),
"asdf-transform-schemas": ("https://www.asdf-format.org/projects/asdf-transform-schemas/en/latest/", None),
"asdf-wcs-schemas": ("https://www.asdf-format.org/projects/asdf-wcs-schemas/en/latest/", None),
}
intersphinx_mapping.update(subprojects)
extensions = [
# TODO clean these up, do we need them all?
"sphinx_inline_tabs",
"sphinx.ext.intersphinx",
"sphinx.ext.extlinks",
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.inheritance_diagram",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinxcontrib.jquery",
"numpydoc",
"sphinx_automodapi.automodapi",
"sphinx_automodapi.smart_resolver",
]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ["_build"]
# The suffix of source filenames.
source_suffix = ".rst"
# The master toctree document.
master_doc = "index"
# The reST default role (used for this markup: `text`) to use for all
# documents. Set to the "smart" one.
default_role = "obj"
# Don't show summaries of the members in each class along with the
# class' docstring
numpydoc_show_class_members = False
autosummary_generate = True
automodapi_toctreedirnm = "api"
# Class documentation should contain *both* the class docstring and
# the __init__ docstring
autoclass_content = "both"
mathjax_path = 'file:///usr/share/javascript/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
html_theme = "furo"
html_static_path = ["_static"]
html_sidebars = {}
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = "_static/images/favicon.ico"
html_logo = ""
html_last_updated_fmt = "%d %b %Y"
globalnavlinks = {
"ASDF Projects": "https://www.asdf-format.org",
"Tutorials": "https://www.asdf-format.org/en/latest/tutorials/index.html",
"Community": "https://www.asdf-format.org/en/latest/community/index.html",
}
topbanner = ""
for text, link in globalnavlinks.items():
topbanner += f"<a href={link}>{text}</a>"
html_theme_options = {
"light_logo": "images/logo-light-mode.png",
"dark_logo": "images/logo-dark-mode.png",
"announcement": topbanner,
}
pygments_style = "monokai"
# NB Dark style pygments is furo-specific at this time
pygments_dark_style = "monokai"
# Render inheritance diagrams in SVG
graphviz_output_format = "svg"
graphviz_dot_args = [
"-Nfontsize=10",
"-Nfontname=Helvetica Neue, Helvetica, Arial, sans-serif",
"-Efontsize=10",
"-Efontname=Helvetica Neue, Helvetica, Arial, sans-serif",
"-Gbgcolor=white",
"-Gfontsize=10",
"-Gfontname=Helvetica Neue, Helvetica, Arial, sans-serif",
]
# -- Options for LaTeX output --------------------------------------------------
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [("index", project + ".tex", project + " Documentation", author, "manual")]
latex_logo = "_static/images/logo-light-mode.png"
def setup(app):
app.add_css_file("css/globalnav.css")
|