summaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
authorPatrick Rudolph <siro@das-labor.org>2020-05-17 20:04:12 +0200
committerPatrick Georgi <pgeorgi@google.com>2020-07-01 21:51:26 +0000
commitf664321508e1ebfd56f656cbf852997716bbbb3d (patch)
tree0f553602bb2a492f040d10fe55b2f9d7c4a24f58 /Documentation
parentecdbc842e2d48362f27b8652d05606d93d1d7e26 (diff)
Documentation: Add several fixes
* Add support for Sphinx 3.0+ * Add backward support for Sphinx 1.8 and older * Make sphinxcontrib ditaa an optional extension * Allow SPHINXOPTS to be set from command line * Add sphinx and sphinx-lint to top level Makefile Change-Id: If10aef51dc426445cb742aad13b19ee7fe169c51 Signed-off-by: Patrick Rudolph <siro@das-labor.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/41492 Reviewed-by: Patrick Georgi <pgeorgi@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/Makefile.sphinx2
-rw-r--r--Documentation/conf.py29
2 files changed, 28 insertions, 3 deletions
diff --git a/Documentation/Makefile.sphinx b/Documentation/Makefile.sphinx
index caa8190a32..6930130cb5 100644
--- a/Documentation/Makefile.sphinx
+++ b/Documentation/Makefile.sphinx
@@ -2,7 +2,7 @@
#
# You can set these variables from the command line.
-SPHINXOPTS =
+SPHINXOPTS ?=
SPHINXBUILD = sphinx-build
SPHINXAUTOBUILD = sphinx-autobuild
PAPER =
diff --git a/Documentation/conf.py b/Documentation/conf.py
index 8848ee6512..f82fa0e182 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -1,6 +1,18 @@
# -*- coding: utf-8 -*-
import subprocess
from recommonmark.parser import CommonMarkParser
+import sphinx
+
+# Get Sphinx version
+major = 0
+minor = 0
+patchlevel = 0
+version = sphinx.__version__.split(".")
+if len(version) > 1:
+ major = int(version[0])
+ minor = int(version[1])
+ if len(version) > 2:
+ patchlevel = int(version[2])
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -25,7 +37,18 @@ release = subprocess.check_output(('git', 'describe')).decode("utf-8")
# The short X.Y version.
version = release.split("-")[0]
-extensions = ['sphinxcontrib.ditaa']
+extensions = []
+# Load recommonmark, supported since 1.8+
+if major >= 2 or (major == 1 and minor >= 8):
+ extensions += ['recommonmark']
+
+# Try to load DITAA
+try:
+ import sphinxcontrib.ditaa
+except ImportError:
+ print("Error: Please install sphinxcontrib.ditaa for ASCII art conversion\n")
+else:
+ extensions += 'sphinxcontrib.ditaa'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -187,7 +210,9 @@ class MyCommonMarkParser(CommonMarkParser):
def setup(app):
from recommonmark.transform import AutoStructify
- app.add_source_parser('.md', MyCommonMarkParser)
+ # Load recommonmark on old Sphinx
+ if major == 1 and minor < 8:
+ app.add_source_parser('.md', MyCommonMarkParser)
app.add_config_value('recommonmark_config', {
'enable_auto_toc_tree': True,