From 499491f8efd3a02dacb64c779edc246510b1d35f Mon Sep 17 00:00:00 2001 From: Théo Zimmermann Date: Sat, 16 Feb 2019 16:42:52 +0100 Subject: [sphinx] Refactor handling of options for coqtop directive. Make it mandatory to give exactly one display option. --- doc/tools/coqrst/coqdomain.py | 72 ++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 28 deletions(-) (limited to 'doc/tools') diff --git a/doc/tools/coqrst/coqdomain.py b/doc/tools/coqrst/coqdomain.py index 36b842d347..8df0f2be97 100644 --- a/doc/tools/coqrst/coqdomain.py +++ b/doc/tools/coqrst/coqdomain.py @@ -570,7 +570,7 @@ class CoqtopDirective(Directive): Here is a list of permissible options: - - Display options + - Display options (choose exactly one) - ``all``: Display input and output - ``in``: Display only input @@ -589,8 +589,8 @@ class CoqtopDirective(Directive): reST source file). Use the ``reset`` option to reset Coq's state. """ has_content = True - required_arguments = 0 - optional_arguments = 1 + required_arguments = 1 + optional_arguments = 0 final_argument_whitespace = True option_spec = { 'name': directives.unchanged } directive_name = "coqtop" @@ -599,10 +599,8 @@ class CoqtopDirective(Directive): # Uses a ‘container’ instead of a ‘literal_block’ to disable # Pygments-based post-processing (we could also set rawsource to '') content = '\n'.join(self.content) - args = self.arguments[0].split() if self.arguments else ['in'] - if 'all' in args: - args.extend(['in', 'out']) - node = nodes.container(content, coqtop_options = list(set(args)), + args = self.arguments[0].split() + node = nodes.container(content, coqtop_options = set(args), classes=['coqtop', 'literal-block']) self.add_name(node) return [node] @@ -829,22 +827,41 @@ class CoqtopBlocksTransform(Transform): return re.split(r"(?<=(?