doc: add the rules-format file (as markdown) Useful to have this as part of the documentation. The rendering isn't great but at least not any worse than pure text. Markdown escapes % so explaining our use of %S and %H would require a double % - not idea. Let's just wrap it as a code block and done. Includes two typo fixes too, yay. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
diff --git a/doc/rules-format.md b/doc/rules-format.md
new file mode 100644
index 0000000..96acbbf
--- /dev/null
+++ b/doc/rules-format.md
@@ -0,0 +1,106 @@
+The rules file
+==============
+
+The purpose of the rules file is to map between configuration values
+that are easy for a user to specify and understand, and the
+configuration values xkbcomp uses and understands.
+
+xkbcomp uses the xkb_component_names struct, which maps directly to
+include statements of the appropriate sections, called for short
+KcCGST (see doc/keymap-format-text-v1.txt; 'G' stands for "geometry",
+which is not supported). These are not really intuitive or straight-
+forward for the uninitiated.
+
+Instead, the user passes in a xkb_rule_names struct, which consists
+of the name of a rules file (in Linux this is usually "evdev"), a
+keyboard model (e.g. "pc105"), a set of layouts (which will end up
+in different groups, e.g. "us,fr"), variants (used to alter/augment
+the respective layout, e.g. "intl,dvorak"), and a set of options
+(used to tweak some general behavior of the keyboard, e.g.
+"ctrl:nocaps,compose:menu" to make the Caps Lock key act like Ctrl
+and the Menu key like Compose). We call these RMLVO.
+
+Format of the file
+------------------
+The file consists of rule sets, each consisting of rules (one per
+line), which match the MLVO values on the left hand side, and, if
+the values match to the values the user passed in, results in the
+values on the right hand side being added to the resulting KcCGST.
+Since some values are related and repeated often, it is possible
+to group them together and refer to them by a group name in the
+rules.
+
+Along with matching values by simple string equality, and for
+membership in a group defined previously, rules may also contain
+"wildcard" values - "*" - which always match. These usually appear
+near the end.
+
+Grammar
+-------
+(It might be helpful to look at a file like rules/evdev along with
+this grammar. Comments, whitespace, etc. are not shown.)
+
+```
+File ::= { "!" (Include | Group | RuleSet) }
+
+Include ::= "include" <ident>
+
+Group ::= GroupName "=" { GroupElement } "\n"
+GroupName ::= "$"<ident>
+GroupElement ::= <ident>
+
+RuleSet ::= Mapping { Rule }
+
+Mapping ::= { Mlvo } "=" { Kccgst } "\n"
+Mlvo ::= "model" | "option" | ("layout" | "variant") [ Index ]
+Index ::= "[" 1..XKB_NUM_GROUPS "]"
+Kccgst ::= "keycodes" | "symbols" | "types" | "compat" | "geometry"
+
+Rule ::= { MlvoValue } "=" { KccgstValue } "\n"
+MlvoValue ::= "*" | GroupName | <ident>
+KccgstValue ::= <ident>
+```
+
+Notes:
+
+- Include processes the rules in the file path specified in the ident,
+ in order. %-expansion is performed, as follows:
+
+```
+ %%:
+ A literal %.
+
+ %H:
+ The value of the HOME environment variable.
+
+ %S:
+ The system-installed rules directory (usually /usr/share/X11/xkb/rules).
+```
+
+- The order of values in a Rule must be the same as the Mapping it
+ follows. The mapping line determines the meaning of the values in
+ the rules which follow in the RuleSet.
+
+- If a Rule is matched, %-expansion is performed on the KccgstValue,
+ as follows:
+
+```
+ %m, %l, %v:
+ The model, layout or variant, if only one was given (e.g.
+ %l for "us,il" is invalid).
+
+ %l[1], %v[1]:
+ Layout or variant for the specified group Index, if more than
+ one was given (e.g. %l[1] for "us" is invalid).
+
+ %+m, %+l, %+v, %+l[1], %+v[1]
+ As above, but prefixed with '+'. Similarly, '|', '-', '_' may be
+ used instead of '+'.
+
+ %(m), %(l), %(l[1]), %(v), %(v[1]):
+ As above, but prefixed by '(' and suffixed by ')'.
+```
+
+ In case the expansion is invalid, as described above, it is
+ skipped (the rest of the string is still processed); this includes
+ the prefix and suffix (that's why you shouldn't use e.g. "(%v[1])").
diff --git a/doc/rules-format.txt b/doc/rules-format.txt
deleted file mode 100644
index d97d8e8..0000000
--- a/doc/rules-format.txt
+++ /dev/null
@@ -1,100 +0,0 @@
-The rules file
-==============
-
-The purpose of the rules file is to map between configuration values
-that are easy for a user to specify and understand, and the
-configuration values xkbcomp uses and understands.
-
-xkbcomp uses the xkb_component_names struct, which maps directly to
-include statements of the appropriate sections, called for short
-KcCGST (see doc/keymap-format-text-v1.txt; 'G' stands for "geometry",
-which is not supported). These are not really intuitive or straight-
-forward for the uninitiated.
-
-Instead, the user passes in a xkb_rule_names struct, which consists
-of the name of a rules file (in Linux this is usually "evdev"), a
-keyboard model (e.g. "pc105"), a set of layouts (which will end up
-in different groups, e.g. "us,fr"), variants (used to alter/augment
-the respective layout, e.g. "intl,dvorak"), and a set of options
-(used to tweak some general behavior of the keyboard, e.g.
-"ctrl:nocaps,compose:menu" to make the Caps Lock key act like Ctrl
-and the Menu key like Compose). We call these RMLVO.
-
-Format of the file
-------------------
-The file consists of rule sets, each consisting of rules (one per
-line), which match the MLVO values on the left hand side, and, if
-the values match to the values the user passed in, results in the
-values on the right hand side being added to the resulting KcCGST.
-Since some values are related and repeated often, it is possible
-to group them together and refer to them by a group name in the
-rules.
-
-Along with matching values by simple string equality, and for
-membership in a group defined previously, rules may also contain
-"wildcard" values - "*" - which always match. These usually appear
-near the end.
-
-Grammar
--------
-(It might be helpful to look at a file like rules/evdev along with
-this grammer. Comments, whitespace, etc. are not shown.)
-
-File ::= { "!" (Include | Group | RuleSet) }
-
-Include ::= "include" <ident>
-
-Group ::= GroupName "=" { GroupElement } "\n"
-GroupName ::= "$"<ident>
-GroupElement ::= <ident>
-
-RuleSet ::= Mapping { Rule }
-
-Mapping ::= { Mlvo } "=" { Kccgst } "\n"
-Mlvo ::= "model" | "option" | ("layout" | "variant") [ Index ]
-Index ::= "[" 1..XKB_NUM_GROUPS "]"
-Kccgst ::= "keycodes" | "symbols" | "types" | "compat" | "geometry"
-
-Rule ::= { MlvoValue } "=" { KccgstValue } "\n"
-MlvoValue ::= "*" | GroupName | <ident>
-KccgstValue ::= <ident>
-
-Notes:
-
-- Include processes the rules in the file path specified in the ident,
- in order. %-expanasion is performed, as follows:
-
- %%:
- A literal %.
-
- %H:
- The value of the HOME environment variable.
-
- %S:
- The system-installed rules directory (usually /usr/share/X11/xkb/rules).
-
-- The order of values in a Rule must be the same as the Mapping it
- follows. The mapping line determines the meaning of the values in
- the rules which follow in the RuleSet.
-
-- If a Rule is matched, %-expansion is performed on the KccgstValue,
- as follows:
-
- %m, %l, %v:
- The model, layout or variant, if only one was given (e.g.
- %l for "us,il" is invalid).
-
- %l[1], %v[1]:
- Layout or variant for the specified group Index, if more than
- one was given (e.g. %l[1] for "us" is invalid).
-
- %+m, %+l, %+v, %+l[1], %+v[1]
- As above, but prefixed with '+'. Similarly, '|', '-', '_' may be
- used instead of '+'.
-
- %(m), %(l), %(l[1]), %(v), %(v[1]):
- As above, but prefixed by '(' and suffixed by ')'.
-
- In case the expansion is invalid, as described above, it is
- skipped (the rest of the string is still processed); this includes
- the prefix and suffix (that's why you shouldn't use e.g. "(%v[1])").
diff --git a/meson.build b/meson.build
index 9729bca..2ea360d 100644
--- a/meson.build
+++ b/meson.build
@@ -543,6 +543,7 @@ You can disable the documentation with -Denable-docs=false.''')
'doc/doxygen-extra.css',
'doc/quick-guide.md',
'doc/compat.md',
+ 'doc/rules-format.md',
'xkbcommon/xkbcommon.h',
'xkbcommon/xkbcommon-names.h',
'xkbcommon/xkbcommon-x11.h',