From c8d642002b1199e24758a76e5b3c4c39d87d7018 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Mon, 10 Jan 2022 17:38:32 -0600 Subject: [PATCH] Add check for zero docs of that type Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- nfdocs-parser.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/nfdocs-parser.py b/nfdocs-parser.py index 12d7e9d..e0acbe6 100755 --- a/nfdocs-parser.py +++ b/nfdocs-parser.py @@ -159,22 +159,23 @@ class NFDocs(Directive): # Try to convert each definition to a node for block_type, block_docs in docstrings.items(): - block_section = nodes.section() - block_section += nodes.title(text=block_type.capitalize()) - for proc_name, proc_docs in block_docs.items(): - proc_section = nodes.section() - proc_section += nodes.title(text=proc_name) - proc_section += nodes.paragraph(text=proc_docs["summary"]) - io_methods = ["input", "output"] - for met in io_methods: - if met in proc_docs.keys(): - io_table = params_to_table(met, proc_docs[met]) - proc_section += io_table - self.state_machine.document.note_implicit_target(proc_section) - block_section += proc_section + if len(block_docs) > 0: + block_section = nodes.section() + block_section += nodes.title(text=block_type.capitalize()) + for proc_name, proc_docs in block_docs.items(): + proc_section = nodes.section() + proc_section += nodes.title(text=proc_name) + proc_section += nodes.paragraph(text=proc_docs["summary"]) + io_methods = ["input", "output"] + for met in io_methods: + if met in proc_docs.keys(): + io_table = params_to_table(met, proc_docs[met]) + proc_section += io_table + self.state_machine.document.note_implicit_target(proc_section) + block_section += proc_section - self.state_machine.document.note_implicit_target(block_section) - return_nodes.append(block_section) + self.state_machine.document.note_implicit_target(block_section) + return_nodes.append(block_section) return return_nodes