Skip to content

feat(pipeline): add @common/@commonparams shared parameter blocks - #7

Closed
pfeerick wants to merge 1 commit into
edgetx_2.12from
docs/common-param-support
Closed

feat(pipeline): add @common/@commonparams shared parameter blocks#7
pfeerick wants to merge 1 commit into
edgetx_2.12from
docs/common-param-support

Conversation

@pfeerick

@pfeerick pfeerick commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

The in-flight LVGL firmware annotation work (EdgeTX/edgetx#7771) repeats the same 9-line "common object properties" bullet list (x, y, w, h, color, pos, size, visible, floating) verbatim across 27+ widget-constructor luadoc comments, since there was no way to define it once and reference it from many functions. Any future change to those shared properties (this already happened once, for a version-citation fix) requires editing every single occurrence.

Adds two new luadoc tags to tools/docs_pipeline.py:

  • @common <name> defines a reusable, non-callable chunk of luadoc body text. It's never treated as an API item — no generated page, no nav entry, no hub-page card. Example:
    /*luadoc
    @common lvgl_object
    
     * `x` (number) position relative to the top-left of the parent
     * `y` (number) position relative to the top-left of the parent
     ...
    */
    
  • @commonparams <name> used inside a @function block's parameter section textually splices in the matching @common block's body, before normal @param/@retval parsing runs:
    @param params (table):
    @commonparams lvgl_object
     * `text` (string or function) text to display, defaults to an empty string
    

This works at the text level (splicing into the raw block before parsing), not as a structured-parameter-array merge after parsing — because the existing convention documents each settings table as a single @param params (table): * bullet * bullet ... entry, not one @param per field. Expansion has to happen before that bullet-list text collapses into one flat description string.

extract_model() now does two passes: collect all @common definitions first, then expand @commonparams references and parse @function blocks as normal. Fails loudly (matching this project's own stated extractor design goal) if a @commonparams reference points at an undefined @common block; warns if a @common block is defined but never referenced.

Also fixes a real, unrelated bug found while testing this against the LVGL branch's actual content: FUNCTION_RE/PARAM_RE/RETVAL_RE/NOTICE_RE/STATUS_RE all anchored ^@tag at true column 0, but the LVGL functions are indented 2 spaces (nested inside a table registration block) — every one of PR #7771's ~45 functions was silently extracting zero parameters and "unknown" availability before this fix. FUNCTION_RE itself didn't need the fix (extract_blocks() already strips the whole block, so the first tag always lands at column 0), but the other four did.

Test plan

  • New @common/@commonparams syntax unit-tested against a small standalone fixture — confirms expansion works, @common blocks don't become items, undefined references fail loudly, unused definitions warn
  • Converted PR #7771's LVGL branch content to use @commonparams in all 27 occurrences and diffed the full rendered output (Markdown + LuaLS .d.lua) before/after — every difference across all 33 changed files is either a source line number (which genuinely shifted) or a generation timestamp; zero content differences
  • mkdocs build --strict (public + dev configs) — both pass clean, confirming no regression to any non-LVGL content

🤖 Generated with Claude Code

https://claude.ai/code/session_015yCHydHbzZYCKpav38SonD

The LVGL firmware annotation work (EdgeTX/edgetx#7771) repeats the
same 9-line "common object properties" bullet list verbatim across
27+ widget-constructor luadoc comments, since there was no way to
define it once and reference it. Any future change to those shared
properties (as already happened once, for a version-citation fix)
requires touching every single occurrence.

Adds two new luadoc tags:

- `@common <name>` defines a reusable, non-callable chunk of luadoc
  body text. It is never treated as an API item -- no page, no nav
  entry, no hub-page card.
- `@commonparams <name>` used inside a `@function` block's parameter
  section textually splices in the matching `@common` block's body,
  before normal @param/@RetVal parsing runs. This works at the text
  level (not as a structured-parameter-array merge) because the
  existing convention documents each settings table as a single
  `@param params (table): * bullet * bullet ...` entry, not one
  @PARAM per field -- expansion has to happen before that bullet-list
  text becomes one flat description string.

extract_model() now does two passes: collect all @common definitions
first, then expand @commonparams references and parse @function
blocks as normal. Fails loudly (matching this project's own stated
design goal for the extractor) if a @commonparams reference points at
an undefined @common block; warns if a @common block is defined but
never referenced.

Also fixes a real, unrelated bug found while testing this against the
LVGL branch's actual content: FUNCTION_RE/PARAM_RE/RETVAL_RE/
NOTICE_RE/STATUS_RE all anchored `^@tag` at true column 0, but the
LVGL functions are indented 2 spaces (nested inside a table
registration block) -- every one of PR #7771's ~45 functions was
silently extracting zero parameters and "unknown" availability before
this fix. FUNCTION_RE itself didn't need the fix (extract_blocks()
already strips the whole block, so the first tag always lands at
column 0), but the rest do.

Verified: rendered Markdown and LuaLS output are byte-identical
before/after converting the LVGL branch to use @common/@commonparams
(the only differences across all changed files are source line
numbers, which genuinely shifted, and a generation timestamp).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015yCHydHbzZYCKpav38SonD
pfeerick added a commit to pfeerick/edgetx that referenced this pull request Sep 7, 2026
…arams

The 9-line "common object properties" bullet list (x, y, w, h, color,
pos, size, visible, floating) was repeated verbatim across all 27
widget-constructor luadoc comments in this file. A companion
doc-pipeline change (JimB40/lua-reference-guide#7) adds @common/
@commonparams luadoc tags specifically to eliminate this: define the
shared block once with @common, reference it from each widget with
@commonparams, and the extractor splices it back in at build time --
so generated documentation is unchanged, but a future edit to a
common property only needs to happen in one place.

Verified: re-extracting and re-rendering this file's content with the
new pipeline support produces output identical to before this refactor
(only source line numbers and a generation timestamp differ, both
expected side effects of inserting the new @common block).

Comment-only change, no behavior change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015yCHydHbzZYCKpav38SonD
@pfeerick

pfeerick commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by direct work on edgetx_2.12: the extraction-phase indentation fix and @common/@commonparams support from this PR were ported (not merged as-is, since this branch predated later work on that same branch — the page-path/generated-file-marker/dual-luals-output changes) in commit a408cce. See that commit message for the exact scope of what was and wasn't carried over.

@pfeerick pfeerick closed this Sep 8, 2026
pfeerick added a commit that referenced this pull request Sep 9, 2026
Ported from #7 (docs/common-param-support):
the four regexes anchored `^@tag` at true column 0, silently dropping
any tag line indented to match surrounding code style. Found while
investigating EdgeTX/edgetx#7771 (adds LVGL luadoc annotations, which
are indented 2 spaces inside their LROT_BEGIN table) -- every one of
that PR's ~45 functions was extracting zero parameters and "unknown"
availability before this fix.

Turns out this wasn't LVGL-specific: re-extracting the current 2.12
baseline with the fix (same 153 items, none added or lost) surfaced
two real, silent bugs already live on this site --
model.getSwashRing's availability was "unknown" instead of "2.8.0",
and playNumber was missing its `volume` parameter entirely. Both are
fixed by this rebuild.

Only the extraction-phase fix is ported here, not #7's build_outputs/
page-path changes -- that PR's branch was forked before this session's
nested-URL restructure and generated-file-marker work, and its diff
would have reverted both. The @common/@commonparams mechanism from
that PR (needed for EdgeTX/edgetx#7771's shared LVGL parameter blocks)
is included since it's purely additive at the extraction phase and
independent of page-path/output concerns.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HLXbKn4rY3NihRnqH89jmD
pfeerick added a commit that referenced this pull request Sep 9, 2026
Re-extracted from EdgeTX/edgetx branch 2.12 at 8718d2473a (the squash
merge of #7771, "add luadoc annotations for the LVGL Lua API"): 153 ->
198 items, all 45 real. The 44 hand-preserved flat lvgl-*.md pages
(ported from the official guide, since firmware had zero LVGL
annotations at all -- see prior HANDOFF.md entries) are replaced with
real nested display-lvgl/<item>.md pages generated the same way as
every other group now; the old flat files are removed, not left as
orphans.

Both #5 (the manual port) and #7 (the @common/@commonparams support
this depended on, already ported separately) on
JimB40/lua-reference-guide are closed as superseded by this.

docs-system/generated/api-model.local.json, REAL-EXTRACTION-NOTES.md
(both copies), and HANDOFF.md updated to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HLXbKn4rY3NihRnqH89jmD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant