From 68fe0f2067d54ac0073f56a556461c5990bffe93 Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Fri, 12 Apr 2019 17:07:26 -0700 Subject: [PATCH] Copy the CSS into the built docs This patch adds code that copies the CSS file into the _static directory on build. Previously the CSS file was not included in the built docs. Change-Id: Ic7cc52b007b0c40b3aa85a242544c3c6aac16c02 --- .../notes/copy-css-to-static-938b35b03a568abc.yaml | 5 +++++ sphinx_feature_classification/support_matrix.py | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 releasenotes/notes/copy-css-to-static-938b35b03a568abc.yaml diff --git a/releasenotes/notes/copy-css-to-static-938b35b03a568abc.yaml b/releasenotes/notes/copy-css-to-static-938b35b03a568abc.yaml new file mode 100644 index 0000000..fc7124f --- /dev/null +++ b/releasenotes/notes/copy-css-to-static-938b35b03a568abc.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Adds a handler to copy the CSS file into the _static directory on build. + Previously the CSS file was not being copied over into the built docs. diff --git a/sphinx_feature_classification/support_matrix.py b/sphinx_feature_classification/support_matrix.py index 0d4c8b4..02e4997 100644 --- a/sphinx_feature_classification/support_matrix.py +++ b/sphinx_feature_classification/support_matrix.py @@ -19,7 +19,9 @@ It is used via a single directive in the .rst file """ +from os import path import re +import shutil from docutils import nodes from docutils.parsers import rst @@ -463,6 +465,15 @@ class Directive(rst.Directive): return para +def on_build_finished(app, exc): + if exc is None: + src = path.join(path.abspath(path.dirname(__file__)), + 'support-matrix.css') + dst = path.join(app.outdir, '_static', 'support-matrix.css') + shutil.copyfile(src, dst) + + def setup(app): app.add_directive('support_matrix', Directive) app.add_css_file('support-matrix.css') + app.connect('build-finished', on_build_finished)