Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1444723ybm; Tue, 21 May 2019 14:19:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBjyugZxmy8KHiUqjf9fLQHwqbc642ZbPyo8KNn5VKZcuZrEsgv+gjn7EkbP++nybO+6Dj X-Received: by 2002:a17:902:3103:: with SMTP id w3mr10895976plb.187.1558473558440; Tue, 21 May 2019 14:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558473558; cv=none; d=google.com; s=arc-20160816; b=GL5wPu3NRkNPrxZq7AHbi75QtODhZ3mpqMc6twfKWVs9OUSvHIfNE88FqPJSTLhoIn Y6oxi9CZ3sQV/g04cE52J3I10cv8zlafaLzvPHWauBeIemWrqkmxsq0V9bVgCSzeN7/z CUShB+maSvTzh6ofAbl6kAHZ3QkuJAyaIz8siaMG2vEJWBXUdDftoe1XBxWHT+/BoVrO bACe5XI/tStHyDlem5qfwa5e55vpHelKwRnzifXluZHwgvQz1mzxnBPllMA/b7DFTFlu 5N/HVhMNewlAwNljA+Akyxx6kzFxiHebNTd2pUnlrpRWmJh2pN8tbk6zlmX8B7ZYIOsk Z65w== 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 132si24565704pfx.25.2019.05.21.14.19.03; Tue, 21 May 2019 14:19:18 -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 S1727912AbfEUVR3 (ORCPT + 99 others); Tue, 21 May 2019 17:17:29 -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 Content-Transfer-Encoding: 8bit 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(-) 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') -- 2.21.0