Skip to content

Commit

Permalink
doc-rst: kernel-doc directive, fix state machine reporter
Browse files Browse the repository at this point in the history
Add a reporter replacement that assigns the correct source name and line
number to a system message, as recorded in a ViewList.

[1] http://mid.gmane.org/CAKMK7uFMQ2wOp99t-8v06Om78mi9OvRZWuQsFJD55QA20BB3iw@mail.gmail.com

Signed-off-by: Markus Heiser <markus.heiser@darmarIT.de>
Tested-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
  • Loading branch information
Markus Heiser authored and Jonathan Corbet committed Jul 20, 2016
1 parent 8ed292f commit f42ddca
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Documentation/sphinx/kernel-doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from docutils.statemachine import ViewList
from docutils.parsers.rst import directives
from sphinx.util.compat import Directive
from sphinx.ext.autodoc import AutodocReporter

class KernelDocDirective(Directive):
"""Extract kernel-doc comments from the specified file"""
Expand Down Expand Up @@ -117,12 +118,17 @@ def run(self):
lineoffset += 1

node = nodes.section()
node.document = self.state.document
self.state.nested_parse(result, self.content_offset, node)
buf = 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 = buf

return node.children

except Exception as e:
except Exception as e: # pylint: disable=W0703
env.app.warn('kernel-doc \'%s\' processing failed with: %s' %
(" ".join(cmd), str(e)))
return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
Expand Down

0 comments on commit f42ddca

Please sign in to comment.