From ba28bdb0cc6cec6abcac6d4854a3d7ecebc1392c Mon Sep 17 00:00:00 2001 From: Dominik Gresch Date: Tue, 12 Jun 2018 14:24:55 +0200 Subject: [PATCH] Fix sphinxext command by allowing whitespace in argument Previously, this command used a fixed number of 'optional' arguments, which contained the signature of the WorkChain split by whitespace. By allowing whitespace in the argument, it can be passed as a single argument, making the directive stable w.r.t. adding / removing arguments in the workchain __init__. --- .gitignore | 1 + aiida/sphinxext/tests/Makefile | 4 ++-- .../tests/reference_results/workchain.xml | 14 ++++++++++++-- aiida/sphinxext/workchain.py | 5 ++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 2366d42a13..1cb7db3675 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ *\,cover coverage/ .cache +.pytest_cache .coverage # Files created by RPN tests diff --git a/aiida/sphinxext/tests/Makefile b/aiida/sphinxext/tests/Makefile index d044c9266a..926a7fb24d 100644 --- a/aiida/sphinxext/tests/Makefile +++ b/aiida/sphinxext/tests/Makefile @@ -23,8 +23,8 @@ I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SOURCEDIR) all: html clean: - rm -r $(BUILDDIR) - rm -r $(HTMLBUILDDIR) + @rm -r $(BUILDDIR) || true + @rm -r $(HTMLBUILDDIR) || true html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(HTMLBUILDDIR) diff --git a/aiida/sphinxext/tests/reference_results/workchain.xml b/aiida/sphinxext/tests/reference_results/workchain.xml index 28438a25e2..862f9809c1 100644 --- a/aiida/sphinxext/tests/reference_results/workchain.xml +++ b/aiida/sphinxext/tests/reference_results/workchain.xml @@ -1,7 +1,7 @@ - - + +
sphinx-aiida demo This is a demo documentation to show off the features of the sphinx-aiida extension. @@ -32,6 +32,16 @@ This module defines an example workchain for the aiida-workchain documentation directive. + + workchaindemo_workchain.DemoWorkChain + + + A demo workchain to show how the workchain auto-documentation works. + + Inputs:description, basestring, optional, non_dblabel, basestring, optional, non_dbnsp, Namespace – A separate namespace, nsp.nsp2, Namespacestore_provenance, bool, optional, non_dbx, Float, required – First input argument.y, Namespacez, Int, required – Input in a separate namespace. + Outputs:z, Bool, required – Output of the demoworkchain. + + class demo_workchain.NormalClass diff --git a/aiida/sphinxext/workchain.py b/aiida/sphinxext/workchain.py index 20bb69c4cf..0c952394c4 100644 --- a/aiida/sphinxext/workchain.py +++ b/aiida/sphinxext/workchain.py @@ -39,9 +39,12 @@ class AiidaWorkchainDirective(Directive): Directive to auto-document AiiDA workchains. """ required_arguments = 1 + optional_arguments = 0 + final_argument_whitespace = True + HIDE_UNSTORED_INPUTS_FLAG = 'hide-nondb-inputs' - optional_arguments = 2 option_spec = {'module': directives.unchanged, HIDE_UNSTORED_INPUTS_FLAG: directives.flag} + has_content = True def run(self):