mirror of
https://github.com/MillironX/nfdocs-parser.git
synced 2024-11-22 00:56:04 +00:00
Refactor to parse multiple files from the directory
Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com>
This commit is contained in:
parent
ab23cd2e17
commit
ccdb61ac27
1 changed files with 68 additions and 62 deletions
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import yaml
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import Directive
|
||||
|
@ -53,7 +54,22 @@ class NFDocs(Directive):
|
|||
def run(self):
|
||||
# Take path as single argument for now
|
||||
nextflow_path = self.arguments[0]
|
||||
with open(nextflow_path) as nextflow_file:
|
||||
print(nextflow_path)
|
||||
|
||||
# Create dictionaries for each of the block types
|
||||
docstrings = {
|
||||
"process": {},
|
||||
"workflow": {},
|
||||
"function": {}
|
||||
}
|
||||
|
||||
# Create any array to return from the plugin
|
||||
return_nodes = []
|
||||
|
||||
for root, dirs, files in os.walk(nextflow_path):
|
||||
for f in files:
|
||||
if f.endswith(".nf"):
|
||||
with open(os.path.join(root,f)) as nextflow_file:
|
||||
|
||||
# Split by lines
|
||||
nextflow_lines = nextflow_file.readlines()
|
||||
|
@ -82,13 +98,6 @@ class NFDocs(Directive):
|
|||
# Add this docstring position to the array
|
||||
docstring_positions.append(range(doc_start, doc_end+1))
|
||||
|
||||
# Create dictionaries for each of the block types
|
||||
docstrings = {
|
||||
"process": {},
|
||||
"workflow": {},
|
||||
"function": {}
|
||||
}
|
||||
|
||||
# Parse out the docstrings and put them in the appropriate dictionary
|
||||
for pos in docstring_positions:
|
||||
proc_name, proc_type = self.definition_type(nextflow_lines[pos[-1]+1])
|
||||
|
@ -97,9 +106,6 @@ class NFDocs(Directive):
|
|||
doc_yaml = doc_yaml + nextflow_lines[i].replace(self.DOC_STARTER, "")
|
||||
docstrings[proc_type][proc_name] = yaml.safe_load(doc_yaml)
|
||||
|
||||
# Create any array to return from the plugin
|
||||
return_nodes = []
|
||||
|
||||
# Try to convert each definition to a node
|
||||
for block_type, block_docs in docstrings.items():
|
||||
block_section = nodes.section()
|
||||
|
|
Loading…
Reference in a new issue