add a bit more index infrastructure

develop
myk002 2022-09-23 08:10:37 -07:00
parent 278b7528ac
commit a1d3fe77b5
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 19 additions and 8 deletions

@ -6,7 +6,7 @@
import logging import logging
import os import os
import re import re
from typing import Iterable, List, Optional, Tuple, Type from typing import Dict, Iterable, List, Optional, Tuple, Type
import docutils.nodes as nodes import docutils.nodes as nodes
from docutils.nodes import Node from docutils.nodes import Node
@ -167,10 +167,12 @@ class DFHackToolDirective(DFHackToolDirectiveBase):
'reftype': 'ref', 'reftype': 'ref',
'refdomain': 'std', 'refdomain': 'std',
'reftarget': tag + '-tag-index', 'reftarget': tag + '-tag-index',
'refexplicit': False, 'refexplicit': True,
'refwarn': True, 'refwarn': True,
}), }),
nodes.inline(text=' | '), nodes.inline(text=' | '),
indexdata = (self.env.docname)
self.env.domaindata[tag]['objects'].append(indexdata)
] ]
tag_paragraph.pop() tag_paragraph.pop()
@ -224,8 +226,15 @@ def get_tags():
return groups return groups
def generate_tag_index(self, docnames: Optional[Iterable[str]] = None) -> Tuple[List[Tuple[str, List[IndexEntry]]], bool]: def tag_domain_get_objects(self):
return [('A', [['name', 0, '', '', '', '', '']])], False for obj in self.data['objects']:
yield(obj)
def tag_domain_merge_domaindata(self, docnames: List[str], otherdata: Dict) -> None:
self.data['objects'].extend(otherdata['objects'])
def tag_index_generate(self, docnames: Optional[Iterable[str]] = None) -> Tuple[List[Tuple[str, List[IndexEntry]]], bool]:
return [('G', [['gui/blueprint', 0, 'docs/tools/gui/blueprint', 'gui-blueprint', '', '', '']])], False
def init_tag_indices(app): def init_tag_indices(app):
@ -241,13 +250,16 @@ def init_tag_indices(app):
domain_class = type(tag+'Domain', (Domain, ), { domain_class = type(tag+'Domain', (Domain, ), {
'name': tag, 'name': tag,
'label': 'Container domain for tag: ' + tag, 'label': 'Container domain for tag: ' + tag,
'initial_data': {'objects': []},
'merge_domaindata': tag_domain_merge_domaindata,
'get_objects': tag_domain_get_objects,
}) })
index_class = type(tag+'Index', (Index, ), { index_class = type(tag+'Index', (Index, ), {
'name': 'tag-index', 'name': 'tag-index',
'localname': tag + ' tag index', 'localname': tag + ' tag index',
'shortname': tag, 'shortname': tag,
'desc': desc, 'desc': desc,
'generate': generate_tag_index, 'generate': tag_index_generate,
}) })
app.add_domain(domain_class) app.add_domain(domain_class)
app.add_index_to_domain(tag, index_class) app.add_index_to_domain(tag, index_class)
@ -268,9 +280,8 @@ def setup(app):
# TODO: re-enable once detection is corrected # TODO: re-enable once detection is corrected
# app.connect('build-finished', lambda *_: check_missing_keybinds()) # app.connect('build-finished', lambda *_: check_missing_keybinds())
# TODO: implement parallel builds so we can set these back to True
return { return {
'version': '0.1', 'version': '0.1',
'parallel_read_safe': False, 'parallel_read_safe': True,
'parallel_write_safe': False, 'parallel_write_safe': True,
} }