Skip to content

Commit

Permalink
user-guide: Allow build with sphinx < 1.8
Browse files Browse the repository at this point in the history
Apparently the override argument to add_directive_to_domain was added in sphinx
1.8.

(cherry picked from commit a257782)
  • Loading branch information
bgamari committed Sep 20, 2018
1 parent 5ed9c86 commit af0bf16
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions docs/users_guide/flags.py
Expand Up @@ -46,9 +46,11 @@

from docutils import nodes
from docutils.parsers.rst import Directive, directives
import sphinx
from sphinx import addnodes
from sphinx.domains.std import GenericObject
from sphinx.errors import SphinxError
from distutils.version import LooseVersion
from utils import build_table_from_list

### Settings
Expand Down Expand Up @@ -597,15 +599,18 @@ def purge_flags(app, env, docname):
### Initialization

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
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
app.add_object_type('extension', 'extension')
app.add_directive_to_domain('std', 'extension', LanguageExtension,
override=True)
**override_arg)
# NB: language-extension would be misinterpreted by sphinx, and produce
# lang="extensions" XML attributes

Expand Down

0 comments on commit af0bf16

Please sign in to comment.