Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp157367ybm; Wed, 22 May 2019 00:37:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGRLOsk1eMGBElFfzngFUnFaGbUpDRmn8s6Zd9zDCN7d7d3xqbedhqzV3L5Kspp/6KdlU5 X-Received: by 2002:a17:902:6b:: with SMTP id 98mr88441092pla.271.1558510660522; Wed, 22 May 2019 00:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558510660; cv=none; d=google.com; s=arc-20160816; b=KtbPE7d47xUZyciTTWJaOarmnjP+uvf7JaMfNocJ7si+DHfPt3FsHjh9Ab8q0/NeLt V0afxum49Zx+wgQJ4yYjzOzxvMmb1GVUnzhc+JLVBsZX9hwKo7JVfxgWsI8dXHfKN4rW q9Dp5nZo5OTBxA91+2dE5h7W8Sccb4jyB1uvDPeagy5Qqte64t+o+WOLG+b2V58jvxVT y3iE6oY8I3jqRGiLxmEOilBwDV4nrGH6MIye27XgdGLxR4WUNRQNsnzqspCBvtwf4s66 36WApEB1e7+S8DEcO6FQ+DzTxYCmYRmVUX5SWXM0lBsjfWepUFAbXCj0ZHuszXh9J2Kk S+UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from; bh=UB700uxnT5fp+r+f8Al3fGTaHHwRP2a7LWq+ymHOoug=; b=ZDOwQ/3/SnQCziiDkUgaaHnlCN9dDBz7x0rdfheDZKAgJLF11WJf1MDV4DDNVrfajO TXDa+s8kbq6dikexJW0VZ1fmYtxbERli8vk0+cEjn/oG5iYjFbbGaG1cS1wl7AiBeTtZ TnIpvY3QzCfT5ZjUPQz98G1LkcP4EnYz9P9U4/tOqaPBMQuY/C6VaY5ia4GPm55rItwd vi71eJ8JTbvzZY4ybdzCZtOTG+6NwMg30ATrv36WoK2qcxdqpdog6/3nU0YZU7sUaMjb yVJplWBFc3xGJfSk/dINLUlxfurv7Th6bpuZkGnrgcdzck5Ui9Ur1iGGL4RvdNCNjybr D0Mw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si25424292pgh.406.2019.05.22.00.37.24; Wed, 22 May 2019 00:37:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728615AbfEVHff (ORCPT + 99 others); Wed, 22 May 2019 03:35:35 -0400 Received: from mga17.intel.com ([192.55.52.151]:30009 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725801AbfEVHfe (ORCPT ); Wed, 22 May 2019 03:35:34 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 May 2019 00:35:34 -0700 X-ExtLoop1: 1 Received: from jnikula-mobl3.fi.intel.com (HELO localhost) ([10.237.66.150]) by fmsmga001.fm.intel.com with ESMTP; 22 May 2019 00:35:32 -0700 From: Jani Nikula To: Jonathan Corbet , linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Markus Heiser , Mauro Carvalho Chehab , Jonathan Corbet Subject: Re: [PATCH 2/2] doc: Cope with the deprecation of AutoReporter In-Reply-To: <20190521211714.1395-3-corbet@lwn.net> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20190521211714.1395-1-corbet@lwn.net> <20190521211714.1395-3-corbet@lwn.net> Date: Wed, 22 May 2019 10:38:50 +0300 Message-ID: <87a7ff7xbp.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 21 May 2019, Jonathan Corbet 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