mirror of
https://github.com/MillironX/nfdocs-parser.git
synced 2024-11-24 17:59:54 +00:00
Remove function definition_type from NFDocs class
Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com>
This commit is contained in:
parent
ccdb61ac27
commit
f555cd9c20
1 changed files with 21 additions and 21 deletions
|
@ -5,6 +5,26 @@ from docutils import nodes
|
||||||
from docutils.parsers.rst import Directive
|
from docutils.parsers.rst import Directive
|
||||||
from docutils.parsers.rst import directives
|
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 NFDocs(Directive):
|
||||||
# Class default overrides
|
# Class default overrides
|
||||||
required_arguments = 1
|
required_arguments = 1
|
||||||
|
@ -12,26 +32,6 @@ class NFDocs(Directive):
|
||||||
# Declare the docstring starting characters
|
# Declare the docstring starting characters
|
||||||
DOC_STARTER = "/// "
|
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):
|
def params_to_list(self, params):
|
||||||
if "tuple" in params.keys():
|
if "tuple" in params.keys():
|
||||||
tuple_item = nodes.list_item()
|
tuple_item = nodes.list_item()
|
||||||
|
@ -100,7 +100,7 @@ class NFDocs(Directive):
|
||||||
|
|
||||||
# Parse out the docstrings and put them in the appropriate dictionary
|
# Parse out the docstrings and put them in the appropriate dictionary
|
||||||
for pos in docstring_positions:
|
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 = ""
|
doc_yaml = ""
|
||||||
for i in pos:
|
for i in pos:
|
||||||
doc_yaml = doc_yaml + nextflow_lines[i].replace(self.DOC_STARTER, "")
|
doc_yaml = doc_yaml + nextflow_lines[i].replace(self.DOC_STARTER, "")
|
||||||
|
|
Loading…
Reference in a new issue