diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/config_reference_check.py | 6 | ||||
| -rw-r--r-- | scripts/test_config_reference_check.py | 19 |
2 files changed, 23 insertions, 2 deletions
diff --git a/scripts/config_reference_check.py b/scripts/config_reference_check.py index f9aa5e72..c23b284b 100644 --- a/scripts/config_reference_check.py +++ b/scripts/config_reference_check.py @@ -35,7 +35,9 @@ SKIPPED_SUBTREES = ("keys.command",) FIELD_RE = re.compile(r"^\s*pub ([a-z_][a-z0-9_]*):\s*(.+?),?\s*$") STRUCT_RE = re.compile(r"^\s*pub(?:\(crate\))? struct ([A-Za-z0-9_]+)\s*\{\s*$") ENUM_RE = re.compile(r"^\s*pub(?:\(crate\))? enum ([A-Za-z0-9_]+)\s*\{\s*$") -VARIANT_RE = re.compile(r"^\s*([A-Z][A-Za-z0-9_]*)\s*(?:\(.*\))?\s*,?\s*$") +VARIANT_RE = re.compile( + r"^\s*([A-Z][A-Za-z0-9_]*)\s*(?:\(.*\)|\{)?\s*,?\s*$" +) RENAME_ALL_RE = re.compile(r'rename_all\s*=\s*"([^"]+)"') RENAME_RE = re.compile(r'rename\s*=\s*"([^"]+)"') @@ -190,11 +192,11 @@ def parse_enum_body( index += 1 break - depth += stripped.count("{") - stripped.count("}") if depth == 0 and not stripped.startswith(("#[", "///")): match = VARIANT_RE.match(stripped) if match: variants.append(apply_rename_all(match.group(1), rename_all or "lowercase")) + depth += stripped.count("{") - stripped.count("}") index += 1 model.enums[name] = variants diff --git a/scripts/test_config_reference_check.py b/scripts/test_config_reference_check.py index 317aae8a..b5a804b1 100644 --- a/scripts/test_config_reference_check.py +++ b/scripts/test_config_reference_check.py @@ -32,6 +32,8 @@ pub struct UiConfig { pub sidebar_width: u16, /// Host cursor policy. Default: auto. pub host_cursor: HostCursorModeConfig, + /// Tab bar status entries. + pub tab_bar_right: Vec<TabBarRightEntryConfig>, #[serde(rename = "accent_color")] pub accent: String, #[serde(skip)] @@ -64,6 +66,19 @@ pub enum HostCursorModeConfig { } #[derive(Debug, Deserialize)] +#[serde(tag = "type", rename_all = "snake_case")] +pub enum TabBarRightEntryConfig { + Hostname, + Datetime { + format: String, + }, + Command { + command: String, + interval_seconds: u64, + }, +} + +#[derive(Debug, Deserialize)] #[serde(untagged)] pub enum BindingConfig { One(String), @@ -129,6 +144,10 @@ class CollectKeysTests(unittest.TestCase): self.assertEqual( entries["ui.host_cursor"]["values"], ["auto", "native-cursor", "drawn"] ) + self.assertEqual( + entries["ui.tab_bar_right"]["values"], + ["hostname", "datetime", "command"], + ) self.assertNotIn("values", entries["keys.zoom"]) |
