linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Akira Yokosawa <akiyks@gmail.com>
To: Jonathan Corbet <corbet@lwn.net>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-doc@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	linux-kernel@vger.kernel.org, Akira Yokosawa <akiyks@gmail.com>
Subject: [PATCH v3 0/2] docs: conf.py: Reduce texlive dependency
Date: Sat, 27 Aug 2022 13:35:03 +0900	[thread overview]
Message-ID: <9b8ff6d7-e97a-c03f-7d46-4b80ae3cf196@gmail.com> (raw)

Hi,

This is v3 which addresses Jon's comments to v2 [1], but slightly
different ways from Jon's suggestions.

Changes since v2 [1]:
 - Drop Patch 3/3, which is in docs-fixes now.
 - Patch 1/2:
     o Simplify find_command() by using shutil.which(). For guessing
       available commands, it should be good enough.
     o Mention find_command() in the changelog.
 - Patch 2/2:
     o Instead of silently ignoring unknown setting of SPHINX_IMGMATH,
       print a warning msg.

Acked-bys from Mauro are kept, as I assume these changes wouldn't
affect the purpose of each patch.

Changes since v1 [2]:
 - Patch 2/3: Rename LOAD_IMGMATH -> SPHINX_IMGMATH (Mauro).
 - For the series: Acked-bys from Mauro.

Amended coverletter:

This was inspired from the discussion on the expected behavior of
sphinx-pre-install [3].

There was a mismatch between Mauro's intent and my expectation for
the --no-pdf option of sphinx-pre-install.

My thought was if I installed all the packages suggested from
"./scripts/sphinx-pre-install --no-pdf", "make htmldocs" should run
free of complaints of missing commands or packages.

However, I got this warning when I tried the procedure on a debian-
based container image:

    WARNING: LaTeX command 'latex' cannot be run (needed for math display),
    check the imgmath_latex setting

, or:

    WARNING: dvipng command 'dvipng' cannot be run (needed for math display),
    check the imgmath_dvipng setting

Mauro's response to my complaint was this:

> The idea of using --no-pdf is to setup an environment without LaTeX,
> meaning that math tags would only be partially parsed: basically, the
> output would be html with LaTeX-like math expressions (at least last
> time I tried).

The mismatch can be resolved by using "mathjax" for math rendering
and making "make htmldocs" be free of texlive packages.

mathjax is the default math renderer since Sphinx 1.8.  It delegates
math rendering to web browsers.  

As Mauro has pointed out, "make epubdocs" requires imgmath.

So this patch set treats mathjax as a fallback math renderer for html
docs when imgmath requirements are not met.
Existing systems which meet imgmath requirements are not affected by
this change.

Summary of math rendering in html:

         dvipng, browser             before           after
    ==========================  ===============  ================
    dvipng                      imgmath (png)    <--
    no divpng, with javascript  raw math:: code  mathjax
    no dvipng, w/o javascript   raw math:: code  raw mathjax code

Patch 1/2 adds code in conf.py so that for html docs, the imgmath
extension will be loaded only when both latex and dvipng are available.
For epub docs, imgmath will always be loaded (no change).

Patch 2/2 adds code respecting a new env variable "SPHINX_IMGMATH" which
will override the math renderer choice. This variable can be helpful
on distros such as Arch linux, Mageia, etc. whose packaging policy is
coarse-grained.

E.g., to test math rendering by mathjax, run:
    make SPHINX_IMGMATH=no htmldocs

I mentioned in the thread of [3] that imgmath can generate scalable
math images in SVG.

My plan was to implement that option as well.  But during tests under
Fedora/CentOS/openSUSE, I encountered a couple of warnings from dvisvgm.
That would be regressions on existing systems which happen to have
not-working dvisvgm along with working dvipng.  I'm thinking of adding
the SVG option later if I can figure out the minimal requirement for
dvisvgm under imgmath.

[1] v2: https://lore.kernel.org/r/c41cab17-afd6-bc99-56a1-e4e73b8c1ef6@gmail.com/
[2] v1: https://lore.kernel.org/r/12d078f5-6995-b039-7076-bdb1f372a799@gmail.com/
[3]: https://lore.kernel.org/r/3ba5a52e-cab6-05cf-a66e-adc58c467e1f@gmail.com/

        Thanks, Akira
--
Akira Yokosawa (2):
  docs/conf.py: Treat mathjax as fallback math renderer
  docs/conf.py: Respect env variable SPHINX_IMGMATH

 Documentation/conf.py | 41 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)


base-commit: e1a0cc8865e3152e9fe43c6436b44e64c0359dfb
-- 
2.25.1


             reply	other threads:[~2022-08-27  4:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-27  4:35 Akira Yokosawa [this message]
2022-08-27  4:37 ` [PATCH v3 1/2] docs/conf.py: Treat mathjax as fallback math renderer Akira Yokosawa
2022-08-29 16:59   ` Jonathan Corbet
2022-08-27  4:38 ` [PATCH v3 2/2] docs/conf.py: Respect env variable SPHINX_IMGMATH Akira Yokosawa
2022-08-28  0:38   ` Randy Dunlap
2022-08-28  3:47     ` Akira Yokosawa
2022-08-28  4:59       ` Randy Dunlap
2022-08-29 16:52 ` [PATCH v3 0/2] docs: conf.py: Reduce texlive dependency Jonathan Corbet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9b8ff6d7-e97a-c03f-7d46-4b80ae3cf196@gmail.com \
    --to=akiyks@gmail.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).