|
|
@ -3,6 +3,7 @@
|
|
|
|
# https://www.sphinx-doc.org/en/master/development/tutorials/recipe.html
|
|
|
|
# https://www.sphinx-doc.org/en/master/development/tutorials/recipe.html
|
|
|
|
# https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#rst-directives
|
|
|
|
# https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#rst-directives
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
from typing import List
|
|
|
|
from typing import List
|
|
|
|
|
|
|
|
|
|
|
@ -15,7 +16,10 @@ import sphinx.directives
|
|
|
|
import dfhack.util
|
|
|
|
import dfhack.util
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger = sphinx.util.logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
_KEYBINDS = {}
|
|
|
|
_KEYBINDS = {}
|
|
|
|
|
|
|
|
_KEYBINDS_RENDERED = set() # commands whose keybindings have been rendered
|
|
|
|
|
|
|
|
|
|
|
|
def scan_keybinds(root, files, keybindings):
|
|
|
|
def scan_keybinds(root, files, keybindings):
|
|
|
|
"""Add keybindings in the specified files to the
|
|
|
|
"""Add keybindings in the specified files to the
|
|
|
@ -45,6 +49,7 @@ def scan_all_keybinds(root_dir):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def render_dfhack_keybind(command) -> List[nodes.paragraph]:
|
|
|
|
def render_dfhack_keybind(command) -> List[nodes.paragraph]:
|
|
|
|
|
|
|
|
_KEYBINDS_RENDERED.add(command)
|
|
|
|
out = []
|
|
|
|
out = []
|
|
|
|
if command not in _KEYBINDS:
|
|
|
|
if command not in _KEYBINDS:
|
|
|
|
return out
|
|
|
|
return out
|
|
|
@ -64,6 +69,13 @@ def render_dfhack_keybind(command) -> List[nodes.paragraph]:
|
|
|
|
return out
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_missing_keybinds():
|
|
|
|
|
|
|
|
# FIXME: _KEYBINDS_RENDERED is empty in the parent process under parallel builds
|
|
|
|
|
|
|
|
# consider moving to a sphinx Domain to solve this properly
|
|
|
|
|
|
|
|
for missing_command in sorted(set(_KEYBINDS.keys()) - _KEYBINDS_RENDERED):
|
|
|
|
|
|
|
|
logger.warning('Undocumented keybindings for command: %s', missing_command)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# pylint:disable=unused-argument,dangerous-default-value,too-many-arguments
|
|
|
|
# pylint:disable=unused-argument,dangerous-default-value,too-many-arguments
|
|
|
|
def dfhack_keybind_role(role, rawtext, text, lineno, inliner,
|
|
|
|
def dfhack_keybind_role(role, rawtext, text, lineno, inliner,
|
|
|
|
options={}, content=[]):
|
|
|
|
options={}, content=[]):
|
|
|
@ -153,6 +165,9 @@ def register(app):
|
|
|
|
def setup(app):
|
|
|
|
def setup(app):
|
|
|
|
app.connect('builder-inited', register)
|
|
|
|
app.connect('builder-inited', register)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: re-enable once detection is corrected
|
|
|
|
|
|
|
|
# app.connect('build-finished', lambda *_: check_missing_keybinds())
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
'version': '0.1',
|
|
|
|
'version': '0.1',
|
|
|
|
'parallel_read_safe': True,
|
|
|
|
'parallel_read_safe': True,
|
|
|
|