From patchwork Wed May 22 20:50:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Corbet X-Patchwork-Id: 164893 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1328235ili; Wed, 22 May 2019 13:51:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5p1oYzPsBhPYDqwl3eh/p4Wmsfts7iOaUnii/pQ+NFBWgb+rOxeABEl2A2tpueWBJs76I X-Received: by 2002:a63:8f09:: with SMTP id n9mr63447677pgd.249.1558558259984; Wed, 22 May 2019 13:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558558259; cv=none; d=google.com; s=arc-20160816; b=UXafMH058I94P4oF/TioUKg05H3ewo0W1pPk0EVySwV8yOdnGUj3sLVtPMH5wB+gNB 2YqVO0uJCs1fawLp7nSRq2zwZXR4wejOl//oQZymGHxBKP8sdCg/ZAvJymz6fCRN9rHg eWDM0k6cEjTmsoWOe+5nXcCuR1qRwhc5q2aq9m3euT3qTJXMHM72N4mOwBMNXOHkDojU Rh7ktv8izG9RSxT0fAptum7GzkAn91htUlfbzYQuU0q6elfQo9XNNm4tUqF+vshWr5qK ELGZGC1f6RdSk+E0464qJjzqohz+SOU9ff7tOha3xybJde1VCuA3qyepGAirE74fiJO4 Mh4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uqqMUX5vuJfdZZTiTtv77y0WoEFceULqccYbTnA65/Y=; b=uhwj1CAA0+zjjltcKxfpR+DCsxZs6krAelozug7cLWkaZN2p/Kw3rw3R0uKJYzSRwI xFDJn5gx/mT5bQreVNTzTP5gzheI7J6fC7GoLyqT51hLXjw6mxwtCEySJui2s5NuN5K+ d7eHHnie+RqBGSogMpRiqg03YsG/jrqdD0id9Big4XvBZWumSw3cLzKElgZTY9SDmQuO Jte4i6TswfB5iLlzF0ShoupQuutyQZlKkame14tFCNqn5RcTWmUcr2pO/4euJCUSa87X 5NC8Nm1LIAafe0iX4L9y99/tJa3BfCXYbmOmfbWTtZVuj7PBmrGjS2pLnCXGJRCvpI0j C+Yg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cp7si27333432plb.14.2019.05.22.13.50.59; Wed, 22 May 2019 13:50:59 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730304AbfEVUu6 (ORCPT + 30 others); Wed, 22 May 2019 16:50:58 -0400 Received: from ms.lwn.net ([45.79.88.28]:49340 "EHLO ms.lwn.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729848AbfEVUu5 (ORCPT ); Wed, 22 May 2019 16:50:57 -0400 Received: from meer.lwn.net (localhost [127.0.0.1]) by ms.lwn.net (Postfix) with ESMTPA id D9DC0128A; Wed, 22 May 2019 20:50:56 +0000 (UTC) From: Jonathan Corbet To: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jani Nikula , Markus Heiser , Mauro Carvalho Chehab , Oleksandr Natalenko , Jonathan Corbet Subject: [PATCH 2/8] doc: Cope with the deprecation of AutoReporter Date: Wed, 22 May 2019 14:50:28 -0600 Message-Id: <20190522205034.25724-3-corbet@lwn.net> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190522205034.25724-1-corbet@lwn.net> References: <20190522205034.25724-1-corbet@lwn.net> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Jonathan Corbet --- Documentation/sphinx/kerneldoc.py | 34 +++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) -- 2.21.0 diff --git a/Documentation/sphinx/kerneldoc.py b/Documentation/sphinx/kerneldoc.py index 200c8aa4a04f..1159405cb920 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,20 @@ 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: + with switch_source_input(self.state, result): + self.state.nested_parse(result, 0, node, match_titles=1) + 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')