Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2184340ybi; Thu, 20 Jun 2019 10:27:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYRiEk5Tp1iNE32d1BKt/luDw2Ez6eIoFjLTPwuImun27PP2gKEjjapgwoLuIcyQlJZxsD X-Received: by 2002:a65:62ca:: with SMTP id m10mr13805116pgv.57.1561051633339; Thu, 20 Jun 2019 10:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561051633; cv=none; d=google.com; s=arc-20160816; b=e3F6blge+Ivx3JbGa5DOZZxtZSeSumcq3C0eq6UQnDkXg8gbfJtfiFayjteCEaUWuL JIGDoRYtdbT7gDFbqBoRHFgCIA9FaZpdC9sIk5kRceSwENq0JTNSYcW+DUjBGlflFSrf fYtNPtgEQEz107880cKPvKhPOqKnDBLRy0wDkBSbQUCLiZMXb/A9KJHIHdlbListnwyh ScqVhmHk5Y16+2Yo1Zy4Eq3arLVfhXFyEbNLLmCUojDinj5y4vLa3Mu6Il0ZRTEOS0vR l/dwaM+CeBWJLEeofTPdbTTeqHWtLsP5v0X7IP+MREEkeCNYyl/xHTIIF0DvEFHRUGeC zHbg== 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 :dkim-signature; bh=4yo27ijYQu1yYo30q/R/RGMGUqSkkm83kufrAmJA9ng=; b=wsP0iuMbf9fCKiM+TCI8AhIU6s/AF/YfDg3zNPHbGLE32ksg+LB49UNo2sIdeMFxHR Ifo7Ge77yx+sg9Ai3jVHFsFFrVg4tB1wNd22H7zK3F3FyLl8WeTDYLjCjUwqSGvzdVD1 +51GPPoPFNIwgE5k/0zp655TLYMbN+DOOyNFgwasi9bHlUgrBA6nUdSYe0fS9wEoSsat RD34aYeL0whFgm66FaxbFtOVbl50KZAou3FSHXuEU6IgluDcyagXdKeD6F/6+VZdeEtr WddDYzXo0Vmel4Lx5YLcfMC3ILRlDgji0phT+wXQlOBezjYcgOmJ9vGDkln0L65MMBOT oMsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Bfk95lQb; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 132si93293pfc.57.2019.06.20.10.26.58; Thu, 20 Jun 2019 10:27:13 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Bfk95lQb; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732572AbfFTRZy (ORCPT + 99 others); Thu, 20 Jun 2019 13:25:54 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:52530 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726758AbfFTRXS (ORCPT ); Thu, 20 Jun 2019 13:23:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4yo27ijYQu1yYo30q/R/RGMGUqSkkm83kufrAmJA9ng=; b=Bfk95lQbh+8kmjHfnS9t42zdM7 GVOZCTygmwqJitE5dgYSWqJt/nfNKMTNHS1LyrnF+lshSqbrtJ+M1FSQvUjOJoy0oU4Ggc5R6x8SJ SuISoX2aHeGXxOtgw2hIa6BWQ3rAfHE4IbaEp3GYGt+5AIUbsD7thrG6REGSpp0hCt65nwOzxMVwR zgySLezwEm3c0O6XQVFOD9ITlGshinpnEle5PvDwxwiMPZ5eX35FaP8tQJl5dY2zAiE45eWJtAdBr LnIg9L5whzAHnKE7DYuEkXJwuFB6utN8Jcx3yXzBm+YPHEx0gcvIHii4ImCLDqi5xh7MCXl4ZsjiE d6JWBFmA==; Received: from [177.97.20.138] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1he0mM-0008Rp-77; Thu, 20 Jun 2019 17:23:18 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92) (envelope-from ) id 1he0mJ-0000Db-TX; Thu, 20 Jun 2019 14:23:15 -0300 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, Jonathan Corbet Subject: [PATCH v2 15/22] sphinx/kernel_abi.py: make it compatible with Sphinx 1.7+ Date: Thu, 20 Jun 2019 14:23:07 -0300 Message-Id: <76a9db53d324ff55fca23fae86b223110aca7678.1561050806.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: 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 The same way kerneldoc.py needed changes to work with newer Sphinx, this script needs the same changes. While here, reorganize the include order to match kerneldoc.py. Signed-off-by: Mauro Carvalho Chehab --- Documentation/sphinx/kernel_abi.py | 39 +++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kernel_abi.py index 0f3e51e67e8d..2d5d582207f7 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -30,18 +30,27 @@ u""" """ import codecs -import sys import os -from os import path import subprocess +import sys -from sphinx.ext.autodoc import AutodocReporter +from os import path -from docutils import nodes -from docutils.parsers.rst import Directive, directives +from docutils import nodes, statemachine from docutils.statemachine import ViewList +from docutils.parsers.rst import directives, Directive from docutils.utils.error_reporting import ErrorString +# +# 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 __version__ = '1.0' @@ -139,11 +148,17 @@ class KernelCmd(Directive): content.append(l, fname, c) buf = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter - self.state.memo.title_styles = [] - self.state.memo.section_level = 0 - self.state.memo.reporter = AutodocReporter(content, self.state.memo.reporter) - try: - self.state.nested_parse(content, 0, node, match_titles=1) - finally: - self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf + + if Use_SSI: + with switch_source_input(self.state, content): + self.state.nested_parse(content, 0, node, match_titles=1) + else: + self.state.memo.title_styles = [] + self.state.memo.section_level = 0 + self.state.memo.reporter = AutodocReporter(content, self.state.memo.reporter) + try: + self.state.nested_parse(content, 0, node, match_titles=1) + finally: + self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf + return node.children -- 2.21.0