From 06e01e5ac88cb764d7750a74ea4b1109d39f62f2 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Mon, 25 Jan 2021 17:53:27 -0600 Subject: [PATCH] doc/ide: use sphinx.ext.imgmath MathJax uses a CDN to to distribute the package. So in order to use the docs offline, we would have to include our own copy. But it is a bit large (50-ish MB), so it is easier to use sphinx.ext.imgmath instead to generate svg images. The situation might be different with MathJax v3, but that requires Sphinx v4. --- .github/workflows/pythonpackage.yml | 6 +++++- doc/ide/conf.py | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 74a2ec2..5b32e68 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -8,7 +8,7 @@ on: [ push, pull_request ] jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: python-version: [3.8, 3.9] @@ -35,5 +35,9 @@ jobs: run: poetry run doc8 - name: Build html docs for Read the Docs run: poetry run make -C doc html + - name: Instal IDE docs dependencies + run: | + sudo apt-get update + sudo apt-get install dvisvgm preview-latex-style texlive texlive-fonts-extra texlive-latex-extra - name: Build html docs for Pybricks Code IDE run: poetry run make -C doc html SOURCEDIR=ide diff --git a/doc/ide/conf.py b/doc/ide/conf.py index 867edef..5acd7e0 100644 --- a/doc/ide/conf.py +++ b/doc/ide/conf.py @@ -19,6 +19,14 @@ html_show_copyright = False html_show_sphinx = False html_css_files = ['css/ide.css'] +imgmath_image_format = 'svg' +imgmath_use_preview = True # requires Sphinx v3 +imgmath_latex_preamble = r''' +\usepackage{newtxsf} +''' + exec(open(os.path.abspath("../common/conf.py")).read()) +extensions.remove('sphinx.ext.mathjax') # noqa F821 +extensions.append('sphinx.ext.imgmath') # noqa F821 html_theme_options['prev_next_buttons_location'] = None # noqa F821