LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Jonathan Corbet <corbet@lwn.net>, linux-doc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Markus Heiser <markus.heiser@darmarit.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Jonathan Corbet <corbet@lwn.net>
Subject: Re: [PATCH 2/2] doc: Cope with the deprecation of AutoReporter
Date: Wed, 22 May 2019 10:38:50 +0300 [thread overview]
Message-ID: <87a7ff7xbp.fsf@intel.com> (raw)
In-Reply-To: <20190521211714.1395-3-corbet@lwn.net>
On Tue, 21 May 2019, Jonathan Corbet <corbet@lwn.net> wrote:
> AutoReporter is going away; recent versions of sphinx emit a warning like:
>
> /stuff/k/git/kernel/Documentation/sphinx/kerneldoc.py:125:
> RemovedInSphinx20Warning: AutodocReporter is now deprecated.
> Use sphinx.util.docutils.switch_source_input() instead.
>
> Make the switch. But switch_source_input() only showed up in 1.7, so we
> have to do ugly version checks to keep things working in older versions.
> ---
> Documentation/sphinx/kerneldoc.py | 38 ++++++++++++++++++++++++-------
> 1 file changed, 30 insertions(+), 8 deletions(-)
>
> diff --git a/Documentation/sphinx/kerneldoc.py b/Documentation/sphinx/kerneldoc.py
> index e8891e63e001..d3216f7b4170 100644
> --- a/Documentation/sphinx/kerneldoc.py
> +++ b/Documentation/sphinx/kerneldoc.py
> @@ -37,7 +37,17 @@ import glob
> from docutils import nodes, statemachine
> from docutils.statemachine import ViewList
> from docutils.parsers.rst import directives, Directive
> -from sphinx.ext.autodoc import AutodocReporter
> +
> +#
> +# AutodocReporter is only good up to Sphinx 1.7
> +#
> +import sphinx
> +
> +Use_SSI = sphinx.__version__[:3] >= '1.7'
> +if Use_SSI:
> + from sphinx.util.docutils import switch_source_input
> +else:
> + from sphinx.ext.autodoc import AutodocReporter
>
> import kernellog
>
> @@ -125,13 +135,7 @@ class KernelDocDirective(Directive):
> lineoffset += 1
>
> node = nodes.section()
> - 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
> + self.do_parse(result, node)
>
> return node.children
>
> @@ -140,6 +144,24 @@ class KernelDocDirective(Directive):
> (" ".join(cmd), str(e)))
> return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
>
> + def do_parse(self, result, node):
> + if Use_SSI:
> + save = self.state.memo.title_styles, self.state.memo.section_level
> + try:
> + with switch_source_input(self.state, result):
> + self.state.nested_parse(result, 0, node, match_titles=1)
IIUC you don't need to save the state anymore, so the above two lines
should be sufficient when using switch_source_input.
BR,
Jani.
> + finally:
> + self.state.memo.title_styles, self.state.memo.section_level = save
> + else:
> + save = 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 = save
> +
> +
> def setup(app):
> app.add_config_value('kerneldoc_bin', None, 'env')
> app.add_config_value('kerneldoc_srctree', None, 'env')
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2019-05-22 7:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-21 21:17 [PATCH RFC 0/2] docs: Deal with some Sphinx deprecation warnings Jonathan Corbet
2019-05-21 21:17 ` [PATCH 1/2] doc: Cope with Sphinx logging deprecations Jonathan Corbet
2019-05-21 21:17 ` [PATCH 2/2] doc: Cope with the deprecation of AutoReporter Jonathan Corbet
2019-05-22 7:38 ` Jani Nikula [this message]
2019-05-22 7:36 ` [PATCH RFC 0/2] docs: Deal with some Sphinx deprecation warnings Jani Nikula
2019-05-22 10:19 ` Mauro Carvalho Chehab
2019-05-22 13:25 ` Markus Heiser
2019-05-22 15:45 ` Jonathan Corbet
2019-05-22 16:04 ` Mauro Carvalho Chehab
2019-05-22 16:40 ` Mauro Carvalho Chehab
2019-05-22 9:43 ` Oleksandr Natalenko
2019-05-22 9:49 ` Oleksandr Natalenko
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=87a7ff7xbp.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=markus.heiser@darmarit.de \
--cc=mchehab@kernel.org \
--subject='Re: [PATCH 2/2] doc: Cope with the deprecation of AutoReporter' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).