mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-06-27 17:12:03 +00:00
doc: update doc/sphinx/kerneldoc.py
Update doc/sphinx/kerneldoc.py from Linux next-20200219 to avoid warnings like: doc/sphinx/kerneldoc.py:125: RemovedInSphinx20Warning: AutodocReporter is now deprecated. Use sphinx.util.docutils.switch_source_input() instead. self.state.memo.reporter = AutodocReporter(result, self.state.memo.reporter) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
parent
15ae500026
commit
d94a3d1707
1 changed files with 39 additions and 12 deletions
|
@ -37,6 +37,16 @@ import glob
|
||||||
from docutils import nodes, statemachine
|
from docutils import nodes, statemachine
|
||||||
from docutils.statemachine import ViewList
|
from docutils.statemachine import ViewList
|
||||||
from docutils.parsers.rst import directives, Directive
|
from docutils.parsers.rst import directives, Directive
|
||||||
|
|
||||||
|
#
|
||||||
|
# AutodocReporter is only good up to Sphinx 1.7
|
||||||
|
#
|
||||||
|
import sphinx
|
||||||
|
|
||||||
|
Use_SSI = sphinx.__version__[:3] >= '1.7'
|
||||||
|
if Use_SSI:
|
||||||
|
from sphinx.util.docutils import switch_source_input
|
||||||
|
else:
|
||||||
from sphinx.ext.autodoc import AutodocReporter
|
from sphinx.ext.autodoc import AutodocReporter
|
||||||
|
|
||||||
import kernellog
|
import kernellog
|
||||||
|
@ -49,9 +59,10 @@ class KernelDocDirective(Directive):
|
||||||
optional_arguments = 4
|
optional_arguments = 4
|
||||||
option_spec = {
|
option_spec = {
|
||||||
'doc': directives.unchanged_required,
|
'doc': directives.unchanged_required,
|
||||||
'functions': directives.unchanged_required,
|
|
||||||
'export': directives.unchanged,
|
'export': directives.unchanged,
|
||||||
'internal': directives.unchanged,
|
'internal': directives.unchanged,
|
||||||
|
'identifiers': directives.unchanged,
|
||||||
|
'functions': directives.unchanged,
|
||||||
}
|
}
|
||||||
has_content = False
|
has_content = False
|
||||||
|
|
||||||
|
@ -67,6 +78,10 @@ class KernelDocDirective(Directive):
|
||||||
|
|
||||||
tab_width = self.options.get('tab-width', self.state.document.settings.tab_width)
|
tab_width = self.options.get('tab-width', self.state.document.settings.tab_width)
|
||||||
|
|
||||||
|
# 'function' is an alias of 'identifiers'
|
||||||
|
if 'functions' in self.options:
|
||||||
|
self.options['identifiers'] = self.options.get('functions')
|
||||||
|
|
||||||
# FIXME: make this nicer and more robust against errors
|
# FIXME: make this nicer and more robust against errors
|
||||||
if 'export' in self.options:
|
if 'export' in self.options:
|
||||||
cmd += ['-export']
|
cmd += ['-export']
|
||||||
|
@ -76,9 +91,13 @@ class KernelDocDirective(Directive):
|
||||||
export_file_patterns = str(self.options.get('internal')).split()
|
export_file_patterns = str(self.options.get('internal')).split()
|
||||||
elif 'doc' in self.options:
|
elif 'doc' in self.options:
|
||||||
cmd += ['-function', str(self.options.get('doc'))]
|
cmd += ['-function', str(self.options.get('doc'))]
|
||||||
elif 'functions' in self.options:
|
elif 'identifiers' in self.options:
|
||||||
for f in str(self.options.get('functions')).split():
|
identifiers = self.options.get('identifiers').split()
|
||||||
cmd += ['-function', f]
|
if identifiers:
|
||||||
|
for i in identifiers:
|
||||||
|
cmd += ['-function', i]
|
||||||
|
else:
|
||||||
|
cmd += ['-no-doc-sections']
|
||||||
|
|
||||||
for pattern in export_file_patterns:
|
for pattern in export_file_patterns:
|
||||||
for f in glob.glob(env.config.kerneldoc_srctree + '/' + pattern):
|
for f in glob.glob(env.config.kerneldoc_srctree + '/' + pattern):
|
||||||
|
@ -121,13 +140,7 @@ class KernelDocDirective(Directive):
|
||||||
lineoffset += 1
|
lineoffset += 1
|
||||||
|
|
||||||
node = nodes.section()
|
node = nodes.section()
|
||||||
buf = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
|
self.do_parse(result, node)
|
||||||
self.state.memo.reporter = AutodocReporter(result, self.state.memo.reporter)
|
|
||||||
self.state.memo.title_styles, self.state.memo.section_level = [], 0
|
|
||||||
try:
|
|
||||||
self.state.nested_parse(result, 0, node, match_titles=1)
|
|
||||||
finally:
|
|
||||||
self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf
|
|
||||||
|
|
||||||
return node.children
|
return node.children
|
||||||
|
|
||||||
|
@ -136,6 +149,20 @@ class KernelDocDirective(Directive):
|
||||||
(" ".join(cmd), str(e)))
|
(" ".join(cmd), str(e)))
|
||||||
return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
|
return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
|
||||||
|
|
||||||
|
def do_parse(self, result, node):
|
||||||
|
if Use_SSI:
|
||||||
|
with switch_source_input(self.state, result):
|
||||||
|
self.state.nested_parse(result, 0, node, match_titles=1)
|
||||||
|
else:
|
||||||
|
save = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
|
||||||
|
self.state.memo.reporter = AutodocReporter(result, self.state.memo.reporter)
|
||||||
|
self.state.memo.title_styles, self.state.memo.section_level = [], 0
|
||||||
|
try:
|
||||||
|
self.state.nested_parse(result, 0, node, match_titles=1)
|
||||||
|
finally:
|
||||||
|
self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = save
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
app.add_config_value('kerneldoc_bin', None, 'env')
|
app.add_config_value('kerneldoc_bin', None, 'env')
|
||||||
app.add_config_value('kerneldoc_srctree', None, 'env')
|
app.add_config_value('kerneldoc_srctree', None, 'env')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue