From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 801B0A04DB;
	Fri, 16 Oct 2020 05:40:13 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 2E8CE1E9A9;
	Fri, 16 Oct 2020 05:40:11 +0200 (CEST)
Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com
 [64.147.123.21]) by dpdk.org (Postfix) with ESMTP id 03D7A1E9A8
 for <dev@dpdk.org>; Fri, 16 Oct 2020 05:40:09 +0200 (CEST)
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42])
 by mailout.west.internal (Postfix) with ESMTP id CD242EC2;
 Thu, 15 Oct 2020 23:40:07 -0400 (EDT)
Received: from mailfrontend2 ([10.202.2.163])
 by compute2.internal (MEProxy); Thu, 15 Oct 2020 23:40:08 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h=
 from:to:cc:subject:date:message-id:mime-version
 :content-transfer-encoding; s=fm2; bh=6EvWSCOC8n0ms6lNy4PrsNvPcr
 m9A3u8Gd0HtOUioJ8=; b=MabtMSyTWW8CzOA4SoLvoH5uYvzTKeXreF5zNMpcZO
 H7k7q5naBgmaOtrj4on93nRSi2OD47yCYBx+r1+44mdVYGc7TPZtrN7RklCx6q1W
 suNPOQcP1zE9pAUpLkEWo2Bkn5666xVDuI0rXF9cXBH94+ksU9vhQsj/lgbxTIbT
 gHl+lBK+dUhe7c9HgY2azJy83k6i2VgJxhw8zFqfhyH752hFsiuhZRXzGUa81b5J
 VAgxlzyPctaUk88LzM5287N3X1l1GPf5VHuZaTkPMBAiPqAkK9zQdIfT2LEnMn/b
 xGqUkJTImlP196lL6mupK9CnyqyCWSG1gnHw0RfiS94Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-transfer-encoding:date:from
 :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=6EvWSCOC8n0ms6lNy
 4PrsNvPcrm9A3u8Gd0HtOUioJ8=; b=Vm94hP9C13UdqJ4Pel3dQTn7o0fsehrNn
 7qY2MeQPAhjKr5Wy9YJPWEEtJDOvjGOb4MW0b4CcbEkXOOKEIhub2Y/b7cbWTuAG
 C7Ke+gPbVBT7ZK97s4fWREXszqoHuheNb6NU4UD54LR932/cqV0HbiFiztWVbxkL
 a/F9lTBYbaGHAYcm5yo+c3ImUDh3kQWqYl+I6W19tJ0VEd7GVcvjaTzsmEx/JT5x
 vjIFTn7ggX4El/63vAFuCI7UILGEYRrNJW9cte8ccyhMehi4oes4Cbzp9rZL8C/0
 +hImssbaJoFvHT20WbCMa9j8dYAKWVMkRL5MhZ2xrUdQVMuikJI3A==
X-ME-Sender: <xms:FxaJXylMx-by3KNSwnMp1BwseHuPT2KatMQ5XR72cILARXnVgGl6YA>
 <xme:FxaJX51fCl0K8ejhMZug1UZIo7IHat_wzShcM4grlftaKll9kMlzHbHSpIU-Y131L
 pyQJH5M4nrfIiU_4w>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrieeggdejgecutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
 uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffoggfgsedtkeertdertd
 dtnecuhfhrohhmpefvhhhomhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhn
 jhgrlhhonhdrnhgvtheqnecuggftrfgrthhtvghrnhepgeetheetuddtgfdvhfdvfeelve
 euteehveduudfhuedtheejtedtieeghfehteejnecuffhomhgrihhnpehrvggrughthhgv
 ughotghsrdhiohenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh
 fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr
 lhhonhdrnhgvth
