Make docstring dictionary more generic

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:22:48 -06:00
parent f880f47b3d
commit c481a04fc0
Signed by: millironx
GPG key ID: 139C07724802BC5D

View file

@ -57,9 +57,11 @@ with open(nextflow_path) as nextflow_file:
docstring_positions.append(range(doc_start, doc_end)) docstring_positions.append(range(doc_start, doc_end))
# Create dictionaries for each of the block types # Create dictionaries for each of the block types
workflow_docstrings = dict() docstrings = {
process_docstrings = dict() "process": {},
function_docstrings = dict() "workflow": {},
"function": {}
}
# 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:
@ -67,12 +69,7 @@ with open(nextflow_path) as nextflow_file:
doc_yaml = "" doc_yaml = ""
for i in pos: for i in pos:
doc_yaml = doc_yaml + nextflow_lines[i].replace(DOC_STARTER, "") doc_yaml = doc_yaml + nextflow_lines[i].replace(DOC_STARTER, "")
if proc_type == "process": docstrings[proc_type][proc_name] = yaml.safe_load(doc_yaml)
process_docstrings[proc_name] = yaml.load(doc_yaml, Loader=yaml.SafeLoader)
elif proc_type == "function":
function_docstrings[proc_name] = yaml.load(doc_yaml, Loader=yaml.SafeLoader)
elif proc_type == "workflow":
workflow_docstrings[proc_name] = yaml.load(doc_yaml, Loader=yaml.SafeLoader)
# Display the results so far # Display the results so far
print(process_docstrings) print(docstrings)