Skip to content

Commit

Permalink
Fix more qmk generate-api fallout from userspace support
Browse files Browse the repository at this point in the history
After qmk#22222 `list_keymaps(fullpath=True)` returns absolute paths which
might point to the userspace directory tree; however, the implementation
of `qmk generate-api` expected to get paths relative to `qmk_firmware`.
The problem was partially fixed in qmk#22618 for the generated `url` value;
however, the `path` value for keymaps was still incorrect (this also
made the subsequent code overwrite the `keymap.json` files in the
working copy instead of writing those files converted to plain JSON into
the API output directory).

Fix the `path` value for keymaps to contain the keymap path relative to
`qmk_firmware` as it was before the userspace changes, and skip any
userspace keymaps which might have been found.
  • Loading branch information
sigprof committed Dec 6, 2023
1 parent f1043e3 commit 076e085
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/python/qmk/cli/generate/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,15 @@ def generate_api(cli):
# Populate the list of JSON keymaps
for keymap in list_keymaps(keyboard_name, c=False, fullpath=True):
keymap_rel = qmk.path.under_qmk_firmware(keymap)
if keymap_rel is None:
cli.log.debug('Skipping keymap %s (not in qmk_firmware)', keymap)
continue
kb_json['keymaps'][keymap.name] = {
# TODO: deprecate 'url' as consumer needs to know its potentially hjson
'url': f'https://raw.githubusercontent.com/qmk/qmk_firmware/master/{keymap_rel}/keymap.json',

# Instead consumer should grab from API and not repo directly
'path': (keymap / 'keymap.json').as_posix(),
'path': (keymap_rel / 'keymap.json').as_posix(),
}

keyboard_dir.mkdir(parents=True, exist_ok=True)
Expand Down

0 comments on commit 076e085

Please sign in to comment.