[commit: ghc] ghc-8.6: users_guide: fix sphinx error caused by non-explicit override (5ed9c86)

git at git.haskell.org git at git.haskell.org
Thu Sep 20 20:06:15 UTC 2018


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

On branch  : ghc-8.6
Link       : http://ghc.haskell.org/trac/ghc/changeset/5ed9c86134200db615908d445702522d95f9025a/ghc

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

commit 5ed9c86134200db615908d445702522d95f9025a
Author: Zejun Wu <watashi at watashi.ws>
Date:   Thu Sep 20 16:05:28 2018 -0400

    users_guide: fix sphinx error caused by non-explicit override
    
    Encouter following error when `make`:
    
    ```
    Extension error:
    The 'ghc-flag' directive is already registered to domain std
    ```
    
    as we register `ghc-flag` to `std` in `add_object_type` first and then
    overtride it in `add_directive_to_domain`.
    
    Test Plan:
      make -C utils/haddock/doc html SPHINX_BUILD=/usr/bin/sphinx-build
    
    Reviewers: austin, bgamari, patrickdoc
    
    Subscribers: rwbarton, carter
    
    Differential Revision: https://phabricator.haskell.org/D5161
    
    (cherry picked from commit 8c7d33a8ff6d3ea55b5dc8108d9441521af68ab8)


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

5ed9c86134200db615908d445702522d95f9025a
 docs/users_guide/flags.py | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/docs/users_guide/flags.py b/docs/users_guide/flags.py
index c9f14f0..df23f38 100644
--- a/docs/users_guide/flags.py
+++ b/docs/users_guide/flags.py
@@ -48,8 +48,6 @@ 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
 
@@ -599,20 +597,15 @@ 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_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')
+    app.add_object_type('ghc-flag', 'ghc-flag')
+    app.add_directive_to_domain('std', 'ghc-flag', Flag, override=True)
 
     # Add extension directive, and override the class with our own
-    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')
-
+    app.add_object_type('extension', 'extension')
+    app.add_directive_to_domain('std', 'extension', LanguageExtension,
+            override=True)
     # NB: language-extension would be misinterpreted by sphinx, and produce
     # lang="extensions" XML attributes
 



More information about the ghc-commits mailing list