Promote params_to_table function to NFDocs class

Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com>
This commit is contained in:
Thomas A. Christensen II 2022-01-10 17:54:42 -06:00
parent d4b3fdc354
commit c498ec82da
Signed by: millironx
GPG key ID: 139C07724802BC5D

View file

@ -26,7 +26,16 @@ def definition_type(signature):
# Return the results # Return the results
return def_name, def_type return def_name, def_type
def params_to_table(type, params): class NFDocs(Directive):
# Class default overrides
required_arguments = 1
# Declare the docstring starting characters
DOC_STARTER = "/// "
pe = inflect.engine()
def params_to_table(self, type, params):
# Create a table # Create a table
params_table = nodes.table() params_table = nodes.table()
if type: if type:
@ -60,7 +69,7 @@ def params_to_table(type, params):
# Params table # Params table
sub_params_entry = nodes.entry() sub_params_entry = nodes.entry()
sub_params_entry += params_to_table("", param["tuple"]) sub_params_entry += self.params_to_table("", param["tuple"])
param_row += sub_params_entry param_row += sub_params_entry
# If this is actually a parameter, the new row takes on the form # If this is actually a parameter, the new row takes on the form
@ -96,15 +105,6 @@ def params_to_table(type, params):
params_table += params_tgroup params_table += params_tgroup
return params_table return params_table
class NFDocs(Directive):
# Class default overrides
required_arguments = 1
# Declare the docstring starting characters
DOC_STARTER = "/// "
pe = inflect.engine()
def run(self): def run(self):
# Take path as single argument for now # Take path as single argument for now
nextflow_path = self.arguments[0] nextflow_path = self.arguments[0]
@ -172,7 +172,7 @@ class NFDocs(Directive):
io_methods = ["input", "output"] io_methods = ["input", "output"]
for met in io_methods: for met in io_methods:
if met in proc_docs.keys(): if met in proc_docs.keys():
io_table = params_to_table(met, proc_docs[met]) io_table = self.params_to_table(met, proc_docs[met])
proc_section += io_table proc_section += io_table
self.state_machine.document.note_implicit_target(proc_section) self.state_machine.document.note_implicit_target(proc_section)
block_section += proc_section block_section += proc_section