From de5f4d356679db170f823d806c81b2b1f3b2ef18 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 6 Aug 2022 16:24:56 -0400 Subject: [PATCH] Default to document basename in dfhack-tool directive --- docs/plugins/3dveins.rst | 2 +- docs/sphinx_extensions/dfhack/tool_docs.py | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/plugins/3dveins.rst b/docs/plugins/3dveins.rst index 7ae2324eb..f1149eb98 100644 --- a/docs/plugins/3dveins.rst +++ b/docs/plugins/3dveins.rst @@ -1,7 +1,7 @@ 3dveins ======= -.. dfhack-tool:: 3dveins +.. dfhack-tool:: :tags: fort, mod, map :dfhack-keybind:`3dveins` diff --git a/docs/sphinx_extensions/dfhack/tool_docs.py b/docs/sphinx_extensions/dfhack/tool_docs.py index 79516e0d8..fd6ed0946 100644 --- a/docs/sphinx_extensions/dfhack/tool_docs.py +++ b/docs/sphinx_extensions/dfhack/tool_docs.py @@ -12,13 +12,16 @@ import dfhack.util class DFHackToolDirective(sphinx.directives.ObjectDescription): has_content = False - required_arguments = 1 + required_arguments = 0 option_spec = { 'tags': dfhack.util.directive_arg_str_list, } def run(self): - tool_name = self.get_signatures()[0] + if self.arguments: + tool_name = self.arguments[0] + else: + tool_name = self.env.docname.split('/')[-1] tag_nodes = [nodes.strong(text='Tags: ')] for tag in self.options.get('tags', []): @@ -33,11 +36,6 @@ class DFHackToolDirective(sphinx.directives.ObjectDescription): nodes.paragraph('', '', *tag_nodes), ] - # simpler but always renders as "inline code" (and less customizable) - # def handle_signature(self, sig, signode): - # signode += addnodes.desc_name(text=sig) - # return sig - def register(app): app.add_directive('dfhack-tool', DFHackToolDirective)