"""This script automates the generation of the QMK API data.
"""This script automates the generation of the QMK API data.
"""
"""
frompathlibimportPath
frompathlibimportPath
from shutilimportcopyfile
import shutil
importjson
importjson
frommilcimportcli
frommilcimportcli
@ -12,28 +12,42 @@ from qmk.json_encoders import InfoJSONEncoder
fromqmk.json_schemaimportjson_load
fromqmk.json_schemaimportjson_load
fromqmk.keyboardimportfind_readme,list_keyboards
fromqmk.keyboardimportfind_readme,list_keyboards
TEMPLATE_PATH=Path('data/templates/api/')
BUILD_API_PATH=Path('.build/api_data/')
@cli.argument('-n','--dry-run',arg_only=True,action='store_true',help="Don't write the data to disk.")
@cli.argument('-n','--dry-run',arg_only=True,action='store_true',help="Don't write the data to disk.")
@cli.argument('-f','--filter',arg_only=True,action='append',default=[],help="Filter the list of keyboards based on partial name matches the supplied value. May be passed multiple times.")
@cli.subcommand('Creates a new keymap for the keyboard of your choosing',hidden=Falseifcli.config.user.developerelseTrue)
@cli.subcommand('Creates a new keymap for the keyboard of your choosing',hidden=Falseifcli.config.user.developerelseTrue)
defgenerate_api(cli):
defgenerate_api(cli):
"""Generates the QMK API data.
"""Generates the QMK API data.
"""
"""
api_data_dir=Path('api_data')
ifBUILD_API_PATH.exists():
v1_dir=api_data_dir/'v1'
shutil.rmtree(BUILD_API_PATH)
shutil.copytree(TEMPLATE_PATH,BUILD_API_PATH)
v1_dir=BUILD_API_PATH/'v1'
keyboard_all_file=v1_dir/'keyboards.json'# A massive JSON containing everything
keyboard_all_file=v1_dir/'keyboards.json'# A massive JSON containing everything
keyboard_list_file=v1_dir/'keyboard_list.json'# A simple list of keyboard targets
keyboard_list_file=v1_dir/'keyboard_list.json'# A simple list of keyboard targets
keyboard_aliases_file=v1_dir/'keyboard_aliases.json'# A list of historical keyboard names and their new name
keyboard_aliases_file=v1_dir/'keyboard_aliases.json'# A list of historical keyboard names and their new name
keyboard_metadata_file=v1_dir/'keyboard_metadata.json'# All the data configurator/via needs for initialization
keyboard_metadata_file=v1_dir/'keyboard_metadata.json'# All the data configurator/via needs for initialization
usb_file=v1_dir/'usb.json'# A mapping of USB VID/PID -> keyboard target
usb_file=v1_dir/'usb.json'# A mapping of USB VID/PID -> keyboard target