Commit af0bf169 authored by Ben Gamari's avatar Ben Gamari 🐢

user-guide: Allow build with sphinx < 1.8

Apparently the override argument to add_directive_to_domain was added in sphinx
1.8.

(cherry picked from commit a257782f)
parent 5ed9c861
...@@ -46,9 +46,11 @@ ...@@ -46,9 +46,11 @@
from docutils import nodes from docutils import nodes
from docutils.parsers.rst import Directive, directives from docutils.parsers.rst import Directive, directives
import sphinx
from sphinx import addnodes from sphinx import addnodes
from sphinx.domains.std import GenericObject from sphinx.domains.std import GenericObject
from sphinx.errors import SphinxError from sphinx.errors import SphinxError
from distutils.version import LooseVersion
from utils import build_table_from_list from utils import build_table_from_list
### Settings ### Settings
...@@ -597,15 +599,18 @@ def purge_flags(app, env, docname): ...@@ -597,15 +599,18 @@ def purge_flags(app, env, docname):
### Initialization ### Initialization
def setup(app): def setup(app):
# The override argument to add_directive_to_domain is only supported by >= 1.8
sphinx_version = LooseVersion(sphinx.__version__)
override_arg = {'override': True} if sphinx_version >= LooseVersion('1.8') else {}
# Add ghc-flag directive, and override the class with our own # Add ghc-flag directive, and override the class with our own
app.add_object_type('ghc-flag', 'ghc-flag') app.add_object_type('ghc-flag', 'ghc-flag')
app.add_directive_to_domain('std', 'ghc-flag', Flag, override=True) app.add_directive_to_domain('std', 'ghc-flag', Flag, **override_arg)
# Add extension directive, and override the class with our own # Add extension directive, and override the class with our own
app.add_object_type('extension', 'extension') app.add_object_type('extension', 'extension')
app.add_directive_to_domain('std', 'extension', LanguageExtension, app.add_directive_to_domain('std', 'extension', LanguageExtension,
override=True) **override_arg)
# NB: language-extension would be misinterpreted by sphinx, and produce # NB: language-extension would be misinterpreted by sphinx, and produce
# lang="extensions" XML attributes # lang="extensions" XML attributes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment