From 98b6ad4954ef2b51782488b5744020d449185c50 Mon Sep 17 00:00:00 2001 From: myk002 Date: Fri, 23 Sep 2022 12:34:50 -0700 Subject: [PATCH] fix index titles on pdf --- docs/Tags.rst | 54 +++++++++++----------- docs/sphinx_extensions/dfhack/tool_docs.py | 16 +++++-- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/docs/Tags.rst b/docs/Tags.rst index 14a12f411..45bfeb9b3 100644 --- a/docs/Tags.rst +++ b/docs/Tags.rst @@ -13,36 +13,36 @@ for the tag assignment spreadsheet. "when" tags ----------- -- `adventure-tag-index`: Tools that are useful while in adventure mode. Note that some tools only tagged with "fort" might also work in adventure mode, but not always in expected ways. Feel free to experiment, though! -- `dfhack-tag-index`: Tools that you use to run DFHack commands or interact with the DFHack library. This tag also includes tools that help you manage the DF game itself (e.g. settings, saving, etc.) -- `embark-tag-index`: Tools that are useful while on the fort embark screen or while creating an adventurer. -- `fort-tag-index`: Tools that are useful while in fort mode. -- `legends-tag-index`: Tools that are useful while in legends mode. +- `adventure `: Tools that are useful while in adventure mode. Note that some tools only tagged with "fort" might also work in adventure mode, but not always in expected ways. Feel free to experiment, though! +- `dfhack `: Tools that you use to run DFHack commands or interact with the DFHack library. This tag also includes tools that help you manage the DF game itself (e.g. settings, saving, etc.) +- `embark `: Tools that are useful while on the fort embark screen or while creating an adventurer. +- `fort `: Tools that are useful while in fort mode. +- `legends `: Tools that are useful while in legends mode. "why" tags ---------- -- `armok-tag-index`: Tools that give you complete control over an aspect of the game or provide access to information that the game intentionally keeps hidden. -- `auto-tag-index`: Tools that run in the background and automatically manage routine, toilsome aspects of your fortress. -- `bugfix-tag-index`: Tools that fix specific bugs, either permanently or on-demand. -- `design-tag-index`: Tools that help you design your fort. -- `dev-tag-index`: Tools that are useful when developing scripts or mods. -- `fps-tag-index`: Tools that help you manage FPS drop. -- `gameplay-tag-index`: Tools that introduce new gameplay elements. -- `inspection-tag-index`: Tools that let you view information that is otherwise difficult to find. -- `productivity-tag-index`: Tools that help you do things that you could do manually, but using the tool is better and faster. +- `armok `: Tools that give you complete control over an aspect of the game or provide access to information that the game intentionally keeps hidden. +- `auto `: Tools that run in the background and automatically manage routine, toilsome aspects of your fortress. +- `bugfix `: Tools that fix specific bugs, either permanently or on-demand. +- `design `: Tools that help you design your fort. +- `dev `: Tools that are useful when developing scripts or mods. +- `fps `: Tools that help you manage FPS drop. +- `gameplay `: Tools that introduce new gameplay elements. +- `inspection `: Tools that let you view information that is otherwise difficult to find. +- `productivity `: Tools that help you do things that you could do manually, but using the tool is better and faster. "what" tags ----------- -- `animals-tag-index`: Tools that interact with animals. -- `buildings-tag-index`: Tools that interact with buildings and furniture. -- `graphics-tag-index`: Tools that interact with game graphics. -- `interface-tag-index`: Tools that interact with or extend the DF user interface. -- `items-tag-index`: Tools that interact with in-game items. -- `jobs-tag-index`: Tools that interact with jobs. -- `labors-tag-index`: Tools that deal with labor assignment. -- `map-tag-index`: Tools that interact with the game map. -- `military-tag-index`: Tools that interact with the military. -- `plants-tag-index`: Tools that interact with trees, shrubs, and crops. -- `stockpiles-tag-index`: Tools that interact wtih stockpiles. -- `units-tag-index`: Tools that interact with units. -- `workorders-tag-index`: Tools that interact with workorders. +- `animals `: Tools that interact with animals. +- `buildings `: Tools that interact with buildings and furniture. +- `graphics `: Tools that interact with game graphics. +- `interface `: Tools that interact with or extend the DF user interface. +- `items `: Tools that interact with in-game items. +- `jobs `: Tools that interact with jobs. +- `labors `: Tools that deal with labor assignment. +- `map `: Tools that interact with the game map. +- `military `: Tools that interact with the military. +- `plants `: Tools that interact with trees, shrubs, and crops. +- `stockpiles `: Tools that interact wtih stockpiles. +- `units `: Tools that interact with units. +- `workorders `: Tools that interact with workorders. diff --git a/docs/sphinx_extensions/dfhack/tool_docs.py b/docs/sphinx_extensions/dfhack/tool_docs.py index e7302c3cd..581cee26e 100644 --- a/docs/sphinx_extensions/dfhack/tool_docs.py +++ b/docs/sphinx_extensions/dfhack/tool_docs.py @@ -216,7 +216,7 @@ class TagRepoDomain(Domain): def get_tags(): groups = {} group_re = re.compile(r'"([^"]+)"') - tag_re = re.compile(r'- `([^`]+)-tag-index`: (.*)') + tag_re = re.compile(r'- `([^ ]+) <[^>]+>`: (.*)') with open('docs/Tags.rst') as f: lines = f.readlines() for line in lines: @@ -282,15 +282,25 @@ def init_tag_indices(app): tag, desc = tag_tuple[0], tag_tuple[1] topidx.write(('- `{name} <{name}-tag-index>`\n').format(name=tag)) topidx.write((' {desc}\n').format(desc=desc)) - register_index(app, tag, '%s

%s

' % (tag, desc)) + register_index(app, tag, desc) +def update_index_titles(app): + for domain in app.env.domains.values(): + for index in domain.indices: + if index.shortname == 'all': + continue + if app.builder.format == 'html': + index.localname = '"%s" tag index

%s

' % (index.shortname, index.localname) + else: + index.localname = '%s tag index - %s' % (index.shortname, index.localname) + def register(app): app.add_directive('dfhack-tool', DFHackToolDirective) app.add_directive('dfhack-command', DFHackCommandDirective) + update_index_titles(app) _KEYBINDS.update(scan_all_keybinds(os.path.join(dfhack.util.DFHACK_ROOT, 'data', 'init'))) - def setup(app): app.connect('builder-inited', register)