mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
doc: update Kernel documentation build system
Update the documentation build system according to Linux v5.11-rc1. Deactive the automarkup.py extension module which on Gitlab CI is incompatible with Unicode. With this patch we can build the HTML documentation using either of Sphinx 2 and Sphinx 3. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
parent
836049d63e
commit
98f01cf7a2
14 changed files with 1474 additions and 154 deletions
|
@ -40,14 +40,94 @@ from sphinx import addnodes
|
|||
from sphinx.domains.c import c_funcptr_sig_re, c_sig_re
|
||||
from sphinx.domains.c import CObject as Base_CObject
|
||||
from sphinx.domains.c import CDomain as Base_CDomain
|
||||
from itertools import chain
|
||||
import re
|
||||
|
||||
__version__ = '1.0'
|
||||
__version__ = '1.1'
|
||||
|
||||
# Get Sphinx version
|
||||
major, minor, patch = sphinx.version_info[:3]
|
||||
|
||||
# Namespace to be prepended to the full name
|
||||
namespace = None
|
||||
|
||||
#
|
||||
# Handle trivial newer c domain tags that are part of Sphinx 3.1 c domain tags
|
||||
# - Store the namespace if ".. c:namespace::" tag is found
|
||||
#
|
||||
RE_namespace = re.compile(r'^\s*..\s*c:namespace::\s*(\S+)\s*$')
|
||||
|
||||
def markup_namespace(match):
|
||||
global namespace
|
||||
|
||||
namespace = match.group(1)
|
||||
|
||||
return ""
|
||||
|
||||
#
|
||||
# Handle c:macro for function-style declaration
|
||||
#
|
||||
RE_macro = re.compile(r'^\s*..\s*c:macro::\s*(\S+)\s+(\S.*)\s*$')
|
||||
def markup_macro(match):
|
||||
return ".. c:function:: " + match.group(1) + ' ' + match.group(2)
|
||||
|
||||
#
|
||||
# Handle newer c domain tags that are evaluated as .. c:type: for
|
||||
# backward-compatibility with Sphinx < 3.0
|
||||
#
|
||||
RE_ctype = re.compile(r'^\s*..\s*c:(struct|union|enum|enumerator|alias)::\s*(.*)$')
|
||||
|
||||
def markup_ctype(match):
|
||||
return ".. c:type:: " + match.group(2)
|
||||
|
||||
#
|
||||
# Handle newer c domain tags that are evaluated as :c:type: for
|
||||
# backward-compatibility with Sphinx < 3.0
|
||||
#
|
||||
RE_ctype_refs = re.compile(r':c:(var|struct|union|enum|enumerator)::`([^\`]+)`')
|
||||
def markup_ctype_refs(match):
|
||||
return ":c:type:`" + match.group(2) + '`'
|
||||
|
||||
#
|
||||
# Simply convert :c:expr: and :c:texpr: into a literal block.
|
||||
#
|
||||
RE_expr = re.compile(r':c:(expr|texpr):`([^\`]+)`')
|
||||
def markup_c_expr(match):
|
||||
return '\ ``' + match.group(2) + '``\ '
|
||||
|
||||
#
|
||||
# Parse Sphinx 3.x C markups, replacing them by backward-compatible ones
|
||||
#
|
||||
def c_markups(app, docname, source):
|
||||
result = ""
|
||||
markup_func = {
|
||||
RE_namespace: markup_namespace,
|
||||
RE_expr: markup_c_expr,
|
||||
RE_macro: markup_macro,
|
||||
RE_ctype: markup_ctype,
|
||||
RE_ctype_refs: markup_ctype_refs,
|
||||
}
|
||||
|
||||
lines = iter(source[0].splitlines(True))
|
||||
for n in lines:
|
||||
match_iterators = [regex.finditer(n) for regex in markup_func]
|
||||
matches = sorted(chain(*match_iterators), key=lambda m: m.start())
|
||||
for m in matches:
|
||||
n = n[:m.start()] + markup_func[m.re](m) + n[m.end():]
|
||||
|
||||
result = result + n
|
||||
|
||||
source[0] = result
|
||||
|
||||
#
|
||||
# Now implements support for the cdomain namespacing logic
|
||||
#
|
||||
|
||||
def setup(app):
|
||||
|
||||
# Handle easy Sphinx 3.1+ simple new tags: :c:expr and .. c:namespace::
|
||||
app.connect('source-read', c_markups)
|
||||
|
||||
if (major == 1 and minor < 8):
|
||||
app.override_domain(CDomain)
|
||||
else:
|
||||
|
@ -75,6 +155,8 @@ class CObject(Base_CObject):
|
|||
function-like macro, the name of the macro is returned. Otherwise
|
||||
``False`` is returned. """
|
||||
|
||||
global namespace
|
||||
|
||||
if not self.objtype == 'function':
|
||||
return False
|
||||
|
||||
|
@ -107,11 +189,16 @@ class CObject(Base_CObject):
|
|||
param += nodes.emphasis(argname, argname)
|
||||
paramlist += param
|
||||
|
||||
if namespace:
|
||||
fullname = namespace + "." + fullname
|
||||
|
||||
return fullname
|
||||
|
||||
def handle_signature(self, sig, signode):
|
||||
"""Transform a C signature into RST nodes."""
|
||||
|
||||
global namespace
|
||||
|
||||
fullname = self.handle_func_like_macro(sig, signode)
|
||||
if not fullname:
|
||||
fullname = super(CObject, self).handle_signature(sig, signode)
|
||||
|
@ -122,6 +209,10 @@ class CObject(Base_CObject):
|
|||
else:
|
||||
# FIXME: handle :name: value of other declaration types?
|
||||
pass
|
||||
else:
|
||||
if namespace:
|
||||
fullname = namespace + "." + fullname
|
||||
|
||||
return fullname
|
||||
|
||||
def add_target_and_index(self, name, sig, signode):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue