From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A55FC00140 for ; Thu, 18 Aug 2022 17:26:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344479AbiHRRZ6 (ORCPT ); Thu, 18 Aug 2022 13:25:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343515AbiHRRZJ (ORCPT ); Thu, 18 Aug 2022 13:25:09 -0400 Received: from ms.lwn.net (ms.lwn.net [45.79.88.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ED50558E9; Thu, 18 Aug 2022 10:24:50 -0700 (PDT) Received: from localhost (unknown [IPv6:2601:281:8300:73:8b7:7001:c8aa:b65f]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ms.lwn.net (Postfix) with ESMTPSA id 25B6D380; Thu, 18 Aug 2022 17:24:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 ms.lwn.net 25B6D380 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lwn.net; s=20201203; t=1660843490; bh=3fRl1j7mKGqvV85JpGfgS3kDrE8+2lAy6KIi73rzFoc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=iKpMyJv3NbbL+LzdhHbx+QU4/u2VBzyekTAjUdJXeQ/8Bq1mmUsx2422T89+X385k XteDu3N47gDwd9r01p8gfH7FJ/nnmNQ7StQXjcVMIMIKJ732E+MxDQSmUE9Px49UEr TqIGxs//RbN3zGVa4hN/pjZfjYMkrDuLUqldcsiAfNz3fIpSJ/bp5RCGF6ITjf/cd4 mhTQnE4EZVT1ZHx1H9LJCMws7Uoe4oqL6seOBmvp9B2N+IOvoDKOZiBitRLH56sbQ1 WR6WNf4CzI+C6VP31CWSeWxIx7GPhLS66aR3ZDlx3iQhME8vpOStFbeV9VZUOJD37Z yN7UUb052ts+Q== From: Jonathan Corbet To: Akira Yokosawa , Mauro Carvalho Chehab Cc: linux-doc@vger.kernel.org, Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, Akira Yokosawa Subject: Re: [PATCH v2 2/3] docs/conf.py: Respect env variable SPHINX_IMGMATH In-Reply-To: <736e39fd-b068-80dd-b383-70e061e71bf5@gmail.com> References: <736e39fd-b068-80dd-b383-70e061e71bf5@gmail.com> Date: Thu, 18 Aug 2022 11:24:49 -0600 Message-ID: <87sfltbh26.fsf@meer.lwn.net> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org Akira Yokosawa writes: > On some distros with coarse-grained packaging policy, dvipng is > installed along with latex. In such cases, math rendering will > use imgmath by default. It is possible to override the choice by > specifying the option string of "-D html_math_renderer='mathjax'" > to sphinx-build (Sphinx >= 1.8). > > To provide developers an easier-to-use knob, add code for an env > variable "SPHINX_IMGMATH" which overrides the automatic choice > of math renderer for html docs. > > SPHINX_IMGMATH=yes : Load imgmath even if dvipng is not found > SPHINX_IMGMATH=no : Don't load imgmath (fall back to mathjax) > > Signed-off-by: Akira Yokosawa > Acked-by: Mauro Carvalho Chehab > --- > Changes since v1: > - No logical changes. > - Renames: > LOAD_IMGMATH -> SPHINX_IMGMATH (Mauro), > opt_load_imgmath -> env_sphinx_imgmath. > - Acked-by from Mauro. > > -- > Documentation/conf.py | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/Documentation/conf.py b/Documentation/conf.py > index 3ec1f845c839..0b8f20e8e22c 100644 > --- a/Documentation/conf.py > +++ b/Documentation/conf.py > @@ -128,8 +128,20 @@ autosectionlabel_maxdepth = 2 > # mathjax is the default math renderer since Sphinx 1.8. > have_latex = have_command('latex', '--version', 'pdfTeX') > have_dvipng = have_command('dvipng', '--version', 'dvipng') > -load_imgmath = ((have_latex and have_dvipng) > - or (major == 1 and minor < 8) > +load_imgmath = have_latex and have_dvipng > + > +# Respect SPHINX_IMGMATH (for html docs only) > +if 'SPHINX_IMGMATH' in os.environ: > + env_sphinx_imgmath = os.environ['SPHINX_IMGMATH'] > + if 'yes' in env_sphinx_imgmath: > + load_imgmath = True > + elif 'no' in env_sphinx_imgmath: > + load_imgmath = False > + else: # otherwide, auto selection > + pass That "else: pass" sequence does nothing, of course, and could be taken out. Otherwise fine, jon