From: Jonathan Corbet <corbet@lwn.net>
To: Jani Nikula <jani.nikula@linux.intel.com>
Cc: linux-doc@vger.kernel.org, Matthew Wilcox <willy@infradead.org>,
Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] Docs: An initial automarkup extension for sphinx
Date: Mon, 24 Jun 2019 08:25:58 -0600 [thread overview]
Message-ID: <20190624082558.62e6c0d2@lwn.net> (raw)
In-Reply-To: <87k1dbrziw.fsf@intel.com>
On Mon, 24 Jun 2019 14:30:47 +0300
Jani Nikula <jani.nikula@linux.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
next prev parent reply other threads:[~2019-06-24 14:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-21 23:51 [PATCH 0/3 v2] docs: function automarkup, now with 80% fewer regexes! Jonathan Corbet
2019-06-21 23:51 ` [PATCH 1/3] Docs: An initial automarkup extension for sphinx Jonathan Corbet
2019-06-22 1:00 ` Mauro Carvalho Chehab
2019-06-22 14:43 ` Jonathan Corbet
2019-06-22 17:46 ` Mauro Carvalho Chehab
2019-06-24 14:29 ` Jonathan Corbet
2019-06-24 16:38 ` Mauro Carvalho Chehab
2019-06-24 11:30 ` Jani Nikula
2019-06-24 14:25 ` Jonathan Corbet [this message]
2019-06-21 23:51 ` [PATCH 2/3] docs: remove :c:func: annotations from xarray.rst Jonathan Corbet
2019-06-21 23:51 ` [PATCH 3/3] kernel-doc: Don't try to mark up function names Jonathan Corbet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190624082558.62e6c0d2@lwn.net \
--to=corbet@lwn.net \
--cc=jani.nikula@linux.intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab+samsung@kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox