From f555cd9c2036defd367d3cea3d153fe797bb6584 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Mon, 10 Jan 2022 16:14:42 -0600 Subject: [PATCH] Remove function definition_type from NFDocs class Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- nfdocs-parser.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/nfdocs-parser.py b/nfdocs-parser.py index e038628..e424c0d 100755 --- a/nfdocs-parser.py +++ b/nfdocs-parser.py @@ -5,6 +5,26 @@ from docutils import nodes from docutils.parsers.rst import Directive from docutils.parsers.rst import directives +def definition_type(signature): + # Returns "name", workflow|process|function + def_type = "unknown" + if "workflow" in signature: + def_type = "workflow" + elif "process" in signature: + def_type = "process" + elif "function" in signature: + def_type = "function" + + # Check if any signature was recognized + if def_type == "unknown": + return "unknown", "an error occurred" + + # Parse out the definition name + def_name = signature.replace(def_type, "").replace("{", "").strip() + + # Return the results + return def_name, def_type + class NFDocs(Directive): # Class default overrides required_arguments = 1 @@ -12,26 +32,6 @@ class NFDocs(Directive): # Declare the docstring starting characters DOC_STARTER = "/// " - def definition_type(self, signature): - # Returns "name", workflow|process|function - def_type = "unknown" - if "workflow" in signature: - def_type = "workflow" - elif "process" in signature: - def_type = "process" - elif "function" in signature: - def_type = "function" - - # Check if any signature was recognized - if def_type == "unknown": - return "unknown", "an error occurred" - - # Parse out the definition name - def_name = signature.replace(def_type, "").replace("{", "").strip() - - # Return the results - return def_name, def_type - def params_to_list(self, params): if "tuple" in params.keys(): tuple_item = nodes.list_item() @@ -100,7 +100,7 @@ class NFDocs(Directive): # Parse out the docstrings and put them in the appropriate dictionary for pos in docstring_positions: - proc_name, proc_type = self.definition_type(nextflow_lines[pos[-1]+1]) + proc_name, proc_type = definition_type(nextflow_lines[pos[-1]+1]) doc_yaml = "" for i in pos: doc_yaml = doc_yaml + nextflow_lines[i].replace(self.DOC_STARTER, "")