Skip to content

Commit

Permalink
doc/sphinx: Stop touching state_machine internals
Browse files Browse the repository at this point in the history
Instead of just forcefully inserting our kernel-doc input and letting
the state machine stumble over it the recommended way is to create
ViewList, parse that and then return the list of parsed nodes.

Suggested by Jani.

Cc: Jani Nikula <jani.nikula@intel.com>
Cc: linux-doc@vger.kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
  • Loading branch information
Daniel Vetter authored and Jani Nikula committed Jun 3, 2016
1 parent ebff7f9 commit 16e161c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Documentation/sphinx/kernel-doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import sys

from docutils import nodes, statemachine
from docutils.statemachine import ViewList
from docutils.parsers.rst import directives
from sphinx.util.compat import Directive

Expand Down Expand Up @@ -92,8 +93,14 @@ def run(self):
sys.stderr.write(err)

lines = statemachine.string2lines(out, tab_width, convert_whitespace=True)
self.state_machine.insert_input(lines, source)
return []
result = ViewList(lines, source)

node = nodes.section()
node.document = self.state.document
self.state.nested_parse(result, self.content_offset, node)

return node.children

except Exception as e:
env.app.warn('kernel-doc \'%s\' processing failed with: %s' %
(" ".join(cmd), str(e)))
Expand Down

0 comments on commit 16e161c

Please sign in to comment.