Update Makefile doc rule.
epsi-builds/msspec_python3/pipeline/head This commit looks good Details

This commit is contained in:
sylvain tricot 2021-02-23 10:26:22 +01:00
parent 1e6e561ba2
commit a3706d84be
2 changed files with 11 additions and 101 deletions

View File

@ -28,7 +28,7 @@ devel: venv pybinding wx
wx: wx:
@echo "Building wxPython for your `python --version` under Linux $(DISTRO_RELEASE)..." @$(INSIDE_VENV) echo "Building wxPython for your `python --version 2>&1` under Linux $(DISTRO_RELEASE)..."
# Create a folder to build wx into # Create a folder to build wx into
@mkdir -p _build_wx @mkdir -p _build_wx
# download the wheel or the source if it cannot find a wheel # download the wheel or the source if it cannot find a wheel
@ -48,11 +48,9 @@ wx:
doc: doc:
@echo "Building pdf and html documentation..." @echo "Building pdf and html documentation..."
@mkdir -p package/ @$(INSIDE_VENV) pip install sphinx
@+$(MAKE) -C doc/ latexpdf @+$(INSIDE_VENV) $(MAKE) -C doc/ latexpdf
@rm -rf package/*.pdf @+$(INSIDE_VENV) $(MAKE) -C doc/ html
@cp "doc/build/latex/MsSpec-python.pdf" "./package/MsSpec-$(VERSION).pdf"
@+$(MAKE) -C doc/ html
clean:: clean::

View File

@ -1,88 +0,0 @@
# SCons file for Sphinx
import sys
sys.path.append('./source')
import subprocess
from pathlib import Path
from sphinx.cmd.build import main as sphinx_build
import custom
doc = Environment(
# You can set these variables from the command line.
SPHINXOPTS = "",
SPHINXBUILD = "sphinx-build",
PAPER = "",
BUILDDIR = "build")
# Internal variables.
PAPEROPT_a4 = "-D latex_elements.papersize=a4paper"
#PAPEROPT_a4 = "-D latex_paper_size=a4"
#PAPEROPT_letter = "-D latex_paper_size=letter"
ALLSPHINXOPTS = f"-d {doc['BUILDDIR']}/doctrees {PAPEROPT_a4} {doc['SPHINXOPTS']} source"
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = "{PAPEROPT_a4} {SPHINXOPTS} source"
# create the banner of the website
banner_src = "./source/title_template.svg"
banner_tgt = "./source/title.svg"
def build_banner(env, target, source):
custom.modify_banner(str(source[0]), str(target[0]))
banner = doc.Command(banner_tgt, banner_src, Action(build_banner, "Creating the website banner..."))
doc.Alias('banner', banner)
# convert *.svg and *.gif to *.png
# first find all of them
src_dir = Path('./source')
svg_pictures = list(src_dir.glob('**/*.svg'))
gif_pictures = list(src_dir.glob('**/*.gif'))
# conversion
pictures = []
for f in svg_pictures + banner:
pictures += doc.Command(str(f).replace('.svg', '.png'), str(f),
Action("convert -background none -density 150 $SOURCE $TARGET",
"Converting $SOURCE to PNG..."))
for f in gif_pictures:
pictures += doc.Command(str(f).replace('.gif', '.png'), str(f),
Action("convert -background none -density 150 $SOURCE[0] $TARGET",
"Converting $SOURCE to PNG..."))
doc.Alias('pictures', pictures)
Depends(pictures, banner)
# html
def html_builder(env, target, source):
return sphinx_build(f"-b html {ALLSPHINXOPTS} {doc['BUILDDIR']}/html".split())
html = doc.Command("html.target", [], Action(html_builder, "Building html..."))
Depends(html, [banner, pictures])
AlwaysBuild(html)
Clean(html, f"{doc['BUILDDIR']}/html")
doc.Alias('html', html)
# generate sitemap.xml
t = f"{doc['BUILDDIR']}/html/sitemap.xml"
cmd = f"python source/sitemap-generate.py --url https://msspec.cnrs.fr --path {doc['BUILDDIR']}/html {t}"
sitemap = doc.Command(t, [], cmd)#Action(cmd, "Generating sitemap.xml..."))
Depends(sitemap, html)
doc.Alias('html', sitemap)
# install ownership
t = f"{doc['BUILDDIR']}/html"
s = Glob('source/google*.html')
ownership = doc.Install(t, s)
Depends(ownership, html)
doc.Alias('html', ownership)
# LaTeX PDF
def latexpdf_builder(env, target, source):
rc = sphinx_build(f"-b latex {ALLSPHINXOPTS} {doc['BUILDDIR']}/latex".split())
if rc == 0:
subprocess.call(f"make -C {doc['BUILDDIR']}/latex all-pdf".split())
latexpdf = doc.Command("latexpdf.target", [], Action(latexpdf_builder, "Building LaTeX PDF..."))
Depends(latexpdf, [banner, pictures])
AlwaysBuild(latexpdf)
Clean(latexpdf, f"{doc['BUILDDIR']}/latex")
doc.Alias('latexpdf', latexpdf)