Publish data as part of API generation (#17020)

This commit is contained in:
Joel Challis 2022-08-06 07:14:29 +01:00 committed by GitHub
parent ec5186f0f9
commit 897403c4a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 19 deletions

View file

@ -7,6 +7,9 @@ on:
paths: paths:
- 'keyboards/**' - 'keyboards/**'
- 'layouts/community/**' - 'layouts/community/**'
- 'lib/python/**'
- 'data/**'
- '.github/workflows/api.yml'
workflow_dispatch: workflow_dispatch:
jobs: jobs:

View file

@ -7,6 +7,9 @@ on:
paths: paths:
- 'keyboards/**' - 'keyboards/**'
- 'layouts/community/**' - 'layouts/community/**'
- 'lib/python/**'
- 'data/**'
- '.github/workflows/develop_api.yml'
workflow_dispatch: workflow_dispatch:
jobs: jobs:

View file

@ -12,29 +12,14 @@ from qmk.json_encoders import InfoJSONEncoder
from qmk.json_schema import json_load from qmk.json_schema import json_load
from qmk.keyboard import find_readme, list_keyboards from qmk.keyboard import find_readme, list_keyboards
TEMPLATE_PATH = Path('data/templates/api/') DATA_PATH = Path('data')
TEMPLATE_PATH = DATA_PATH / 'templates/api/'
BUILD_API_PATH = Path('.build/api_data/') 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.") def _filtered_keyboard_list():
@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.") """Perform basic filtering of list_keyboards
@cli.subcommand('Creates a new keymap for the keyboard of your choosing', hidden=False if cli.config.user.developer else True)
def generate_api(cli):
"""Generates the QMK API data.
""" """
if BUILD_API_PATH.exists():
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_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_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
# Filter down when required
keyboard_list = list_keyboards() keyboard_list = list_keyboards()
if cli.args.filter: if cli.args.filter:
kb_list = [] kb_list = []
@ -42,6 +27,30 @@ def generate_api(cli):
if any(i in keyboard_name for i in cli.args.filter): if any(i in keyboard_name for i in cli.args.filter):
kb_list.append(keyboard_name) kb_list.append(keyboard_name)
keyboard_list = kb_list keyboard_list = kb_list
return keyboard_list
@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('Generate QMK API data', hidden=False if cli.config.user.developer else True)
def generate_api(cli):
"""Generates the QMK API data.
"""
v1_dir = BUILD_API_PATH / 'v1'
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_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
usb_file = v1_dir / 'usb.json' # A mapping of USB VID/PID -> keyboard target
if BUILD_API_PATH.exists():
shutil.rmtree(BUILD_API_PATH)
shutil.copytree(TEMPLATE_PATH, BUILD_API_PATH)
shutil.copytree(DATA_PATH, v1_dir)
# Filter down when required
keyboard_list = _filtered_keyboard_list()
kb_all = {} kb_all = {}
usb_list = {} usb_list = {}