1
0
Fork 0

Generate api data on each push (#10609)

* add new qmk generate-api command, to generate a complete set of API data.

* Generate api data and push it to the keyboard repo

* fix typo

* Apply suggestions from code review

Co-authored-by: Joel Challis <git@zvecr.com>

* fixup api workflow

* remove file-changes-action

* use a more mainstream github action

* fix yaml error

* Apply suggestions from code review

Co-authored-by: Erovia <Erovia@users.noreply.github.com>

* more uniform date handling

* make flake8 happy

* Update lib/python/qmk/decorators.py

Co-authored-by: Erovia <Erovia@users.noreply.github.com>

Co-authored-by: Joel Challis <git@zvecr.com>
Co-authored-by: Erovia <Erovia@users.noreply.github.com>
This commit is contained in:
Zach White 2020-10-25 14:48:44 -07:00 committed by GitHub
parent 8ef82c466e
commit 0c42f91f4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 399 additions and 127 deletions

View file

@ -16,7 +16,7 @@ ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop'
COL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijilmnopqrstuvwxyz'
def show_keymap(info_json, title_caps=True):
def show_keymap(kb_info_json, title_caps=True):
"""Render the keymap in ascii art.
"""
keymap_path = locate_keymap(cli.config.info.keyboard, cli.config.info.keymap)
@ -36,7 +36,7 @@ def show_keymap(info_json, title_caps=True):
else:
cli.echo('{fg_cyan}layer_%s{fg_reset}:', layer_num)
print(render_layout(info_json['layouts'][layout_name]['layout'], layer))
print(render_layout(kb_info_json['layouts'][layout_name]['layout'], layer))
def show_layouts(kb_info_json, title_caps=True):
@ -48,10 +48,10 @@ def show_layouts(kb_info_json, title_caps=True):
print(layout_art) # Avoid passing dirty data to cli.echo()
def show_matrix(info_json, title_caps=True):
def show_matrix(kb_info_json, title_caps=True):
"""Render the layout with matrix labels in ascii art.
"""
for layout_name, layout in info_json['layouts'].items():
for layout_name, layout in kb_info_json['layouts'].items():
# Build our label list
labels = []
for key in layout['layout']:
@ -69,54 +69,54 @@ def show_matrix(info_json, title_caps=True):
else:
cli.echo('{fg_blue}matrix_%s{fg_reset}:', layout_name)
print(render_layout(info_json['layouts'][layout_name]['layout'], labels))
print(render_layout(kb_info_json['layouts'][layout_name]['layout'], labels))
def print_friendly_output(info_json):
def print_friendly_output(kb_info_json):
"""Print the info.json in a friendly text format.
"""
cli.echo('{fg_blue}Keyboard Name{fg_reset}: %s', info_json.get('keyboard_name', 'Unknown'))
cli.echo('{fg_blue}Manufacturer{fg_reset}: %s', info_json.get('manufacturer', 'Unknown'))
if 'url' in info_json:
cli.echo('{fg_blue}Website{fg_reset}: %s', info_json.get('url', ''))
if info_json.get('maintainer', 'qmk') == 'qmk':
cli.echo('{fg_blue}Keyboard Name{fg_reset}: %s', kb_info_json.get('keyboard_name', 'Unknown'))
cli.echo('{fg_blue}Manufacturer{fg_reset}: %s', kb_info_json.get('manufacturer', 'Unknown'))
if 'url' in kb_info_json:
cli.echo('{fg_blue}Website{fg_reset}: %s', kb_info_json.get('url', ''))
if kb_info_json.get('maintainer', 'qmk') == 'qmk':
cli.echo('{fg_blue}Maintainer{fg_reset}: QMK Community')
else:
cli.echo('{fg_blue}Maintainer{fg_reset}: %s', info_json['maintainer'])
cli.echo('{fg_blue}Keyboard Folder{fg_reset}: %s', info_json.get('keyboard_folder', 'Unknown'))
cli.echo('{fg_blue}Layouts{fg_reset}: %s', ', '.join(sorted(info_json['layouts'].keys())))
if 'width' in info_json and 'height' in info_json:
cli.echo('{fg_blue}Size{fg_reset}: %s x %s' % (info_json['width'], info_json['height']))
cli.echo('{fg_blue}Processor{fg_reset}: %s', info_json.get('processor', 'Unknown'))
cli.echo('{fg_blue}Bootloader{fg_reset}: %s', info_json.get('bootloader', 'Unknown'))
cli.echo('{fg_blue}Maintainer{fg_reset}: %s', kb_info_json['maintainer'])
cli.echo('{fg_blue}Keyboard Folder{fg_reset}: %s', kb_info_json.get('keyboard_folder', 'Unknown'))
cli.echo('{fg_blue}Layouts{fg_reset}: %s', ', '.join(sorted(kb_info_json['layouts'].keys())))
if 'width' in kb_info_json and 'height' in kb_info_json:
cli.echo('{fg_blue}Size{fg_reset}: %s x %s' % (kb_info_json['width'], kb_info_json['height']))
cli.echo('{fg_blue}Processor{fg_reset}: %s', kb_info_json.get('processor', 'Unknown'))
cli.echo('{fg_blue}Bootloader{fg_reset}: %s', kb_info_json.get('bootloader', 'Unknown'))
if cli.config.info.layouts:
show_layouts(info_json, True)
show_layouts(kb_info_json, True)
if cli.config.info.matrix:
show_matrix(info_json, True)
show_matrix(kb_info_json, True)
if cli.config_source.info.keymap and cli.config_source.info.keymap != 'config_file':
show_keymap(info_json, True)
show_keymap(kb_info_json, True)
def print_text_output(info_json):
def print_text_output(kb_info_json):
"""Print the info.json in a plain text format.
"""
for key in sorted(info_json):
for key in sorted(kb_info_json):
if key == 'layouts':
cli.echo('{fg_blue}layouts{fg_reset}: %s', ', '.join(sorted(info_json['layouts'].keys())))
cli.echo('{fg_blue}layouts{fg_reset}: %s', ', '.join(sorted(kb_info_json['layouts'].keys())))
else:
cli.echo('{fg_blue}%s{fg_reset}: %s', key, info_json[key])
cli.echo('{fg_blue}%s{fg_reset}: %s', key, kb_info_json[key])
if cli.config.info.layouts:
show_layouts(info_json, False)
show_layouts(kb_info_json, False)
if cli.config.info.matrix:
show_matrix(info_json, False)
show_matrix(kb_info_json, False)
if cli.config_source.info.keymap and cli.config_source.info.keymap != 'config_file':
show_keymap(info_json, False)
show_keymap(kb_info_json, False)
@cli.argument('-kb', '--keyboard', help='Keyboard to show info for.')