aboutsummaryrefslogtreecommitdiff
path: root/doc/tools
diff options
context:
space:
mode:
authorThéo Zimmermann2018-08-01 10:58:18 +0200
committerThéo Zimmermann2018-08-01 10:58:18 +0200
commit2dcb340f82c3df70d8fe2c6acc3536913a86144a (patch)
tree86e627cb4c13ec2b1533c557224495ed1d15908e /doc/tools
parent29a432dfbaa83dd1459c7af95f556555da15a1ce (diff)
parent7f1ed3298c841c2afa4faf080a5f65361bbb413f (diff)
Merge PR #8191: [sphinx] Use arguments of '.. example::' directive as a title
Diffstat (limited to 'doc/tools')
-rw-r--r--doc/tools/coqrst/coqdomain.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/doc/tools/coqrst/coqdomain.py b/doc/tools/coqrst/coqdomain.py
index c9487abf03..e6b71a8293 100644
--- a/doc/tools/coqrst/coqdomain.py
+++ b/doc/tools/coqrst/coqdomain.py
@@ -571,6 +571,9 @@ class ExampleDirective(BaseAdmonition):
http://docutils.sourceforge.net/docs/ref/rst/directives.html#generic-admonition
for more details.
+ Optionally, any text immediately following the ``.. example::`` header is
+ used as the example's title.
+
Example::
.. example:: Adding a hint to a database
@@ -583,13 +586,14 @@ class ExampleDirective(BaseAdmonition):
"""
node_class = nodes.admonition
directive_name = "example"
+ optional_arguments = 1
def run(self):
# ‘BaseAdmonition’ checks whether ‘node_class’ is ‘nodes.admonition’,
# and uses arguments[0] as the title in that case (in other cases, the
# title is unset, and it is instead set in the HTML visitor).
- assert not self.arguments # Arguments have been parsed as content
- self.arguments = ['Example']
+ assert len(self.arguments) <= 1
+ self.arguments = [": ".join(['Example'] + self.arguments)]
self.options['classes'] = ['admonition', 'note']
return super().run()