From patchwork Fri Aug 5 15:14:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Heiser X-Patchwork-Id: 9265507 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9DDE160760 for ; Fri, 5 Aug 2016 15:14:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D3C128426 for ; Fri, 5 Aug 2016 15:14:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F26428453; Fri, 5 Aug 2016 15:14:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B12FB28426 for ; Fri, 5 Aug 2016 15:14:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759925AbcHEPOr (ORCPT ); Fri, 5 Aug 2016 11:14:47 -0400 Received: from smtp3-1.goneo.de ([85.220.129.38]:47191 "EHLO smtp3-1.goneo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759915AbcHEPOp (ORCPT ); Fri, 5 Aug 2016 11:14:45 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp3.goneo.de (Postfix) with ESMTP id 0D54223FA1B; Fri, 5 Aug 2016 17:14:32 +0200 (CEST) X-Virus-Scanned: by goneo Received: from smtp3.goneo.de ([127.0.0.1]) by localhost (smtp3.goneo.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zhcZiUwd_5se; Fri, 5 Aug 2016 17:14:21 +0200 (CEST) Received: from ubu1604.fritz.box (dyndsl-095-033-012-240.ewe-ip-backbone.de [95.33.12.240]) by smtp3.goneo.de (Postfix) with ESMTPSA id 0AC5123F029; Fri, 5 Aug 2016 17:14:20 +0200 (CEST) From: Markus Heiser To: Mauro Carvalho Chehab , linux-media@vger.kernel.org Cc: Markus Heiser , Jani Nikula , Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH] doc-rst: support *sphinx build themes* Date: Fri, 5 Aug 2016 17:14:07 +0200 Message-Id: <1470410047-9911-1-git-send-email-markus.heiser@darmarit.de> X-Mailer: git-send-email 2.7.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Heiser Load an additional configuration file into conf.py namespace. The name of the configuration file is taken from the environment SPHINX_CONF. The external configuration file extends (or overwrites) the configuration values from the origin conf.py. With this you are able to maintain *build themes*. E.g. to create your own nit-picking *build theme*, create a file Documentation/conf_nitpick.py:: nitpicky=True nitpick_ignore = [ ("c:func", "clock_gettime"), ... ] and run make with SPHINX_CONF environment:: make SPHINX_CONF=conf_nitpick.py htmldocs Signed-off-by: Markus Heiser --- Documentation/conf.py | 9 +++++++++ Documentation/sphinx/load_config.py | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Documentation/sphinx/load_config.py diff --git a/Documentation/conf.py b/Documentation/conf.py index 96b7aa6..d502775 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -20,6 +20,8 @@ import os # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath('sphinx')) +from load_config import loadConfig + # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. @@ -419,3 +421,10 @@ pdf_documents = [ # line arguments. kerneldoc_bin = '../scripts/kernel-doc' kerneldoc_srctree = '..' + + +# ------------------------------------------------------------------------------ +# Since loadConfig overwrites settings from the global namespace, it has to be +# the last statement in the conf.py file +# ------------------------------------------------------------------------------ +loadConfig(globals()) diff --git a/Documentation/sphinx/load_config.py b/Documentation/sphinx/load_config.py new file mode 100644 index 0000000..44bdd22 --- /dev/null +++ b/Documentation/sphinx/load_config.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8; mode: python -*- +# pylint: disable=R0903, C0330, R0914, R0912, E0401 + +import os +from sphinx.util.pycompat import execfile_ + +# ------------------------------------------------------------------------------ +def loadConfig(namespace): +# ------------------------------------------------------------------------------ + + u"""Load an additional configuration file into *namespace*. + + The name of the configuration file is taken from the environment + ``SPHINX_CONF``. The external configuration file extends (or overwrites) the + configuration values from the origin ``conf.py``. With this you are able to + maintain *build themes*. """ + + config_file = os.environ.get("SPHINX_CONF", None) + if config_file is not None and os.path.exists(config_file): + config_file = os.path.abspath(config_file) + config = namespace.copy() + config['__file__'] = config_file + execfile_(config_file, config) + del config['__file__'] + namespace.update(config)