From 7baf9b3f357abe314fcd02e01c814f9516d66e89 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Fri, 10 Jun 2022 11:44:23 +0100 Subject: Promote label with newlines to lint error (#17347) --- data/schemas/keyboard.jsonschema | 5 ++++- keyboards/sendyyeah/75pixels/info.json | 28 ++++++++++++++-------------- lib/python/qmk/info.py | 10 ---------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index dc5592220b..fd60920578 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -145,7 +145,10 @@ "type": "object", "additionalProperties": false, "properties": { - "label": {"type": "string"}, + "label": { + "type": "string", + "pattern": "^[^\\n]*$" + }, "matrix": { "type": "array", "minItems": 2, diff --git a/keyboards/sendyyeah/75pixels/info.json b/keyboards/sendyyeah/75pixels/info.json index 193beb6532..6fb65c1d88 100644 --- a/keyboards/sendyyeah/75pixels/info.json +++ b/keyboards/sendyyeah/75pixels/info.json @@ -31,10 +31,10 @@ {"label": "I", "x": 8, "y": 1}, {"label": "O", "x": 9, "y": 1}, {"label": "P", "x": 10, "y": 1}, - {"label": "|\n\\", "x": 11, "y": 1}, - {"label": "7\nHome", "x": 12, "y": 1}, - {"label": "8\nUp", "x": 13, "y": 1}, - {"label": "9\nPgUp", "x": 14, "y": 1}, + {"label": "|", "x": 11, "y": 1}, + {"label": "7", "x": 12, "y": 1}, + {"label": "8", "x": 13, "y": 1}, + {"label": "9", "x": 14, "y": 1}, {"label": "Caps", "x": 0, "y": 2}, {"label": "A", "x": 1, "y": 2}, {"label": "S", "x": 2, "y": 2}, @@ -47,9 +47,9 @@ {"label": "L", "x": 9, "y": 2}, {"label": ":", "x": 10, "y": 2}, {"label": "Enter", "x": 11, "y": 2}, - {"label": "4\nLeft", "x": 12, "y": 2}, + {"label": "4", "x": 12, "y": 2}, {"label": "5", "x": 13, "y": 2}, - {"label": "6\nRight", "x": 14, "y": 2}, + {"label": "6", "x": 14, "y": 2}, {"label": "Shift", "x": 0, "y": 3}, {"label": "Z", "x": 1, "y": 3}, {"label": "X", "x": 2, "y": 3}, @@ -58,13 +58,13 @@ {"label": "B", "x": 5, "y": 3}, {"label": "N", "x": 6, "y": 3}, {"label": "M", "x": 7, "y": 3}, - {"label": "<\n,", "x": 8, "y": 3}, - {"label": ">\n.", "x": 9, "y": 3}, - {"label": "?\n/", "x": 10, "y": 3}, + {"label": "<", "x": 8, "y": 3}, + {"label": ">", "x": 9, "y": 3}, + {"label": "?", "x": 10, "y": 3}, {"label": "Shift", "x": 11, "y": 3}, - {"label": "1\nEnd", "x": 12, "y": 3}, - {"label": "2\nDown", "x": 13, "y": 3}, - {"label": "3\nPgDn", "x": 14, "y": 3}, + {"label": "1", "x": 12, "y": 3}, + {"label": "2", "x": 13, "y": 3}, + {"label": "3", "x": 14, "y": 3}, {"label": "Ctrl", "x": 0, "y": 4}, {"label": "Win", "x": 1, "y": 4}, {"label": "Alt", "x": 2, "y": 4}, @@ -77,8 +77,8 @@ {"label": "Win", "x": 9, "y": 4}, {"label": "Menu", "x": 10, "y": 4}, {"label": "Ctrl", "x": 11, "y": 4}, - {"label": "0\nIns", "x": 12, "y": 4}, - {"label": ".\nDel", "x": 13, "y": 4}, + {"label": "0", "x": 12, "y": 4}, + {"label": ".", "x": 13, "y": 4}, {"label": "Enter", "x": 14, "y": 4} ] } diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 6ff9cba45b..dd753f328c 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -26,13 +26,6 @@ def _valid_community_layout(layout): return (Path('layouts/default') / layout).exists() -def _remove_newlines_from_labels(layouts): - for layout_name, layout_json in layouts.items(): - for key in layout_json['layout']: - if '\n' in key['label']: - key['label'] = key['label'].split('\n')[0] - - def info_json(keyboard): """Generate the info.json data for a specific keyboard. """ @@ -111,9 +104,6 @@ def info_json(keyboard): # Check that the reported matrix size is consistent with the actual matrix size _check_matrix(info_data) - # Remove newline characters from layout labels - _remove_newlines_from_labels(layouts) - return info_data -- cgit v1.2.3 From 92665aef33148fef051ad07687028c88f0da64fc Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Fri, 10 Jun 2022 11:44:48 +0100 Subject: Promote 'layouts require matrix data' to api error (#17349) --- lib/python/qmk/cli/lint.py | 7 ------- lib/python/qmk/info.py | 7 +++++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/python/qmk/cli/lint.py b/lib/python/qmk/cli/lint.py index af057b4110..96593ed69b 100644 --- a/lib/python/qmk/cli/lint.py +++ b/lib/python/qmk/cli/lint.py @@ -116,13 +116,6 @@ def lint(cli): if not keymap_check(kb, cli.config.lint.keymap): ok = False - # Check if all non-data driven macros exist in - for layout, data in keyboard_info['layouts'].items(): - # Matrix data should be a list with exactly two integers: [0, 1] - if not data['c_macro'] and not all('matrix' in key_data.keys() or len(key_data) == 2 or all(isinstance(n, int) for n in key_data) for key_data in data['layout']): - cli.log.error(f'{kb}: "{layout}" has no "matrix" definition in either "info.json" or ".h"!') - ok = False - # Report status if not ok: failed.append(kb) diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index dd753f328c..23761d71b7 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -797,8 +797,11 @@ def merge_info_jsons(keyboard, info_data): for new_key, existing_key in zip(layout['layout'], info_data['layouts'][layout_name]['layout']): existing_key.update(new_key) else: - layout['c_macro'] = False - info_data['layouts'][layout_name] = layout + if not all('matrix' in key_data.keys() for key_data in layout['layout']): + _log_error(info_data, f'Layout "{layout_name}" has no "matrix" definition in either "info.json" or ".h"!') + else: + layout['c_macro'] = False + info_data['layouts'][layout_name] = layout # Update info_data with the new data if 'layouts' in new_info_data: -- cgit v1.2.3