Default to document basename in dfhack-tool directive

develop
lethosor 2022-08-06 16:24:56 -04:00
parent e47c681e9c
commit de5f4d3566
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
2 changed files with 6 additions and 8 deletions

@ -1,7 +1,7 @@
3dveins
=======
.. dfhack-tool:: 3dveins
.. dfhack-tool::
:tags: fort, mod, map
:dfhack-keybind:`3dveins`

@ -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)