nuttx/Documentation/conf.py
Vinicius May f6ecf80ebb Documentation: brand new layout for NuttX documentation.
The documentation grew one page at a time, so the tree follows the
history of who wrote what and not the shape of NuttX. Scheduling is
spread over three places, a driver page can sit above the subsystem
that owns it, and the front page lists everything at the same level.
That is a lot to face when all you want to know is where the scheduler
lives.

This change files every page under the code it describes. It is a move,
not a rewrite: outside the ten pages named below, every page keeps the
text that is already in master, and no page's text is deleted.

What it does:

* Groups the table of contents into nine chapters.
* Moves the OS subsystems under os/: scheduling, memory, drivers,
  filesystem, networking, IPC, interrupts, libs, time.
* Renames the platform pages to the names the source tree uses, and
  derives their tags from the tree instead of by hand.
* Splits guides/ by subject.
* Adds Documentation/redirects.py, with a rule for every page that left
  its old path, so old URLs keep working. The redirect page also carries
  a link's #anchor across to the new page.

Ten pages have text that is new or rewritten. Nine of them are the
landing page of a chapter, which has to exist for the new structure:

    index                  the front page
    os/index               OS Design
    os/scheduling/index    Scheduling
    os/interrupts/index    Interrupts
    os/ipc/index           IPC
    os/time/index          Time and timers
    about/index            About
    developing/index       Developing NuttX
    ReleaseNotes/index     Release notes

The tenth is os/libs/libbuiltin, the only page here with technical
content: libs/libbuiltin/ had no page at all. Five SVG diagrams come
with these pages, hand-written XML with no editor metadata.

Nothing outside Documentation/ is touched.

How it was checked:

* Sphinx builds with -W: no warnings, and no document left outside a
  toctree.
* A script, offered in the PR, proves the narrow claim this rests on.
  For every page outside the ten named above it erases what a move
  touches -- link target, path, tag line, toctree block, table border --
  from the whole old text and the whole new text, and requires the two
  to be byte for byte identical. It also requires every sentence of a
  deleted page to turn up somewhere, and every page that left its old
  path to have a redirect, from a URL that existed, to where its content
  went. It exits non-zero and names the page if any of that is not true,
  and it tests added pages too, so forgetting to declare one cannot make
  it pass.
* An independent audit checked 133 factual claims on these ten pages
  against the tree, one shell command per claim: 130 confirmed, 1
  refuted and fixed here, 2 not checkable.
* tools/checkpatch.sh is clean over the range.

The diff is large because moving a page changes every link that points
to it. Most of it is pure renames, and board pages that gained one tag
line.

Assisted-by: Claude:claude-opus-5
2026-10-08 01:40:54 +08:00

206 lines
6.8 KiB
Python

##############################################################################
# Documentation/conf.py
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
##############################################################################
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
import datetime
import os
import pathlib
import sys
import time
# Add the '_extensions' directory to sys.path, to enable finding Sphinx
# extensions within.
sys.path.insert(0, "_extensions")
sys.path.insert(0, ".")
from redirects import redirects # noqa: E402,F401 (used by sphinx_reredirects)
# sphinx-reredirects writes a small page at every old URL. Its default one
# is a bare meta refresh, which drops the #anchor of a link to a section; this
# template carries the anchor across with one line of script, and keeps the
# meta refresh as the fallback when scripts are off.
redirect_html_template_file = "_templates/redirect.html"
# -- Project information -----------------------------------------------------
project = "NuttX"
# The start year is the one the NOTICE file at the repository root carries;
# the end year is the year the documentation is built, so that the footer
# stops going stale the moment a release slips past New Year. SOURCE_DATE_EPOCH
# is honoured so that a build stays reproducible, which is what the ASF release
# process needs -- Sphinx rewrites the trailing year from it as well, and this
# way the two agree instead of fighting.
_COPYRIGHT_SINCE = 2020
_build_year = datetime.datetime.fromtimestamp(
int(os.environ.get("SOURCE_DATE_EPOCH", time.time())),
datetime.timezone.utc,
).year
copyright = f"{_COPYRIGHT_SINCE}-{_build_year}, The Apache Software Foundation"
author = "NuttX community"
version = release = "latest"
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx_rtd_theme",
"myst_parser",
"sphinx.ext.autosectionlabel",
"sphinx.ext.todo",
"sphinx_tabs.tabs",
"sphinx_copybutton",
"warnings_filter",
"sphinx_tags",
"tags_overview",
"sphinx_design",
"sphinx_collapse",
"sphinxcontrib.plantuml",
"sphinx_reredirects",
]
source_suffix = [".rst", ".md"]
todo_include_todos = True
autosectionlabel_prefix_document = True
# The release notes under ReleaseNotes/ are a frozen archive: each file is the
# text exactly as it was written at the time of the release. They reuse the
# same section titles over and over ("Bug Fixes", "New Features", one per
# subsystem), which makes autosectionlabel emit a duplicate-label warning for
# every repetition. Nothing cross-references a section *inside* a release
# note, so simply stop indexing them. The list is derived from the directory
# so that new releases are covered automatically.
suppress_warnings = [
f"autosectionlabel.ReleaseNotes/{path.stem}"
for path in sorted(pathlib.Path(__file__).parent.glob("ReleaseNotes/NuttX-*.md"))
]
# do not set Python as primary domain for code blocks
highlight_language = "none"
primary_domain = None
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = [
"_build",
"Thumbs.db",
".DS_Store",
# Not a page of its own: it is inlined by introduction/resources.rst.
"legacy_README.md",
"venv",
".venv",
]
# list of documentation versions to offer (besides latest). this will be
# overridden by command line option but we can provide a sane default
# this way
# TODO: append other options using releases detected from git (or maybe just
# a few hand-selected ones, or maybe just a "stable" option)
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
html_show_sphinx = False
html_theme_options = {"navigation_depth": 5}
html_context = {
"display_github": True,
"github_user": "apache",
"github_repo": "nuttx",
"github_version": "master",
"conf_py_path": "/Documentation/",
"nuttx_versions": "latest",
}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_css_files = ["custom.css"]
html_show_license = True
html_logo = "_static/NuttX.png"
html_favicon = "_static/favicon.ico"
today_fmt = "%d %B %y at %H:%M"
c_id_attributes = ["FAR", "CODE", "noreturn_function"]
# This is required to allow running linkcheck with sphinx-tabs
sphinx_tabs_valid_builders = ["linkcheck"]
# There are some sites where the linkchecker cannot handle anchors
linkcheck_ignore = [
"https://github.com/pyenv/pyenv#installation",
"http://openocd.zylin.com/#/c/4103/",
]
latex_engine = "lualatex"
copybutton_exclude = ".linenos, .gp, .go"
# -- Options for warnings_filter ------------------------------------------
warnings_filter_config = "known-warnings.txt"
# -- Options for sphinx_tags ----------------------------------------------
tags_create_tags = True
tags_page_title = "Tags"
tags_page_header = "Pages with this tag"
tags_overview_title = "Tags"
tags_create_badges = True
tags_badge_colors = {
"chip:*": "secondary",
"experimental": "warning",
}