X-ME-Proxy: <xmx:FxaJXwocbjFujkCieJ8CMw6a24dadnoTmcm4z2RQKkK_RELTA3mQkQ>
 <xmx:FxaJX2lYLsOrWEJakIoKqMCIJ01eHctcS9tZNFdAw5O8NDFU8DcSBg>
 <xmx:FxaJXw2_OYnEx_sbKT9cPNCruDnVe-CadS22VoD12xCXi7w0SiA0dQ>
 <xmx:FxaJX1_wWi5b_U4EsPX7KqzjHTqLDcfWSflaiTd-6JlmJxaxlm3_PA>
Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184])
 by mail.messagingengine.com (Postfix) with ESMTPA id 869E2306467E;
 Thu, 15 Oct 2020 23:40:06 -0400 (EDT)
From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: david.marchand@redhat.com,
	bruce.richardson@intel.com
Date: Fri, 16 Oct 2020 05:39:55 +0200
Message-Id: <20201016033955.2566518-1-thomas@monjalon.net>
X-Mailer: git-send-email 2.28.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH] doc: make sphinx errors more visible
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

When running Sphinx through ninja, the wrapper configured in meson
redirects stdout to a log file.
It makes more important to print issues on stderr.

Some warnings generated by the conf.py were hidden because
printed on stdout. The first improvement is to print them on stderr.

The second measure is to stop processing if meson was configured
with --werror.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 buildtools/call-sphinx-build.py |  3 +++
 doc/guides/conf.py              | 19 +++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/buildtools/call-sphinx-build.py b/buildtools/call-sphinx-build.py
index 26b199220a..8b266bec9b 100755
--- a/buildtools/call-sphinx-build.py
+++ b/buildtools/call-sphinx-build.py
@@ -14,6 +14,9 @@
 
 # set the version in environment for sphinx to pick up
 os.environ['DPDK_VERSION'] = version
+# forward error policy to conf.py
+if '-W' in extra_args:
+    os.environ['SPHINX_STOP_ON_ERROR'] = 'true'
 
 # for sphinx version >= 1.7 add parallelism using "-j auto"
 ver = run([sphinx, '--version'], stdout=PIPE,
diff --git a/doc/guides/conf.py b/doc/guides/conf.py
index 2ffe5a5969..ce91b9e658 100644
--- a/doc/guides/conf.py
+++ b/doc/guides/conf.py
@@ -12,6 +12,7 @@
 from os.path import basename
 from os.path import dirname
 from os.path import join as path_join
+from sys import stderr
 
 import configparser
 
@@ -22,9 +23,12 @@
     html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
 except:
     print('Install the sphinx ReadTheDocs theme for improved html documentation '
-          'layout: https://sphinx-rtd-theme.readthedocs.io/')
+          'layout: https://sphinx-rtd-theme.readthedocs.io/',
+          file=stderr)
     pass
 
+stop_on_error = environ['SPHINX_STOP_ON_ERROR']
+
 project = 'Data Plane Development Kit'
 html_logo = '../logo/DPDK_logo_vertical_rev_small.png'
 latex_logo = '../logo/DPDK_logo_horizontal_tag.png'
@@ -217,7 +221,10 @@ def generate_overview_table(output_filename, table_id, section, table_name, titl
         if not config.has_section(section):
             print("{}: File '{}' has no [{}] secton".format(warning,
                                                             ini_filename,
-                                                            section))
+                                                            section),
+                                                            file=stderr)
+            if stop_on_error:
+                raise Exception('Warning is treated as a failure')
             continue
 
         # Check for valid features names.
@@ -225,7 +232,10 @@ def generate_overview_table(output_filename, table_id, section, table_name, titl
             if name not in valid_features:
                 print("{}: Unknown feature '{}' in '{}'".format(warning,
                                                                 name,
-                                                                ini_filename))
+                                                                ini_filename),
+                                                                file=stderr)
+                if stop_on_error:
+                    raise Exception('Warning is treated as a failure')
                 continue
 
             if value:
@@ -418,7 +428,8 @@ def setup(app):
 
     if LooseVersion(sphinx_version) < LooseVersion('1.3.1'):
         print('Upgrade sphinx to version >= 1.3.1 for '
-              'improved Figure/Table number handling.')
+              'improved Figure/Table number handling.',
+              file=stderr)
         # Add a role to handle :numref: references.
         app.add_role('numref', numref_role)
         # Process the numref references once the doctree has been created.
-- 
2.28.0