From 157105379ec779e61961114a98fdd93e57b1269d Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Wed, 5 Jan 2022 14:09:31 -0600 Subject: [PATCH] Add docstring parsing per process Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- nfdocs-parser.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/nfdocs-parser.py b/nfdocs-parser.py index 9688657..645eff7 100755 --- a/nfdocs-parser.py +++ b/nfdocs-parser.py @@ -1,5 +1,6 @@ #!/usr/bin/env python import sys +import yaml # Declare the docstring starting characters DOC_STARTER = "/// " @@ -55,6 +56,23 @@ with open(nextflow_path) as nextflow_file: # Add this docstring position to the array 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 - print(docstring_positions) - print(definition_type(nextflow_lines[docstring_positions[0][-1]+2])) + print(process_docstrings)