Skip to content

Commit 05b3bf0

Browse files
committed
sync conf.py with spack/spack
Signed-off-by: Harmen Stoppels <[email protected]>
1 parent a795ac0 commit 05b3bf0

File tree

3 files changed

+48
-15
lines changed

3 files changed

+48
-15
lines changed

.readthedocs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ build:
1515
# golang: "1.20"
1616
apt_packages:
1717
- graphviz
18+
jobs:
19+
post_checkout:
20+
- git fetch --unshallow || true # get accurate "Last updated on" info
1821

1922
# Build documentation in the "docs/" directory with Sphinx
2023
sphinx:

conf.py

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright Spack Project Developers. See COPYRIGHT file for details.
22
#
33
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
4-
54
# flake8: noqa
65
# -*- coding: utf-8 -*-
76
#
@@ -15,14 +14,15 @@
1514
#
1615
# All configuration values have a default; values that are commented out
1716
# serve to show the default.
18-
import sys
19-
import os
2017

21-
from sphinx.domains.python import PythonDomain
18+
import os
19+
import sys
2220

21+
from pygments.formatters.html import HtmlFormatter
2322
from pygments.lexer import RegexLexer, default
2423
from pygments.token import *
25-
24+
from sphinx.domains.python import PythonDomain
25+
from sphinx.highlighting import PygmentsBridge
2626

2727
# -- Spack customizations -----------------------------------------------------
2828
# Add the Spack bin directory to the path so that we can use its output in docs.
@@ -35,6 +35,25 @@
3535

3636
sys.path.insert(0, os.path.abspath("_spack_root/lib/spack/"))
3737

38+
39+
class NoWhitespaceHtmlFormatter(HtmlFormatter):
40+
"""HTML formatter that suppresses redundant span elements for Text.Whitespace tokens."""
41+
42+
def _get_css_classes(self, ttype):
43+
# For Text.Whitespace return an empty string, which avoids <span class="w"> </span>
44+
# elements from being generated.
45+
return "" if ttype is Text.Whitespace else super()._get_css_classes(ttype)
46+
47+
48+
class CustomPygmentsBridge(PygmentsBridge):
49+
def get_formatter(self, **options):
50+
return NoWhitespaceHtmlFormatter(**options)
51+
52+
53+
# Use custom HTML formatter to avoid redundant <span class="w"> </span> elements.
54+
# See https://github.com/pygments/pygments/issues/1905#issuecomment-3170486995.
55+
PygmentsBridge.html_formatter = NoWhitespaceHtmlFormatter
56+
3857
# Enable todo items
3958
todo_include_todos = True
4059

@@ -112,12 +131,10 @@ class SpecLexer(RegexLexer):
112131
# Disable duplicate cross-reference warnings.
113132
#
114133
class PatchedPythonDomain(PythonDomain):
115-
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
134+
def resolve_xref(self, env, fromdocname, builder, type, target, node, contnode):
116135
if "refspecific" in node:
117136
del node["refspecific"]
118-
return super(PatchedPythonDomain, self).resolve_xref(
119-
env, fromdocname, builder, typ, target, node, contnode
120-
)
137+
return super().resolve_xref(env, fromdocname, builder, type, target, node, contnode)
121138

122139

123140
def setup(sphinx):
@@ -127,14 +144,16 @@ def setup(sphinx):
127144

128145
# -- General configuration -----------------------------------------------------
129146
# If your documentation needs a minimal Sphinx version, state it here.
130-
needs_sphinx = "1.8"
147+
needs_sphinx = "3.4"
131148

132149
# Add any Sphinx extension module names here, as strings. They can be extensions
133150
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
134151
extensions = [
135152
"sphinx.ext.graphviz",
136153
"sphinx.ext.todo",
137154
"sphinx_copybutton",
155+
"sphinx_last_updated_by_git",
156+
"sphinx_sitemap",
138157
]
139158

140159
# Set default graphviz options
@@ -287,7 +306,7 @@ def setup(sphinx):
287306
# html_show_sourcelink = True
288307

289308
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
290-
# html_show_sphinx = False
309+
html_show_sphinx = False
291310

292311
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
293312
# html_show_copyright = True
@@ -300,19 +319,27 @@ def setup(sphinx):
300319
# This is the file name suffix for HTML files (e.g. ".xhtml").
301320
# html_file_suffix = None
302321

322+
# Base URL for the documentation, used to generate <link rel="canonical"/> for better indexing
323+
html_baseurl = "https://spack-tutorial.readthedocs.io/en/latest/"
324+
303325
# Output file base name for HTML help builder.
304326
htmlhelp_basename = "Spackdoc"
305327

328+
# Sitemap settings
329+
sitemap_show_lastmod = True
330+
sitemap_url_scheme = "{link}"
331+
sitemap_excludes = ["search.html"]
332+
306333

307334
# -- Options for LaTeX output --------------------------------------------------
308335

309336
latex_elements = {
310337
# The paper size ('letterpaper' or 'a4paper').
311-
#'papersize': 'letterpaper',
338+
# 'papersize': 'letterpaper',
312339
# The font size ('10pt', '11pt' or '12pt').
313-
#'pointsize': '10pt',
340+
# 'pointsize': '10pt',
314341
# Additional stuff for the LaTeX preamble.
315-
#'preamble': '',
342+
# 'preamble': '',
316343
}
317344

318345
# Grouping the document tree into LaTeX files. List of tuples

requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ sphinx==8.2.3
44
sphinxcontrib-programoutput==0.18
55
sphinx-copybutton==0.5.2
66
sphinx_design==0.6.1
7-
furo==2025.7.19
7+
sphinx-last-updated-by-git==0.3.8
8+
sphinx-sitemap==2.8.0
9+
# fork of furo with a few changes that are not merged upstream
10+
git+https://github.com/haampie/furo.git@c1d161cb9e04b481ec3331db981aacfa132ecaa6#egg=furo
811
python-levenshtein==0.27.1
912
docutils==0.21.2
1013
pygments==2.19.2

0 commit comments

Comments
 (0)