mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-09-29 13:30:33 +02:00
Align client/docs gen with recent changes
This commit is contained in:
@@ -8,7 +8,7 @@ from pathlib import Path
|
||||
from typing import OrderedDict
|
||||
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||||
|
||||
from qmk.constants import QMK_FIRMWARE, GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE
|
||||
import qmk.constants
|
||||
from qmk.git import git_get_version
|
||||
from qmk.json_schema import json_load, validate
|
||||
from qmk.decorators import lru_cache
|
||||
@@ -53,7 +53,7 @@ def load_lighting_spec(feature, version='latest'):
|
||||
|
||||
|
||||
def _get_jinja2_env(data_templates_xap_subdir: str):
|
||||
templates_dir = os.path.join(QMK_FIRMWARE, 'data', 'templates', 'xap', data_templates_xap_subdir)
|
||||
templates_dir = os.path.join(qmk.constants.QMK_FIRMWARE, 'data', 'templates', 'xap', data_templates_xap_subdir)
|
||||
j2 = Environment(loader=FileSystemLoader(templates_dir), autoescape=select_autoescape())
|
||||
return j2
|
||||
|
||||
@@ -65,11 +65,11 @@ def render_xap_output(data_templates_xap_subdir, file_to_render, defs=None, **kw
|
||||
|
||||
attach_filters(j2)
|
||||
|
||||
constants = {}
|
||||
specs = {}
|
||||
for feature in ['rgblight', 'rgb_matrix', 'led_matrix']:
|
||||
constants[feature] = load_lighting_spec(feature)
|
||||
specs[feature] = load_lighting_spec(feature)
|
||||
|
||||
return j2.get_template(file_to_render).render(xap=defs, qmk_version=git_get_version(), xap_str=hjson.dumps(defs), constants=constants, GPL2_HEADER_C_LIKE=GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE=GENERATED_HEADER_C_LIKE, **kwargs)
|
||||
return j2.get_template(file_to_render).render(xap=defs, qmk_version=git_get_version(), xap_str=hjson.dumps(defs), specs=specs, constants=qmk.constants, **kwargs)
|
||||
|
||||
|
||||
def _find_kb_spec(kb):
|
||||
@@ -130,7 +130,7 @@ def _merge_ordered_dicts(dicts):
|
||||
def get_xap_definition_files():
|
||||
"""Get the sorted list of XAP definition files, from <QMK>/data/xap.
|
||||
"""
|
||||
xap_defs = QMK_FIRMWARE / "data" / "xap"
|
||||
xap_defs = qmk.constants.QMK_FIRMWARE / "data" / "xap"
|
||||
return list(sorted(xap_defs.glob('**/xap_*.hjson')))
|
||||
|
||||
|
||||
|
||||
@@ -61,8 +61,13 @@ def _triplet_to_bcd(value: str):
|
||||
return f'0x{int(m.group(1)):02d}{int(m.group(2)):02d}{int(m.group(3)):04d}'
|
||||
|
||||
|
||||
def _newline_to_br(value: str):
|
||||
return value.replace('\n', '<br>')
|
||||
|
||||
|
||||
def attach_filters(j2: Environment):
|
||||
j2.filters['to_snake'] = to_snake
|
||||
j2.filters['newline_to_br'] = _newline_to_br
|
||||
j2.filters['triplet_to_bcd'] = _triplet_to_bcd
|
||||
j2.filters['fnv1a_32'] = _fnv1a_32
|
||||
j2.filters['type_to_c'] = _xap_type_to_c
|
||||
|
||||
Reference in New Issue
Block a user