[commit: ghc] master: user-guide: Allow build with sphinx < 1.8 (a257782)

git at git.haskell.org git at git.haskell.org
Thu Sep 20 23:51:31 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/a257782f56e5e330349d4cc7db71e297d8396c67/ghc

>---------------------------------------------------------------

commit a257782f56e5e330349d4cc7db71e297d8396c67
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Thu Sep 20 17:35:05 2018 -0400

    user-guide: Allow build with sphinx < 1.8
    
    Apparently the override argument to add_directive_to_domain was added in sphinx
    1.8.


>---------------------------------------------------------------

a257782f56e5e330349d4cc7db71e297d8396c67
 docs/users_guide/flags.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/docs/users_guide/flags.py b/docs/users_guide/flags.py
index 0e56bdf..c95b9aa 100644
--- a/docs/users_guide/flags.py
+++ b/docs/users_guide/flags.py
@@ -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
@@ -599,15 +601,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
 



More information about the ghc-commits mailing list