[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190624082558.62e6c0d2@lwn.net>
Date: Mon, 24 Jun 2019 08:25:58 -0600
From: Jonathan Corbet <corbet@....net>
To: Jani Nikula <jani.nikula@...ux.intel.com>
Cc: linux-doc@...r.kernel.org, Matthew Wilcox <willy@...radead.org>,
Mauro Carvalho Chehab <mchehab+samsung@...nel.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] Docs: An initial automarkup extension for sphinx
On Mon, 24 Jun 2019 14:30:47 +0300
Jani Nikula <jani.nikula@...ux.intel.com> 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.
Thanks,
jon
Powered by blists - more mailing lists