From c481a04fc09b4946a8dc8dc783a73ca1039b7da8 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Wed, 5 Jan 2022 14:22:48 -0600 Subject: [PATCH] Make docstring dictionary more generic Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- nfdocs-parser.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/nfdocs-parser.py b/nfdocs-parser.py index 0f207ca..08352f3 100755 --- a/nfdocs-parser.py +++ b/nfdocs-parser.py @@ -57,9 +57,11 @@ with open(nextflow_path) as nextflow_file: 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() + docstrings = { + "process": {}, + "workflow": {}, + "function": {} + } # Parse out the docstrings and put them in the appropriate dictionary for pos in docstring_positions: @@ -67,12 +69,7 @@ with open(nextflow_path) as nextflow_file: 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, 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) + docstrings[proc_type][proc_name] = yaml.safe_load(doc_yaml) # Display the results so far - print(process_docstrings) + print(docstrings)