Add docstring parsing per process

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 14:09:31 -06:00
parent dbc70e0d4d
commit 157105379e
Signed by: millironx
GPG key ID: 139C07724802BC5D

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys import sys
import yaml
# Declare the docstring starting characters # Declare the docstring starting characters
DOC_STARTER = "/// " DOC_STARTER = "/// "
@ -55,6 +56,23 @@ with open(nextflow_path) as nextflow_file:
# Add this docstring position to the array # Add this docstring position to the array
docstring_positions.append(range(doc_start, doc_end)) docstring_positions.append(range(doc_start, doc_end))
# Create dictionaries for each of the block types
workflow_docstrings = dict()
process_docstrings = dict()
function_docstrings = dict()
# Parse out the docstrings and put them in the appropriate dictionary
for pos in docstring_positions:
proc_name, proc_type = definition_type(nextflow_lines[pos[-1]+2])
doc_yaml = ""
for i in pos:
doc_yaml = doc_yaml + nextflow_lines[i].replace(DOC_STARTER, "")
if proc_type == "process":
process_docstrings[proc_name] = yaml.load(doc_yaml)
elif proc_type == "function":
function_docstrings[proc_name] = yaml.load(doc_yaml)
elif proc_type == "workflow":
workflow_docstrings[proc_name] = yaml.load(doc_yaml)
# Display the results so far # Display the results so far
print(docstring_positions) print(process_docstrings)
print(definition_type(nextflow_lines[docstring_positions[0][-1]+2]))