mirror of
https://github.com/MillironX/nfdocs-parser.git
synced 2024-11-24 09:49:56 +00:00
Add docstring parsing per process
Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com>
This commit is contained in:
parent
dbc70e0d4d
commit
157105379e
1 changed files with 20 additions and 2 deletions
|
@ -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]))
|
|
||||||
|
|
Loading…
Reference in a new issue