From 30cb9afb4e00322248de4a061c5ac7a0d2fdac02 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 16 May 2018 11:49:40 +0200 Subject: [PATCH] m.plots: make the font configurable so we can pass the CI. --- doc/plugins/plots.rst | 12 +- pelican-plugins/m/plots.py | 17 ++- pelican-plugins/m/test/plots/page.html | 152 +++++++++++++------------ pelican-plugins/m/test/plots/page.rst | 9 ++ pelican-plugins/m/test/test_plots.py | 3 +- 5 files changed, 110 insertions(+), 83 deletions(-) diff --git a/doc/plugins/plots.rst b/doc/plugins/plots.rst index 1da954ab..8733ea65 100644 --- a/doc/plugins/plots.rst +++ b/doc/plugins/plots.rst @@ -49,9 +49,15 @@ package to your :py:`PLUGINS` in ``pelicanconf.py``. .. code:: python PLUGINS += ['m.plots'] - -In addition you need the `Matplotlib `_ library -installed. Get it via ``pip`` or your distribution package manager: + M_PLOTS_FONT = 'Source Sans Pro' + +Set :py:`M_PLOTS_FONT` to a font that matches your CSS theme (it's Source Sans +Pro for `builtin m.css themes <{filename}/css/themes.rst>`_), note that you +*need to have the font installed* on your system, otherwise it will fall back +to whatever system font it finds instead (for example DejaVu Sans) and the +output won't look as expected. In addition you need the +`Matplotlib `_ library installed. Get it via ``pip`` +or your distribution package manager: .. code:: sh diff --git a/pelican-plugins/m/plots.py b/pelican-plugins/m/plots.py index dc809e02..173ca76d 100644 --- a/pelican-plugins/m/plots.py +++ b/pelican-plugins/m/plots.py @@ -37,7 +37,6 @@ import io import pelican.signals -mpl.rcParams['font.family'] = 'Source Sans Pro' mpl.rcParams['font.size'] = '11' mpl.rcParams['axes.titlesize'] = '13' @@ -101,13 +100,13 @@ _class_mapping = [ ('

m.plots

-
+

Note: the test uses DejaVu Sans instead of Source Sans Pro in order to have +predictable rendering on the CIs.

+
- + - 0 + 0 - + - 5 + 5 - + - 10 + 10 - + - 15 + 15 - + - 20 + 20 - + - 25 + 25 - + - 30 + 30 - meters, i guess? + meters, i guess? @@ -126,32 +130,32 @@ - + - First + First - + - Second + Second - A plot with a single color + A plot with a single color - - + + @@ -166,16 +170,16 @@ - + 3.0 ± 0.1 Mondays - + 4.0 ± 2.1 Mondays - + 5.0 ± 1.0 Mondays - + @@ -184,75 +188,75 @@ - + - 0 + 0 - + - 1 + 1 - + - 2 + 2 - + - 3 + 3 - + - 4 + 4 - + - 5 + 5 - + - 6 + 6 - Mondays + Mondays @@ -262,79 +266,79 @@ - + - January - + January + - + - February - + February + - + - March - + March + - - - + + + - - - - + + + + - - - - + + + + - - a paradise + + a paradise - - okay + + okay - - hell! + + hell! - A plot with separate colors, extra labels, error bars and custom height + A plot with separate colors, extra labels, error bars and custom height - - + + diff --git a/pelican-plugins/m/test/plots/page.rst b/pelican-plugins/m/test/plots/page.rst index 805c81a2..d0925f3c 100644 --- a/pelican-plugins/m/test/plots/page.rst +++ b/pelican-plugins/m/test/plots/page.rst @@ -1,6 +1,15 @@ m.plots ####### +Note: the test uses DejaVu Sans instead of Source Sans Pro in order to have +predictable rendering on the CIs. + +.. raw:: html + + + .. plot:: A plot with a single color :type: barh :labels: diff --git a/pelican-plugins/m/test/test_plots.py b/pelican-plugins/m/test/test_plots.py index a7d011ac..e9a7a87f 100644 --- a/pelican-plugins/m/test/test_plots.py +++ b/pelican-plugins/m/test/test_plots.py @@ -30,7 +30,8 @@ class Plots(PluginTestCase): def test(self): self.run_pelican({ - 'PLUGINS': ['m.htmlsanity', 'm.plots'] + 'PLUGINS': ['m.htmlsanity', 'm.plots'], + 'M_PLOTS_FONT': 'DejaVu Sans' }) self.assertEqual(*self.actual_expected_contents('page.html')) -- 2.30.2