Use sphinx.ext.imgconverter for converting SVG images for PDF doc builds

This commit is contained in:
Paul Romano 2017-12-29 15:10:55 -06:00
parent 98b2bcb275
commit 6b48fe9f6b
4 changed files with 13 additions and 34 deletions

View file

@ -13,10 +13,6 @@ PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# SVG to PDF conversion
SVG2PDF = inkscape
PDFS = $(patsubst %.svg,%.pdf,$(wildcard $(IMAGEDIR)/*.svg))
# Tikz to PNG conversion
PNGS = $(patsubst %.tex,%.png,$(wildcard $(IMAGEDIR)/*.tex))
@ -41,21 +37,13 @@ help:
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
# Pattern rule for converting SVG to PDF
%.pdf: %.svg
$(SVG2PDF) -f $< -A $@
%.png: %.tex
pdflatex --interaction=nonstopmode --output-directory=$(IMAGEDIR) $<
pdftoppm -r 120 -singlefile $(patsubst %.tex,%.pdf, $<) $(basename $<)
convert -trim -fuzz 2% -transparent white $(patsubst %.tex,%.ppm,$<) $@
# Rule to build PDFs
images: $(PDFS) $(PNGS)
clean:
-rm -rf $(BUILDDIR)/*
-rm -rf $(PDFS)
-rm -rf source/pythonapi/generated/
html:

View file

@ -52,6 +52,7 @@ extensions = ['sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
'sphinx.ext.imgconverter',
'sphinx_numfig',
'notebook_sphinxext']
@ -253,5 +254,5 @@ intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
'pandas': ('http://pandas.pydata.org/pandas-docs/stable/', None),
'matplotlib': ('http://matplotlib.org/', None)
'matplotlib': ('https://matplotlib.org/', None)
}

View file

@ -5,15 +5,16 @@ Building Sphinx Documentation
=============================
In order to build the documentation in the ``docs`` directory, you will need to
have the Sphinx_ third-party Python package. The easiest way to install Sphinx
is via pip:
have the `Sphinx <http://openmc.readthedocs.io/en/latest/>`_ third-party Python
package. The easiest way to install Sphinx is via pip:
.. code-block:: sh
sudo pip install sphinx
Additionally, you will also need a Sphinx extension for numbering figures. The
Numfig_ package can be installed directly with pip:
`Numfig <http://openmc.readthedocs.io/en/latest/>`_ package can be installed
directly with pip:
.. code-block:: sh
@ -24,7 +25,7 @@ Building Documentation as a Webpage
-----------------------------------
To build the documentation as a webpage (what appears at
http://mit-crpg.github.io/openmc), simply go to the ``docs`` directory and run:
http://openmc.readthedocs.io), simply go to the ``docs`` directory and run:
.. code-block:: sh
@ -35,20 +36,9 @@ Building Documentation as a PDF
-------------------------------
To build PDF documentation, you will need to have a LaTeX distribution installed
on your computer as well as Inkscape_, which is used to convert .svg files to
.pdf files. Inkscape can be installed in a Debian-derivative with:
.. code-block:: sh
sudo apt install inkscape
One the pre-requisites are installed, simply go to the ``docs`` directory and
run:
on your computer. Once you have a LaTeX distribution installed, simply go to the
``docs`` directory and run:
.. code-block:: sh
make latexpdf
.. _Sphinx: http://sphinx-doc.org
.. _Numfig: https://pypi.python.org/pypi/sphinx_numfig
.. _Inkscape: https://inkscape.org

View file

@ -47,7 +47,7 @@ dividing space into two half-spaces.
.. _fig-halfspace:
.. figure:: ../_images/halfspace.*
.. figure:: ../_images/halfspace.svg
:align: center
:figclass: align-center
@ -63,7 +63,7 @@ defined as the intersection of an ellipse and two planes.
.. _fig-union:
.. figure:: ../_images/union.*
.. figure:: ../_images/union.svg
:align: center
:figclass: align-center
@ -482,7 +482,7 @@ upper-right tiles, respectively.
.. _fig-rect-lat:
.. figure:: ../_images/rect_lat.*
.. figure:: ../_images/rect_lat.svg
:align: center
:figclass: align-center
:width: 400px
@ -521,7 +521,7 @@ right side.
.. _fig-hex-lat:
.. figure:: ../_images/hex_lat.*
.. figure:: ../_images/hex_lat.svg
:align: center
:figclass: align-center
:width: 400px