Add definition_type function to parse out function names and types

Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com>
This commit is contained in:
Thomas A. Christensen II 2022-01-05 13:52:14 -06:00
parent d727de5715
commit dbc70e0d4d
Signed by: millironx
GPG key ID: 139C07724802BC5D

View file

@ -4,6 +4,26 @@ import sys
# Declare the docstring starting characters # Declare the docstring starting characters
DOC_STARTER = "/// " DOC_STARTER = "/// "
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
# Take path as single argument for now # Take path as single argument for now
nextflow_path = sys.argv[1] nextflow_path = sys.argv[1]
with open(nextflow_path) as nextflow_file: with open(nextflow_path) as nextflow_file:
@ -37,3 +57,4 @@ with open(nextflow_path) as nextflow_file:
# Display the results so far # Display the results so far
print(docstring_positions) print(docstring_positions)
print(definition_type(nextflow_lines[docstring_positions[0][-1]+2]))