diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 9c5593381a..b9f7296c5f 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,3 +1,4 @@ +--- # .readthedocs.yaml # Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details @@ -7,9 +8,9 @@ version: 2 # Set the version of Python and other tools you might need build: - os: ubuntu-20.04 + os: ubuntu-22.04 tools: - python: "3.9" + python: "3.10" # You can also specify other tool versions: # nodejs: "16" # rust: "1.55" @@ -17,13 +18,12 @@ build: # Build documentation in the docs/ directory with Sphinx sphinx: - configuration: docs/conf.py + configuration: docs/conf.py # If using Sphinx, optionally build your docs in additional formats such as PDF # formats: # - pdf -# Optionally declare the Python requirements required to build your docs -#python: -# install: -# - requirements: docs/requirements.txt +python: + install: + - requirements: docs/requirements.txt diff --git a/docs/Makefile b/docs/Makefile index d4bb2cbb9e..a9bc6a02c3 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,20 +1,32 @@ # Minimal makefile for Sphinx documentation # +VENV = _venv + # You can set these variables from the command line, and also # from the environment for the first two. SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build +SPHINXBUILD ?= ./$(VENV)/bin/sphinx-build SOURCEDIR = . BUILDDIR = _build + # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -.PHONY: help Makefile +venv: Makefile + python -m venv --upgrade-deps $(VENV) + ./$(VENV)/bin/pip install -r requirements.txt + + +clean: + @rm -rf $(VENV) $(BUILDDIR) + + +.PHONY: help Makefile $(SPHINXBUILD) # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile +%: $(SPHINXBUILD) @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000000..4ffb083903 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,18 @@ +# Building documentation locally + +This process will improve over time. + +For now, manually create a Python virtual environment and install the +dependencies: + +```shell +make venv +``` + +The virtualenv will be created in **_venv**. + +Then to build the documentation: + +```shell +make html +``` diff --git a/docs/_addons/bzlink.py b/docs/_addons/bzlink.py new file mode 100644 index 0000000000..6bdbdac8c5 --- /dev/null +++ b/docs/_addons/bzlink.py @@ -0,0 +1,63 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import re + +from docutils.nodes import Text, paragraph, reference +from sphinx.transforms import SphinxTransform + + +class ConvertBugsToLinks(SphinxTransform): + # Convert text entries in paragraphs that are in the style of "bug xxxxx" + # to a hyperlink that leads to the appropriate bugzilla bug link. + + default_priority = 400 + bz_url = "https://bugzilla.mozilla.org/show_bug.cgi?id={0}" + bz_reg = r"bug[' '][0-9]\d*" + + def apply(self): + def check_if_paragraph(o): + return isinstance(o, paragraph) + + def check_if_text(o): + return ( + not isinstance(o.parent, reference) + and isinstance(o, Text) + and re.search(self.bz_reg, o, re.IGNORECASE) + ) + + changed = True + while changed: + changed = self.textToReferences(check_if_paragraph, check_if_text) + return + + def textToReferences(self, check_if_paragraph, check_if_text): + # Analyses the document and replaces from the paragraph nodes + # the Text element(s) that contain bz_reg matching strings. + # Whevever the matching strings are more than one and + # a correction is made, the function returns True. + + for node in self.document.traverse(check_if_paragraph): + for text in node.traverse(check_if_text): + bugs = re.findall(self.bz_reg, text, re.IGNORECASE) + if len(bugs) == 0: + continue + bug = bugs[0] + txtparts = text.split(bug, 1) + new_ref = reference( + bug, + bug, + refuri=self.bz_url.format(bug.split()[1]), + ) + txt_0 = Text(txtparts[0]) + txt_1 = Text(txtparts[1]) + text.parent.replace(text, [txt_0, new_ref, txt_1]) + if len(bugs) > 1: + return True + return False + + +def setup(app): + app.add_transform(ConvertBugsToLinks) + return diff --git a/docs/_static/custom_theme.css b/docs/_static/custom_theme.css new file mode 100644 index 0000000000..c8e34c03ca --- /dev/null +++ b/docs/_static/custom_theme.css @@ -0,0 +1,71 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Increase the size of the content */ +.wy-nav-content { + max-width: 80% !important; +} + +/* Increase the size of the tables */ +table.docutils { + width: 90%; +} + +/* Override the default values for multiline text in a table */ +table.docutils td, table.docutils th +{ + font-size: 16px !important; +} + +.rst-content .line-block { + margin-bottom: 0px !important; +} + +/* Add the strikethrough feature */ +span.strikethrough { + text-decoration: line-through; +} + +/* Better control over the table on this page */ +.matcher-cookbook td { + white-space: break-spaces !important; +} + +.wy-table-responsive table td, .wy-table-responsive table th { + white-space: normal; +} + +img.center { + display: block; + margin: auto; +} + +img.border { + border: 1px solid black; + display: block; + margin: auto; +} + +.center { + text-align: center; +} + +/* Keyboard shortcuts styling */ +kbd { + background: linear-gradient(180deg,#f4f4f4,#d5d5d5); + background-color: #f4f4f4; + border: 1px solid #d5d5d5; + border-radius: 6px; + font-family: consolas,"Liberation Mono",courier,monospace; + font-size: .9rem; + font-weight: 700; + line-height: 2.3; + margin: 3px; + padding: 4px 6px 1px 6px; + white-space: nowrap; +} + +table.docutils { + width: 100%; +} diff --git a/docs/_templates/breadcrumbs.html b/docs/_templates/breadcrumbs.html new file mode 100644 index 0000000000..27bf66b65b --- /dev/null +++ b/docs/_templates/breadcrumbs.html @@ -0,0 +1,14 @@ + + +{%- extends "sphinx_rtd_theme/breadcrumbs.html" %} + +{% block breadcrumbs_aside %} +