mirror of
https://github.com/MillironX/nfdocs-parser.git
synced 2024-11-25 01:59:55 +00:00
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:
parent
d727de5715
commit
dbc70e0d4d
1 changed files with 21 additions and 0 deletions
|
@ -4,6 +4,26 @@ import sys
|
|||
# Declare the docstring starting characters
|
||||
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
|
||||
nextflow_path = sys.argv[1]
|
||||
with open(nextflow_path) as nextflow_file:
|
||||
|
@ -37,3 +57,4 @@ with open(nextflow_path) as nextflow_file:
|
|||
|
||||
# Display the results so far
|
||||
print(docstring_positions)
|
||||
print(definition_type(nextflow_lines[docstring_positions[0][-1]+2]))
|
||||
|
|
Loading…
Reference in a new issue