[lkml]   [2019]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH 1/3] Docs: An initial automarkup extension for sphinx
On Mon, 24 Jun 2019 14:30:47 +0300
Jani Nikula <> wrote:

> > +def auto_markup(app, doctree, name):
> > + for para in doctree.traverse(nodes.paragraph):
> > + for node in para.traverse(nodes.Text):
> > + if not isinstance(node.parent, nodes.literal):
> > + node.parent.replace(node, markup_funcs(name, app, node))
> I think overall this is a better approach than preprocessing. Thanks for
> doing this!
> I toyed with something like this before, and the key difference here
> seems to be ignoring literal blocks. The problem seemed to be that
> replacing blocks with syntax highlighting also removed the syntax
> highlighting, with no way that I could find to bring it back.

That test could use a comment, really. What it is actually doing is
skipping text chunks in ``inline literal`` sections, and what that is
*actually* doing is avoiding marking up functions that have an
explicit :c:func: markup on them already.

Someday I don't doubt that this loop will be replaced by a proper tree
walk that knows where to prune things and how to replace various other
types of nodes, but this is easy and does the right thing pretty much
everywhere as far as I can tell.



 \ /
  Last update: 2019-06-24 16:26    [W:0.063 / U:6.276 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site