diff options
author | Pierre Le Marre <dev@wismill.eu> | 2023-09-18 18:17:34 +0200 |
---|---|---|
committer | Wismill <dev@wismill.eu> | 2023-09-19 08:49:52 +0200 |
commit | ef81d04eef4b1a60ff42bd9ccbe2918b0a5420ec (patch) | |
tree | 58bb8120a870c6f3db1f50d2049c0f69f2030d80 /doc | |
parent | 0e3e2d17302e99e68bdab3b5db0a1dcc835e5bee (diff) | |
download | libxkbcommon-ef81d04eef4b1a60ff42bd9ccbe2918b0a5420ec.tar.gz libxkbcommon-ef81d04eef4b1a60ff42bd9ccbe2918b0a5420ec.tar.bz2 libxkbcommon-ef81d04eef4b1a60ff42bd9ccbe2918b0a5420ec.zip |
Structured log messages with a message registry
Currently there is little structure in the log messages, making
difficult to use them for the following use cases:
- A user looking for help about a log message: the user probably
uses a search engine, thus the results will depend on the proper
indexing of our documentation and the various forums. It relies
only on the wording of the message, which may change with time.
- A user wants to filter the logs resulting of the use of one of the
components of xkbcommon. A typical example would be testing
xkeyboard-config against libxkbcommon. It requires the use of a
pattern (simple words detection or regex). The issue is that the
pattern may become silently out-of-sync with xkbcommon.
A common practice (e.g. in compilers) is to assign unique error codes
to reference theses messages, along with an error index for
documentation.
Thus this commit implements the following features:
- Create a message registry (message-registry.yaml) that defines the
log messages produced by xkbcommon. This is a simple YAML file that
provides, for each message:
- A unique numeric code as a short identifier. It is used in the
output message and thus can be easily be filtered to spot errors
or searched in the internet. It must not change: if the
semantics of message changes, it is better to introduce a new
message for clarity.
- A unique text identifier, meant for two uses:
1. Generate constants dealing with log information in our code
base.
2. Generate human-friendly names for the documentation.
- A type: currently warning or error. Used to prefix the constants
(see hereinabove) and for basic classification in documentation.
- A short description, used as concise and mandatory documentation.
- An optionnal detailed description.
- Optional examples, intended to help the user to fix issues
themself.
- Version of xkbcommon it was added. For old entries this often
unknown, so they will default to 1.0.0.
- Version of xkbcommon it was removed (optional)
No entry should ever be deleted from this index, even if the message
is not used anymore: it ensures we have unique identifiers along the
history of xkbcommon, and that users can refer to the documentation
even for older versions.
- Add the script update-message-registry.py to generate the following
files:
- messages.h: message code enumeration for the messages currently
used in the code base. Currently a private API.
- message.registry.md: the error index documentation page.
- Modify the logging functions to use structured messages. This is a
work in progress.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/cool-uris.yaml | 1 | ||||
-rw-r--r-- | doc/doxygen-extra.css | 28 | ||||
-rw-r--r-- | doc/message-registry.md | 293 | ||||
-rw-r--r-- | doc/message-registry.md.jinja | 74 | ||||
-rw-r--r-- | doc/message-registry.yaml | 176 |
5 files changed, 572 insertions, 0 deletions
diff --git a/doc/cool-uris.yaml b/doc/cool-uris.yaml index b739ee5..9fae6d1 100644 --- a/doc/cool-uris.yaml +++ b/doc/cool-uris.yaml @@ -7,6 +7,7 @@ dir_63ce773eee1f9b680e6e312b48cc99ca.html: [] dir_891596f32582d3133e8915e72908625f.html: [] dir_d44c64559bbebec7f509842c48db8b23.html: [] dir_e68e8157741866f444e17edd764ebbae.html: [] +error-index.html: [] files.html: [] functions.html: [] functions_func.html: [] diff --git a/doc/doxygen-extra.css b/doc/doxygen-extra.css index 104fa0b..569cd2e 100644 --- a/doc/doxygen-extra.css +++ b/doc/doxygen-extra.css @@ -31,3 +31,31 @@ a[href^="https://"]::after background-size: contain; display: inline-block; } + +/******************************************************************************* + * Error index + ******************************************************************************/ + +div.example-container { + display: flex; + flex-flow: row wrap; + justify-content: space-between; + gap: 1em; +} + +div.example { + flex-grow: 1; + overflow-x: auto; + margin-top: 1em; +} + +div.example-inner { + height: 100%; + display: flex; + flex-direction: column; +} + +div.example-title { + padding: 0 0 1em 0; + font-style: italic; +} diff --git a/doc/message-registry.md b/doc/message-registry.md new file mode 100644 index 0000000..69027be --- /dev/null +++ b/doc/message-registry.md @@ -0,0 +1,293 @@ +# Error index {#error-index} + +<!-- +NOTE: This file has been generated automatically by “update-message-registry.py”. + Do not edit manually! +--> + +This page lists the warnings and errors generated by xkbcommon. +There are currently 20 entries. + +@todo The documentation of the log messages is a work in progress. + +## Index + +| Code | Identifier | Description | Type | +| --------- | ---------------------------- | ----------- | ---- | +| [XKB-034] | `malformed-number-literal` | Warn on malformed number literals | Error | +| [XKB-060] | `unsupported-modifier-mask` | Warn on unsupported modifier mask | Error | +| [XKB-107] | `unrecognized-keysym` | Warn on unrecognized keysyms | Warning | +| [XKB-183] | `cannot-infer-key-type` | Warn if no key type can be inferred | Warning | +| [XKB-237] | `unsupported-group-index` | Warn when a group index is not supported | Error | +| [XKB-286] | `undefined-key-type` | Warn if using an undefined key type | Warning | +| [XKB-305] | `non-base-group-name` | Warn if a group name was defined for group other than the first one | Warning | +| [XKB-312] | `unsupported-shift-level` | Warn when a shift level is not supported | Error | +| [XKB-461] | `conflicting-key-symbol` | Warn if there are conflicting keysyms while merging keys | Warning | +| [XKB-516] | `extra-symbols-ignored` | <span class="todo">TODO:</span> add description | Warning | +| [XKB-578] | `wrong-field-type` | Warn when a field has not the expected type | Error | +| [XKB-645] | `unknown-char-escape-sequence` | Warn on unknown escape sequence in string literal | Warning | +| [XKB-700] | `multiple-groups-at-once` | Warn if a key defines multiple groups at once | Warning | +| [XKB-769] | `invalid-syntax` | The syntax is invalid and the file cannot be parsed | Error | +| [XKB-770] | `undefined-keycode` | <span class="todo">TODO:</span> add description | Warning | +| [XKB-800] | `conflicting-modmap` | Warn if there are conflicting modmap definitions | Warning | +| [XKB-883] | `conflicting-key-action` | Warn if there are conflicting actions while merging keys | Warning | +| [XKB-893] | `conflicting-key-type` | Warn if there are conflicting key types while merging groups | Warning | +| [XKB-935] | `conflicting-key-fields` | Warn if there are conflicting fields while merging keys | Warning | +| [XKB-965] | `unresolved-keymap-symbol` | Warn if using a symbol not defined in the keymap | Warning | + +## Details + +### XKB-034 – Malformed number literal {#XKB-034} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Error</dd> + <dt>Summary</dt><dd>Warn on malformed number literals</dd> +</dl> + +xkbcommon can parse the following number literal formats: + +- *decimal integer:* 1, 123, etc. +- *decimal floating-point number:* 1.23, etc. +- *hexadecimal integer:* prefixed with “0x”: 0x123, 0xff, 0xAB, etc. + + +### XKB-060 – Unsupported modifier mask {#XKB-060} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Error</dd> + <dt>Summary</dt><dd>Warn on unsupported modifier mask</dd> +</dl> + +### XKB-107 – Unrecognized keysym {#XKB-107} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd>Warn on unrecognized keysyms</dd> +</dl> + +xkbcommon replaces keysyms it does not recognize by the keysym `NoSymbol`. + +You may find the list of supported keysyms in +`include/xkbcommon/xkbcommon-keysyms.h`. + + +#### Examples + +<details> + <summary>Unrecognized keysym “`coma`”</summary> + +**Error message:** + +``` +xkbcommon: WARNING: [XKB-107] de:31:20: unrecognized keysym "coma" +``` + +xkbcommon does not recognize the keysym “`coma`”. It is most probably +a typo for “<code>com<em>m</em>a</code>”. +See: `XKB_KEY_comma` in `include/xkbcommon/xkbcommon-keysyms.h`. + +**Fix:** + <div class="example-container"> + <div class="example"> + <div class="example-inner"> + <div class="example-title">Before</div> +```c +key <AB08> {[ coma, semicolon, periodcentered, multiply ]}; +``` +</div> + </div> + <div class="example"> + <div class="example-inner"> + <div class="example-title">After</div> +```c +key <AB08> {[ comma, semicolon, periodcentered, multiply ]}; +``` +</div> + </div> + </div> +</details> + +### XKB-183 – Cannot infer key type {#XKB-183} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd>Warn if no key type can be inferred</dd> +</dl> + +### XKB-237 – Unsupported group index {#XKB-237} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Error</dd> + <dt>Summary</dt><dd>Warn when a group index is not supported</dd> +</dl> + +xkbcommon supports group index in the range (1..4). + + +### XKB-286 – Undefined key type {#XKB-286} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd>Warn if using an undefined key type</dd> +</dl> + +### XKB-305 – Non base group name {#XKB-305} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd>Warn if a group name was defined for group other than the first one</dd> +</dl> + +### XKB-312 – Unsupported shift level {#XKB-312} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Error</dd> + <dt>Summary</dt><dd>Warn when a shift level is not supported</dd> +</dl> + +Shift levels are _one_-indexed. xkbcommon supports two formats of shift levels: +as numbers and as identifiers `LevelN`, where `N` is in the range (1..8). + + +### XKB-461 – Conflicting key symbol {#XKB-461} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd>Warn if there are conflicting keysyms while merging keys</dd> +</dl> + +### XKB-516 – Extra symbols ignored {#XKB-516} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd><span class="todo">TODO:</span> add description</dd> +</dl> + +### XKB-578 – Wrong field type {#XKB-578} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Error</dd> + <dt>Summary</dt><dd>Warn when a field has not the expected type</dd> +</dl> + +### XKB-645 – Unknown char escape sequence {#XKB-645} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd>Warn on unknown escape sequence in string literal</dd> +</dl> + +xkbcommon support the following escape sequences in string literals: + +| Escape sequence | Corresponding character | +| --------------- | ----------------------------------- | +| `\b` | `U+0008` Backspace | +| `\t` | `U+0009` Character tabulation | +| `\n` | `U+000A` Line feed | +| `\v` | `U+000B` Vertical tabulation | +| `\f` | `U+000C` Form feed | +| `\r` | `U+000D` Carriage return | +| `\e` | `U+001B` Escape | +| `\\` | `U+005C` Backslash | +| `\NNN` | _Octal_ escape, from `\0` to `\777` | + + +### XKB-700 – Multiple groups at once {#XKB-700} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd>Warn if a key defines multiple groups at once</dd> +</dl> + +### XKB-769 – Invalid syntax {#XKB-769} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Error</dd> + <dt>Summary</dt><dd>The syntax is invalid and the file cannot be parsed</dd> +</dl> + +### XKB-770 – Undefined keycode {#XKB-770} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd><span class="todo">TODO:</span> add description</dd> +</dl> + +### XKB-800 – Conflicting modmap {#XKB-800} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd>Warn if there are conflicting modmap definitions</dd> +</dl> + +@todo detailed explanation and examples + + +### XKB-883 – Conflicting key action {#XKB-883} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd>Warn if there are conflicting actions while merging keys</dd> +</dl> + +### XKB-893 – Conflicting key type {#XKB-893} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd>Warn if there are conflicting key types while merging groups</dd> +</dl> + +### XKB-935 – Conflicting key fields {#XKB-935} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd>Warn if there are conflicting fields while merging keys</dd> +</dl> + +### XKB-965 – Unresolved keymap symbol {#XKB-965} + +<dl> + <dt>Since</dt><dd>1.0.0</dd> + <dt>Type</dt><dd>Warning</dd> + <dt>Summary</dt><dd>Warn if using a symbol not defined in the keymap</dd> +</dl> + +[XKB-034]: @ref XKB-034 +[XKB-060]: @ref XKB-060 +[XKB-107]: @ref XKB-107 +[XKB-183]: @ref XKB-183 +[XKB-237]: @ref XKB-237 +[XKB-286]: @ref XKB-286 +[XKB-305]: @ref XKB-305 +[XKB-312]: @ref XKB-312 +[XKB-461]: @ref XKB-461 +[XKB-516]: @ref XKB-516 +[XKB-578]: @ref XKB-578 +[XKB-645]: @ref XKB-645 +[XKB-700]: @ref XKB-700 +[XKB-769]: @ref XKB-769 +[XKB-770]: @ref XKB-770 +[XKB-800]: @ref XKB-800 +[XKB-883]: @ref XKB-883 +[XKB-893]: @ref XKB-893 +[XKB-935]: @ref XKB-935 +[XKB-965]: @ref XKB-965 diff --git a/doc/message-registry.md.jinja b/doc/message-registry.md.jinja new file mode 100644 index 0000000..e1d40d7 --- /dev/null +++ b/doc/message-registry.md.jinja @@ -0,0 +1,74 @@ +# Error index { {#--#} #error-index} + +{# NOTE: Prevent Doxygen issue by writing the comment after the first header. #} +<!-- +NOTE: This file has been generated automatically by “{{script}}”. + Do not edit manually! +--> + +This page lists the warnings and errors generated by xkbcommon. +There are currently {{ entries|length }} entries. + +@todo The documentation of the log messages is a work in progress. + +## Index + +| Code | Identifier | Description | Type | +| --------- | ---------------------------- | ----------- | ---- | +{% for entry in entries %} +| [{{entry.message_code}}] | `{{entry.id}}` | {{entry.description|prepend_todo}} | {{entry.type|capitalize}} | +{% endfor %} + +## Details + +{% for entry in entries %} +### {{entry.message_code}} – {{entry.message_name}} { {#--#}#{{entry.message_code}}} + +<dl> +{% if entry.removed %} + <dt>Added in</dt><dd>{{entry.added}}</dd> + <dt>Removed in</dt><dd>{{entry.removed}}</dd> +{% else %} + <dt>Since</dt><dd>{{entry.added}}</dd> +{% endif %} + <dt>Type</dt><dd>{{entry.type|capitalize}}</dd> + <dt>Summary</dt><dd>{{entry.description|prepend_todo}}</dd> +</dl> + +{% if entry.details %} +{{entry.details}} + +{% endif %} +{% if entry.examples %} +#### Examples + +{% for example in entry.examples %} +<details> + <summary>{{example.name}}</summary> + +{{example.description}} +{% if example.before %} +**Fix:** + <div class="example-container"> + <div class="example"> + <div class="example-inner"> + <div class="example-title">Before</div> +{{example.before-}} + </div> + </div> + <div class="example"> + <div class="example-inner"> + <div class="example-title">After</div> +{{example.after-}} + </div> + </div> + </div> +{% endif %} +</details> + +{% endfor %} +{% endif %} +{% endfor %} +{% for entry in entries %} +[{{entry.message_code}}]: @ref {{entry.message_code}} +{% endfor %} diff --git a/doc/message-registry.yaml b/doc/message-registry.yaml new file mode 100644 index 0000000..fea4658 --- /dev/null +++ b/doc/message-registry.yaml @@ -0,0 +1,176 @@ +# Guidelines: +# • A message code must always have the same meaning forever. +# • Codes may be retired or introduced in new releases. In order to avoid +# clashes, retired codes must not be deleted. +# • Codes should not themselves reflect classification, e.g. a range for parse +# errors and a range for each keymap component. +# • Codes should not be assigned sequentially because it is misleading. +# • Codes must be in the range 1..999. This range may be extended once every +# code has be assigned. +# +# See the following guidelines for futher details on good practices: +# https://github.com/haskellfoundation/error-message-index/blob/main/tool-developers.md#code-assignment-recommendations + +# NOTE: Field “added: ALWAYS” means that the precise version is unknown and +# anterior to the introduction of the message registry. It will be replaced by +# the default version 1.0.0 in the generated documentation. While this is deemed +# good enough to avoid spelunking commit history, a more precise version would +# be welcome. + +# TODO: fix missing detailed description, examples, resolution + +- id: "malformed-number-literal" + code: 34 + added: ALWAYS + type: error + description: "Warn on malformed number literals" + details: | + xkbcommon can parse the following number literal formats: + + - *decimal integer:* 1, 123, etc. + - *decimal floating-point number:* 1.23, etc. + - *hexadecimal integer:* prefixed with “0x”: 0x123, 0xff, 0xAB, etc. +- id: "unsupported-modifier-mask" + code: 60 + added: ALWAYS + type: error + description: "Warn on unsupported modifier mask" +- id: "unrecognized-keysym" + code: 107 + added: ALWAYS + type: warning + description: "Warn on unrecognized keysyms" + details: | + xkbcommon replaces keysyms it does not recognize by the keysym `NoSymbol`. + + You may find the list of supported keysyms in + `include/xkbcommon/xkbcommon-keysyms.h`. + examples: + - name: Unrecognized keysym “`coma`” + description: | + **Error message:** + + ``` + xkbcommon: WARNING: [XKB-107] de:31:20: unrecognized keysym "coma" + ``` + + xkbcommon does not recognize the keysym “`coma`”. It is most probably + a typo for “<code>com<em>m</em>a</code>”. + See: `XKB_KEY_comma` in `include/xkbcommon/xkbcommon-keysyms.h`. + before: | + ```c + key <AB08> {[ coma, semicolon, periodcentered, multiply ]}; + ``` + after: | + ```c + key <AB08> {[ comma, semicolon, periodcentered, multiply ]}; + ``` +- id: "cannot-infer-key-type" + code: 183 + added: ALWAYS + type: warning + description: "Warn if no key type can be inferred" +- id: "unsupported-group-index" + code: 237 + added: ALWAYS + type: error + description: "Warn when a group index is not supported" + details: | + xkbcommon supports group index in the range (1..{{XKB_MAX_GROUPS}}). +- id: "undefined-key-type" + code: 286 + added: ALWAYS + type: warning + description: "Warn if using an undefined key type" +- id: "non-base-group-name" + code: 305 + added: ALWAYS + type: warning + description: "Warn if a group name was defined for group other than the first one" +- id: "unsupported-shift-level" + code: 312 + added: ALWAYS + type: error + description: "Warn when a shift level is not supported" + details: | + Shift levels are _one_-indexed. xkbcommon supports two formats of shift levels: + as numbers and as identifiers `LevelN`, where `N` is in the range (1..8). +- id: "conflicting-key-symbol" + code: 461 + added: ALWAYS + type: warning + description: "Warn if there are conflicting keysyms while merging keys" +- id: "extra-symbols-ignored" + code: 516 + added: ALWAYS + type: warning + description: "TODO: add description" +- id: "wrong-field-type" + code: 578 + added: ALWAYS + type: error + description: "Warn when a field has not the expected type" +- id: "unknown-char-escape-sequence" + code: 645 + added: ALWAYS + type: warning + description: "Warn on unknown escape sequence in string literal" + details: | + xkbcommon support the following escape sequences in string literals: + + | Escape sequence | Corresponding character | + | --------------- | ----------------------------------- | + | `\b` | `U+0008` Backspace | + | `\t` | `U+0009` Character tabulation | + | `\n` | `U+000A` Line feed | + | `\v` | `U+000B` Vertical tabulation | + | `\f` | `U+000C` Form feed | + | `\r` | `U+000D` Carriage return | + | `\e` | `U+001B` Escape | + | `\\` | `U+005C` Backslash | + | `\NNN` | _Octal_ escape, from `\0` to `\777` | +- id: "multiple-groups-at-once" + code: 700 + added: ALWAYS + type: warning + description: "Warn if a key defines multiple groups at once" +- id: "invalid-syntax" + code: 769 + added: ALWAYS + type: error + description: "The syntax is invalid and the file cannot be parsed" +- id: "undefined-keycode" + code: 770 + added: ALWAYS + type: warning + description: "TODO: add description" +- id: "conflicting-modmap" + code: 800 + added: ALWAYS + type: warning + description: "Warn if there are conflicting modmap definitions" + details: | + @todo detailed explanation and examples +- id: "conflicting-key-action" + code: 883 + added: ALWAYS + type: warning + description: "Warn if there are conflicting actions while merging keys" +- id: "conflicting-key-type" + code: 893 + added: ALWAYS + type: warning + description: "Warn if there are conflicting key types while merging groups" +- id: "conflicting-key-fields" + code: 935 + added: ALWAYS + type: warning + description: "Warn if there are conflicting fields while merging keys" +- id: "unresolved-keymap-symbol" + code: 965 + added: ALWAYS + type: warning + description: "Warn if using a symbol not defined in the keymap" + +# TODO: deprecated keysym +# TODO: unicode keysym when named and recommended keysym exists |