From patchwork Tue May 21 21:17:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Corbet X-Patchwork-Id: 164748 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp53807ili; Tue, 21 May 2019 14:17:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBYhTBTNMEZ3jvTnu+tIkZXzwE5rwKGFtp8C9s6Zh6d2boiPCg9XW4EJutKbZqhiTs+0NO X-Received: by 2002:a17:902:3343:: with SMTP id a61mr85296268plc.90.1558473451299; Tue, 21 May 2019 14:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558473451; cv=none; d=google.com; s=arc-20160816; b=YozIna9jVqclDDSVoQlbjfb4Z5CrrY4mFztSX21o9HdcBWQdE/Jxc5uoz6FaHH5JGE vOUFFMylIgOO6R8IDoafhLCOvY6pbj+N+WhYfHuUkLjsTtjU45WXdyrUsKRxiiW8pNdG tfBRjl0nbG4dGyZ3SRHLLxaNj9H444/CI3Z690XFr2gxgZMOj6Kj+IH14XQhi17viI8O WIOgGELqognenkLYOK8uvzgd+cnyGYyvhVY9asMOv2TCjUsr/3D+F9MWhY3iTMGFcXiL 3pmaP/JCAdqW4bhFl5XP+W7vRQGzr9KWHR2M6xHR1xv81xIz0eMGT5o6w18f2lj1Nksf o87A== 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=0cNKkCXerquH6ceAUftI9mlRlu75nbUgo+Yp0CWyBV0=; b=sPSzFSGhAZPfLfkcjM2HtkgO7AzvfSqsDsMs1E1KSkz7g4I3WEEwhbv9OFvpj5k2kT TDz0H/jvd9DNalqS0Y7QwoE6EcXjCjjMw30yLPZLWoMPK3EtHI7BpR1pPHkjklBaLLf7 7zN1oWBNT7bLB5JF7lzvneuP44UJ2XlM+FV/x9zvhy0q1yK5IU2RaA9JWmurGNk/fafM h0GGsNomqJYq0hIMJvQASInskNFC1S7Ph4TB5rwFTozD910eaQqD/JJVHJjTK9oo/R/z 7yrRQr93nQuYZq8BcA64dJ4JyHkjfHijgLI1LQNyIvYMkYztzAKyvf+4y02t20JhButJ SPCA== 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 r5si25151363pfg.152.2019.05.21.14.17.30; Tue, 21 May 2019 14:17:31 -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 S1727944AbfEUVRa (ORCPT + 30 others); Tue, 21 May 2019 17:17:30 -0400 Received: from ms.lwn.net ([45.79.88.28]:42970 "EHLO ms.lwn.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726907AbfEUVR2 (ORCPT ); Tue, 21 May 2019 17:17:28 -0400 Received: from meer.lwn.net (localhost [127.0.0.1]) by ms.lwn.net (Postfix) with ESMTPA id C75FEA78; Tue, 21 May 2019 21:17:27 +0000 (UTC) From: Jonathan Corbet To: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jani Nikula , Markus Heiser , Mauro Carvalho Chehab , Jonathan Corbet Subject: [PATCH 2/2] doc: Cope with the deprecation of AutoReporter Date: Tue, 21 May 2019 15:17:14 -0600 Message-Id: <20190521211714.1395-3-corbet@lwn.net> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190521211714.1395-1-corbet@lwn.net> References: <20190521211714.1395-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. --- Documentation/sphinx/kerneldoc.py | 38 ++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) -- 2.21.0 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) + 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')