Commit 7cd54538 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot
Browse files

users-guide: Make reverse flags addressable via :ghc-flag:

Previously one could not easily link to the :reverse: flag of a
ghc-flag.
parent 8a2e8408
......@@ -212,8 +212,10 @@ class Flag(GenericFlag):
# Manually create references
name_string = ", ".join([':ghc-flag:`'+n+'`' for n in self.names])
reverse_string = ''
if 'reverse' in self.options and self.options['reverse'] != '':
reverse_string = ':ghc-flag:`' + self.options['reverse'] + '`'
reverse = self.options.get('reverse')
if reverse is not None and reverse != '':
reverse_string = ':ghc-flag:`' + reverse + '`'
self.names += [reverse]
self.register_flag(
self.names,
......@@ -223,6 +225,17 @@ class Flag(GenericFlag):
self.options['type'],
reverse_string)
# Add additional targets
def add_target_and_index(self, name, sig, signode):
GenericFlag.add_target_and_index(self, name, sig, signode)
reverse = self.options.get('reverse')
if reverse is not None and reverse != '':
# Make this also addressable via the reverse flag
self.env.domaindata['std']['objects']['ghc-flag', reverse] = \
self.env.docname, 'ghc-flag-%s' % name
# This class inherits from Sphinx's internal GenericObject, which drives
# the add_object_type() utility function. We want to keep that tooling,
# but need to override some of the functionality.
......
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