build(docs): sort/lint class fields and keysets

Problem:
Fields (key names) in classes, keysets, and quasi-keysets are ordered
randomly, which adds friction when reading docs.

Solution:
- Sort class fields and keysets when generating docs.
- Add a lint check for quasi-keysets (keysets defined as unstructured
  markdown lists within a docstring).
This commit is contained in:
Justin M. Keyes
2026-04-26 12:36:07 +02:00
parent 1e3e06f582
commit 033efbbd32
4 changed files with 61 additions and 0 deletions

View File

@@ -610,6 +610,8 @@ local function inline_type(obj, classes)
end
end
util.sort_by_key(cls.fields, 'name')
local desc_append = {}
for _, f in ipairs(cls.fields) do
if not f.access then
@@ -715,6 +717,8 @@ local function render_class(class, classes, hidden_fields, cfg)
end, fields)
end
util.sort_by_key(fields, 'name')
local fields_txt = render_fields_or_params(fields, nil, classes, cfg)
if not fields_txt:match('^%s*$') then
table.insert(ret, '\n Fields: ~\n')
@@ -1145,6 +1149,7 @@ local function gen_target(cfg)
if not f:find('ui_events%.in%.h$') then -- TODO(justinmk): also lint UI events.
lint.lint_names(f, funs, nil, classes)
lint.lint_quasi_keysets(f, funs)
end
local mod_cls_nm = find_module_class(classes, 'M')