docs(build): fix the Sphinx warnings and errors

This commit is contained in:
BlackAngelTV committed 2026-11-25 21:16:19 +01:00
1 parent 25840c6ce1
commit a3d0fd38b7
16 files changed
+69 -56

No files matched your search

+14 -6
View File
@@ -20,7 +20,7 @@ from docutils import nodes
from docutils.parsers.rst.roles import normalize_options
from pygments.lexer import RegexLexer
from pygments.lexer import bygroups as untyped_bygroups
from pygments.token import Comment, Error, Keyword, Literal, Name, Number, String, Whitespace
from pygments.token import Comment, Error, Keyword, Literal, Name, Number, Punctuation, String, Whitespace
from sphinx import addnodes, version_info
from sphinx.util.logging import getLogger
@@ -220,15 +220,21 @@ def commit_role(
name: str, rawtext: str, text: str, lineno: int, inliner: Any, options: Any = {}, content: Any = []
) -> Tuple[List[nodes.reference], List[nodes.problematic]]:
"Link to a github commit"
# The changelog also cites upstream kitty commits, which a shallow clone of
# the fork does not contain: link to the id as written instead of failing
# the documentation build over missing local history.
try:
commit_id = subprocess.check_output(f'git rev-list --max-count=1 {text}'.split()).decode('utf-8').strip()
commit_id = subprocess.check_output(f'git rev-list --max-count=1 {text}'.split(), stderr=subprocess.DEVNULL).decode('utf-8').strip()
except Exception:
msg = inliner.reporter.error(f'git commit id "{text}" not recognized.', line=lineno)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
commit_id = text
url = f'https://github.com/kovidgoyal/kitty/commit/{commit_id}'
options = normalize_options(options)
short_id = subprocess.check_output(f'git rev-list --max-count=1 --abbrev-commit {commit_id}'.split()).decode('utf-8').strip()
try:
short_id = subprocess.check_output(
f'git rev-list --max-count=1 --abbrev-commit {commit_id}'.split(), stderr=subprocess.DEVNULL
).decode('utf-8').strip()
except Exception:
short_id = commit_id
node = nodes.reference(rawtext, f'commit: {short_id}', refuri=url, **options)
return [node], []
@@ -507,6 +513,8 @@ class ConfLexer(RegexLexer):
tokens = {
'root': [
(r'#.*?$', Comment.Single),
# Closing brace of a profile block, see :ref:`config-profiles`.
(r'\}', Punctuation),
(r'\s+$', Whitespace),
(r'\s+', Whitespace),
(r'(include)(\s+)(.+?)$', bygroups(Comment.Preproc, Whitespace, Name.Namespace)),