docs: fix various pep8 issues

Missing second empty lines between top-level classes/functions,
spurious/unnecessary newlines, unused imports... just bunch of trivial
and non-controversial stuff.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40558>
This commit is contained in:
Eric Engestrom 2026-03-22 09:35:48 +01:00
parent f9a10c46fa
commit d81a70b3af
5 changed files with 22 additions and 12 deletions

View file

@ -30,14 +30,12 @@
# Based on https://github.com/pydata/pydata-sphinx-theme
from docutils import nodes
import sphinx
from sphinx.ext.autosummary import autosummary_table
from sphinx.locale import admonitionlabels
import types
class BootstrapHTML5TranslatorMixin:
def __init__(self, *args, **kwds):
super().__init__(*args, **kwds)
@ -66,8 +64,7 @@ class BootstrapHTML5TranslatorMixin:
self.body.append(self.starttag(
node, 'div', CLASS=('alert ' + admonitionclasses[name])))
if name:
self.body.append(
self.starttag(node, 'div', '', CLASS='h5'))
self.body.append(self.starttag(node, 'div', '', CLASS='h5'))
self.body.append(str(admonitionlabels[name]))
self.body.append('</div>')
@ -98,6 +95,7 @@ class BootstrapHTML5TranslatorMixin:
tag = self.starttag(node, "table", CLASS=" ".join(classes), **atts)
self.body.append(tag)
def setup_translators(app):
if app.builder.format != "html":
return
@ -124,5 +122,6 @@ def setup_translators(app):
)
app.set_translator(name, translator, override=True)
def setup(app):
app.connect("builder-inited", setup_translators)

View file

@ -20,6 +20,7 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
def create_depfile(app, env):
if not app.config.depfile:
return
@ -29,6 +30,7 @@ def create_depfile(app, env):
path = env.doc2path(doc)
f.write('{0}: {1}\n'.format(app.outdir, path))
def setup(app):
app.add_config_value('depfile', None, 'env')
app.connect('env-updated', create_depfile)

View file

@ -3,12 +3,12 @@
# (c) Corbin Simpson 2010
# Public domain to the extent permitted; contact author for special licensing
import docutils.nodes
import sphinx.addnodes
from sphinx.util.nodes import split_explicit_title
from docutils import nodes, utils
def parse_opcode(env, sig, signode):
opcode, desc = sig.split("-", 1)
opcode = opcode.strip().upper()
@ -33,6 +33,7 @@ def ext_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
pnode = nodes.reference(title, title, internal=False, refuri=full_url)
return [pnode], []
def vkfeat_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
text = utils.unescape(text)
has_explicit_title, title, ext = split_explicit_title(text)
@ -42,8 +43,8 @@ def vkfeat_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
pnode = nodes.reference(title, title, internal=False, refuri=full_url)
return [pnode], []
def setup(app):
app.add_object_type("opcode", "opcode", "%s (TGSI opcode)",
parse_opcode)
app.add_object_type("opcode", "opcode", "%s (TGSI opcode)", parse_opcode)
app.add_role('ext', ext_role)
app.add_role('vk-feat', vkfeat_role)

View file

@ -71,16 +71,19 @@ ${textwrap.indent(op.const_expr, ' ')}
.. c:function:: nir_def *nir_${op.name}(nir_builder *, ${src_decl_list(op.num_inputs)})
""")
def parse_rst(state, parent, rst):
vl = docutils.statemachine.ViewList(rst.splitlines())
state.nested_parse(vl, 0, parent)
def nir_alu_type_name(t, s):
if s:
return '{}[{}]'.format(t, s)
else:
return '{}[N]'.format(t)
def build_alu_op_desc(state, env, op):
desc = sphinx.addnodes.desc(domain='nir', objtype='aluop')
@ -95,8 +98,7 @@ def build_alu_op_desc(state, env, op):
params += sphinx.addnodes.desc_parameter('', 'src' + str(i))
sig += params
sig += sphinx.addnodes.desc_returns('',
nir_alu_type_name(op.output_type, op.output_size))
sig += sphinx.addnodes.desc_returns('', nir_alu_type_name(op.output_type, op.output_size))
nir_domain = env.get_domain('nir')
sig['ids'].append(nir_domain.add_alu_op_ref(op))
@ -108,11 +110,13 @@ def build_alu_op_desc(state, env, op):
return desc
class NIRALUOpcodesDirective(SphinxDirective):
def run(self):
return [build_alu_op_desc(self.state, self.env, op)
for op in nir_opcodes.opcodes.values()]
class NIRDomain(Domain):
"""A new NIR directive
@ -125,10 +129,10 @@ class NIRDomain(Domain):
"""
name = 'nir'
roles = {
'alu-op' : sphinx.roles.XRefRole(),
'alu-op': sphinx.roles.XRefRole(),
}
directives = {
'alu-opcodes' : NIRALUOpcodesDirective,
'alu-opcodes': NIRALUOpcodesDirective,
}
initial_data = {
'alu-op-refs': [],
@ -149,5 +153,6 @@ class NIRDomain(Domain):
return None
def setup(app):
app.add_domain(NIRDomain)

View file

@ -22,10 +22,12 @@ import os
import pathlib
from urllib.parse import urlparse
def create_redirect(dst):
tpl = '<html><head><meta http-equiv="refresh" content="0; url={0}"><script>window.location.replace("{0}")</script></head></html>'
return tpl.format(dst)
def create_redirects(app, exception):
if exception is not None or not app.builder.name == 'html':
return
@ -42,6 +44,7 @@ def create_redirects(app, exception):
with open(path, 'w') as f:
f.write(create_redirect(dst))
def setup(app):
app.add_config_value('html_redirects', [], '')
app.connect('build-finished', create_redirects)