Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp586968ybd; Sat, 22 Jun 2019 10:00:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNb0G/4+jz5blC+DkCFxUVZY0QKfNfSlUSUGALIbIpTvcJJuv8qQ8uFeXrg3vijr+QZTOR X-Received: by 2002:a17:902:1101:: with SMTP id d1mr17967451pla.212.1561222818397; Sat, 22 Jun 2019 10:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561222818; cv=none; d=google.com; s=arc-20160816; b=gF+D38+cBnPcw9xfViFoqMAs3XCuqsjm4EN4bGEdAF9Qri7/9Ji+5RUDys4QSIyDK5 sa1PgZ/H9Yxi+W8jMHfNqqJCEwz2Q3O/Ude0YaUliiKi/b+rLXpd827ntrWkMIttmNXQ U4G+WZUpQEilYcg0zWbGU3UoIj39O/lnOa6BjIFy6Opk+Ys3yTgJtuTMUaqTOm1OrYaV XomXZvZDFprVeKjzOF+RJHAbsqQUReMqBz58VA8mKvbydKm4QessyN7xYjqOvPRu5NG8 giDFDg8e94GJPMLC/SwQqsiyczFs4IewQY4ot4ANXKYu5m1VuKasADchb+yfCjVSMjBQ enKg== 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=aYkO21+57WhHrMos1KtTm4cyY8Mb4Xx9tR+j2J1rYNI=; b=JLYz2+9smzscxp2NCINr1tSRSNZvqEetyP8mO/9wMXa2kvnwSVm9pRllUG8Gl6mFDP tLgwhkKho+EQA2jn5JCs4aBHlykzpIZW8btMJveaXoLZ5atL/Q3xDxVhsOVB1ZPlM6yC TBq/ybsYvnIkCA/o7cSktj9L4rtIJ+ugs8sryyAc2sWL+SqnXlt6oWtGMMoa6o0WdUl7 aRk3owNTDQVZWcatSxqLyulA1eccVzCD78H5+ledKBLlPryHfZ1N6GE+wHhkIRGdWIPj 8VW/rkZMCKcVWl6thFAz016HElNUP8GUIB8Upw+t5ih4CLkmomg/XW97yj/1xXkDE7VX 4xZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=dOqZCFvS; 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 64si5492020ply.399.2019.06.22.10.00.00; Sat, 22 Jun 2019 10:00: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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=dOqZCFvS; 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 S1726612AbfFVQ7W (ORCPT + 99 others); Sat, 22 Jun 2019 12:59:22 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:42868 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726511AbfFVQ7D (ORCPT ); Sat, 22 Jun 2019 12:59:03 -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=aYkO21+57WhHrMos1KtTm4cyY8Mb4Xx9tR+j2J1rYNI=; b=dOqZCFvSr/KGjvvUWsOekDkCkZ VO75FYeYSM2/sabjOnNASvZF9UvmvJAd2xJQm0MkTqVk8RZzkXbzwpsqhXHxIuG3vywskXm0LJQOe sQ3aSNzWPGKa26fOj+4hRCgcnXNXI5KAaeq2xRsUsqvmHUlAtlR46dV1qpLhVI7jGnC5wbUcKHWl0 fvYO0WB5RmV6maWdeulE5L2eyxs76i06SxCCcM5AM5SexdyKJ4prqPlgnRtaFxnlowH5XMWQm/WFW dc+r+RT8vYbcZhvZlPysM52ibNia8fTBxYXfo9/xTEkoA2ylMgL1Kh05Qh13Fg9nAZq2Yr6Nc7/SQ jXbprTiw==; Received: from [179.95.45.115] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hejLz-00054v-1V; Sat, 22 Jun 2019 16:59:03 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92) (envelope-from ) id 1hejLs-0000vo-2X; Sat, 22 Jun 2019 13:58:56 -0300 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , gregkh@linuxfoundation.org, Jonathan Corbet Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH 11/12] docs: kernel_abi.py: Handle with a lazy Sphinx parser Date: Sat, 22 Jun 2019 13:58:52 -0300 Message-Id: <31bb430e89d3c4e7320fd9e976a76a5675d5c590.1561221403.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 Sphinx docutils parser is lazy: if the content is bigger than a certain number of lines, it silenlty stops parsing it, producing an incomplete content. This seems to be worse on newer Sphinx versions, like 2.0. So, change the logic to parse the contents per input file. Signed-off-by: Mauro Carvalho Chehab --- Documentation/sphinx/kernel_abi.py | 39 ++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kernel_abi.py index efa338e18764..a417026ed690 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -36,6 +36,7 @@ import os import subprocess import sys import re +import kernellog from os import path @@ -79,12 +80,6 @@ class KernelCmd(Directive): "debug" : directives.flag } - def warn(self, message, **replace): - replace["fname"] = self.state.document.current_source - replace["line_no"] = replace.get("line_no", self.lineno) - message = ("%(fname)s:%(line_no)s: [kernel-abi WARN] : " + message) % replace - self.state.document.settings.env.app.warn(message, prefix="") - def run(self): doc = self.state.document @@ -110,7 +105,7 @@ class KernelCmd(Directive): shell_env["srctree"] = srctree lines = self.runCmd(cmd, shell=True, cwd=cwd, env=shell_env) - nodeList = self.nestedParse(lines, fname) + nodeList = self.nestedParse(lines, self.arguments[0]) return nodeList def runCmd(self, cmd, **kwargs): @@ -137,9 +132,9 @@ class KernelCmd(Directive): % (self.name, ErrorString(exc))) return out - def nestedParse(self, lines, f): + def nestedParse(self, lines, fname): content = ViewList() - node = nodes.section() + node = nodes.section() if "debug" in self.options: code_block = "\n\n.. code-block:: rst\n :linenos:\n" @@ -149,22 +144,42 @@ class KernelCmd(Directive): line_regex = re.compile("^#define LINENO (\S+)\#([0-9]+)$") ln = 0 + n = 0 + f = fname for line in lines.split("\n"): + n = n + 1 match = line_regex.search(line) if match: - f = match.group(1) + new_f = match.group(1) + + # Sphinx parser is lazy: it stops parsing contents in the + # middle, if it is too big. So, handle it per input file + if new_f != f and content: + self.do_parse(content, node) + content = ViewList() + + f = new_f + # sphinx counts lines from 0 ln = int(match.group(2)) - 1 else: content.append(line, f, ln) - buf = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter + kernellog.info(self.state.document.settings.env.app, "%s: parsed %i lines" % (fname, n)) + if content: + self.do_parse(content, node) + + return node.children + + def do_parse(self, content, node): if Use_SSI: with switch_source_input(self.state, content): self.state.nested_parse(content, 0, node, match_titles=1) else: + 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) @@ -172,5 +187,3 @@ class KernelCmd(Directive): 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