|
|
@ -125,8 +125,12 @@ class DFHackToolDirectiveBase(sphinx.directives.ObjectDescription):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return parts[-1]
|
|
|
|
return parts[-1]
|
|
|
|
|
|
|
|
|
|
|
|
def add_index_entry(self, name, tag) -> None:
|
|
|
|
def add_index_entries(self, name) -> None:
|
|
|
|
indexdata = (name, self.options.get('summary', ''), '', self.env.docname, '', 0)
|
|
|
|
docname = self.env.docname
|
|
|
|
|
|
|
|
tags = self.env.domaindata['tag-repo']['doctags'][docname]
|
|
|
|
|
|
|
|
indexdata = (name, self.options.get('summary', ''), '', docname, '', 0)
|
|
|
|
|
|
|
|
self.env.domaindata['all']['objects'].append(indexdata)
|
|
|
|
|
|
|
|
for tag in tags:
|
|
|
|
self.env.domaindata[tag]['objects'].append(indexdata)
|
|
|
|
self.env.domaindata[tag]['objects'].append(indexdata)
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
@staticmethod
|
|
|
@ -154,7 +158,9 @@ class DFHackToolDirective(DFHackToolDirectiveBase):
|
|
|
|
|
|
|
|
|
|
|
|
def render_content(self) -> List[nodes.Node]:
|
|
|
|
def render_content(self) -> List[nodes.Node]:
|
|
|
|
tag_paragraph = self.make_labeled_paragraph('Tags')
|
|
|
|
tag_paragraph = self.make_labeled_paragraph('Tags')
|
|
|
|
for tag in self.options.get('tags', []):
|
|
|
|
tags = self.options.get('tags', [])
|
|
|
|
|
|
|
|
self.env.domaindata['tag-repo']['doctags'][self.env.docname] = tags
|
|
|
|
|
|
|
|
for tag in tags:
|
|
|
|
tag_paragraph += [
|
|
|
|
tag_paragraph += [
|
|
|
|
addnodes.pending_xref(tag, nodes.inline(text=tag), **{
|
|
|
|
addnodes.pending_xref(tag, nodes.inline(text=tag), **{
|
|
|
|
'reftype': 'ref',
|
|
|
|
'reftype': 'ref',
|
|
|
@ -165,12 +171,11 @@ class DFHackToolDirective(DFHackToolDirectiveBase):
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
nodes.inline(text=' | '),
|
|
|
|
nodes.inline(text=' | '),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
self.add_index_entry(self.get_name_or_docname(), tag)
|
|
|
|
|
|
|
|
tag_paragraph.pop()
|
|
|
|
tag_paragraph.pop()
|
|
|
|
|
|
|
|
|
|
|
|
ret_nodes = [tag_paragraph]
|
|
|
|
ret_nodes = [tag_paragraph]
|
|
|
|
if 'no-command' in self.options:
|
|
|
|
if 'no-command' in self.options:
|
|
|
|
self.add_index_entry(self.get_name_or_docname() + ' (plugin)', 'all')
|
|
|
|
self.add_index_entries(self.get_name_or_docname() + ' (plugin)')
|
|
|
|
ret_nodes += [make_summary(self.env.app.builder, self.options.get('summary', ''))]
|
|
|
|
ret_nodes += [make_summary(self.env.app.builder, self.options.get('summary', ''))]
|
|
|
|
return ret_nodes
|
|
|
|
return ret_nodes
|
|
|
|
|
|
|
|
|
|
|
@ -188,7 +193,7 @@ class DFHackCommandDirective(DFHackToolDirectiveBase):
|
|
|
|
|
|
|
|
|
|
|
|
def render_content(self) -> List[nodes.Node]:
|
|
|
|
def render_content(self) -> List[nodes.Node]:
|
|
|
|
command = self.get_name_or_docname()
|
|
|
|
command = self.get_name_or_docname()
|
|
|
|
self.add_index_entry(command, 'all')
|
|
|
|
self.add_index_entries(command)
|
|
|
|
return [
|
|
|
|
return [
|
|
|
|
self.make_labeled_paragraph('Command', command, content_class=nodes.literal),
|
|
|
|
self.make_labeled_paragraph('Command', command, content_class=nodes.literal),
|
|
|
|
make_summary(self.env.app.builder, self.options.get('summary', '')),
|
|
|
|
make_summary(self.env.app.builder, self.options.get('summary', '')),
|
|
|
@ -196,6 +201,15 @@ class DFHackCommandDirective(DFHackToolDirectiveBase):
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TagRepoDomain(Domain):
|
|
|
|
|
|
|
|
name = 'tag-repo'
|
|
|
|
|
|
|
|
label = 'Holds tag associations per document'
|
|
|
|
|
|
|
|
initial_data = {'doctags': {}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def merge_domaindata(self, docnames: List[str], otherdata: Dict) -> None:
|
|
|
|
|
|
|
|
self.data['doctags'].update(otherdata['doctags'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_tags():
|
|
|
|
def get_tags():
|
|
|
|
groups = {}
|
|
|
|
groups = {}
|
|
|
|
group_re = re.compile(r'"([^"]+)"')
|
|
|
|
group_re = re.compile(r'"([^"]+)"')
|
|
|
@ -277,6 +291,7 @@ def register(app):
|
|
|
|
def setup(app):
|
|
|
|
def setup(app):
|
|
|
|
app.connect('builder-inited', register)
|
|
|
|
app.connect('builder-inited', register)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.add_domain(TagRepoDomain)
|
|
|
|
register_index(app, 'all', 'Index of DFHack tools')
|
|
|
|
register_index(app, 'all', 'Index of DFHack tools')
|
|
|
|
init_tag_indices(app)
|
|
|
|
init_tag_indices(app)
|
|
|
|
|
|
|
|
|
|
|
|