[commit: ghc] ghc-8.6: users-guide: Fix build with sphinx 1.8 (6f717bc)

git at git.haskell.org git at git.haskell.org
Thu Sep 20 14:41:21 UTC 2018


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

On branch  : ghc-8.6
Link       : http://ghc.haskell.org/trac/ghc/changeset/6f717bc6440d6dcf368fc605fabb86d7619510af/ghc

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

commit 6f717bc6440d6dcf368fc605fabb86d7619510af
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Thu Sep 20 08:27:37 2018 -0400

    users-guide: Fix build with sphinx 1.8
    
    It seems that both add_object_type and add_directive_to_domain both register a
    directive. Previously sphinx didn't seem to mind this but as of Sphinx 1.8 it
    crashes with an exception.
    
    (cherry picked from commit 4eebc8016f68719e1ccdf460754a97d1f4d6ef05)


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

6f717bc6440d6dcf368fc605fabb86d7619510af
 docs/users_guide/flags.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/docs/users_guide/flags.py b/docs/users_guide/flags.py
index cc30b8c..c9f14f0 100644
--- a/docs/users_guide/flags.py
+++ b/docs/users_guide/flags.py
@@ -48,6 +48,8 @@ from docutils import nodes
 from docutils.parsers.rst import Directive, directives
 from sphinx import addnodes
 from sphinx.domains.std import GenericObject
+from sphinx.domains import ObjType
+from sphinx.roles import XRefRole
 from sphinx.errors import SphinxError
 from utils import build_table_from_list
 
@@ -597,14 +599,20 @@ def purge_flags(app, env, docname):
 ### Initialization
 
 def setup(app):
+    # Yuck: We can't use app.add_object_type since we need to provide the
+    # Directive instance ourselves.
+    std_object_types = app.registry.domain_object_types.setdefault('std', {})
 
     # 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)
+    app.add_role_to_domain('std', 'ghc-flag', XRefRole())
+    std_object_types['ghc-flag'] = ObjType('ghc-flag', 'ghc-flag')
 
     # Add extension directive, and override the class with our own
-    app.add_object_type('extension', 'extension')
     app.add_directive_to_domain('std', 'extension', LanguageExtension)
+    app.add_role_to_domain('std', 'extension', XRefRole())
+    std_object_types['extension'] = ObjType('ghc-flag', 'ghc-flag')
+
     # NB: language-extension would be misinterpreted by sphinx, and produce
     # lang="extensions" XML attributes
 



More information about the ghc-commits mailing list