RDKDEV-1701 Add ThunderTools Documentation. - #330
gourivarma3 wants to merge 1 commit into
Conversation
Add comprehensive documentation for ThunderTools, detailing its features, design, threading model, configuration, and testing procedures.
There was a problem hiding this comment.
🟡 Changes recommended
Documentation contains multiple inaccurate tool, API, and build descriptions, plus a missing ignore rule.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds comprehensive ThunderTools documentation covering generators, configuration, architecture, and testing.
Changes:
- Documents generator responsibilities and workflows.
- Describes threading, lifecycle, and component interactions.
- Adds configuration and functional testing guidance.
File summaries
| File | Description |
|---|---|
docs/README.md |
Adds ThunderTools documentation and usage guidance. |
Review details
Suppressed comments (23)
docs/README.md:157
- This says every output is conditionally written, but
code_generator.CreateApiHeader()anddocumentation_generator.Create()do not perform an mtime check; they rewrite their files on every invocation. Please distinguish code artifacts from the documentation and combined API header.
The flow below shows JsonGenerator producing C++ JSON data classes and JSON-RPC dispatch code from a single interface definition file. Each output artifact is written only if the input is newer than the existing output.
docs/README.md:281
- This describes a transactional emitter, but the implementation opens/truncates output before emission and flushes accumulated lines from
__exit__even when the body raises;StubGeneratorwrites directly to an already-open file, and ConfigGenerator/PluginSkeletonGenerator write directly. A failure can therefore leave a partial output file, so it should not be documented as avoiding partial output.
- **Code Emission Strategy**: All generators write through the `Emitter` class. `Emitter` accumulates lines in memory, applies indentation, and wraps long lines at commas before flushing to disk on context-manager exit. This ensures that generated files are only written if generation succeeds, avoiding partial output on failure.
docs/README.md:283
- The mtime check is not performed before every output: it exists for JsonGenerator's code artifacts and ProxyStubGenerator's generated
.cppfile, while documentation, combined API headers, ConfigGenerator, and PluginSkeletonGenerator write without this guard. Please narrow this statement and the--forcescope to generators that implement it.
- **Incremental Build Optimisation**: Before writing any output file, generators compare the modification time of the output against the input source. If the output is newer, the generator logs a skip message and continues to the next file. The `--force` flag disables this check.
docs/README.md:39
- The statement generalizes incremental behavior to every generator, but only JsonGenerator and ProxyStubGenerator implement per-output modification-time checks;
write_config()executes during CMake configure and PluginSkeletonGenerator does not track outputs. Please scope this claim to the generators that actually implement it.
Each generator invocation reads its inputs, produces outputs, and exits. Build-system dependency tracking handles incremental regeneration, avoiding redundant runs when output artifacts are already up to date.
docs/README.md:285
ENABLE_SECUREis not the switch for frame integrity/coherency:--secureenables instance and range verification, whereas--coherentsetsENABLE_INTEGRITY_VERIFICATION. Saying thatENABLE_SECUREcovers all three checks can mislead users about which generated checks are enabled.
- **Security and Verification in ProxyStubGenerator**: Optional checks controlled by `ENABLE_SECURE` (default `False`) cover instance identity verification, parameter range validation, and frame integrity. When enabled, the generated stub emits `ASSERT()` or error-return guards around the corresponding checks.
docs/README.md:287
- The listed error policy is not shared by every generator, and the exit code is not an error count: JsonGenerator continues after per-input errors and exits with
1if any were recorded, while ConfigGenerator exits immediately on configuration errors and ProxyStubGenerator returns1when its log contains errors. Please describe these as component-specific policies.
- **Error Handling Strategy**: Each generator catches typed exceptions (`JsonParseError`, `CppParseError`, `RPCEmitterError`, `IOError`, `JsonRefError`) at the per-file loop level, logs the error, and continues processing remaining files. The overall exit code reflects the count of errors encountered.
docs/README.md:302
- This CMake option only enables instance/range verification; frame-integrity/coherency is controlled separately by
PROXYSTUB_GENERATOR_ENABLE_COHERENCY(which adds--coherent). The row currently promises a check that is not enabled by the named option.
| `PROXYSTUB_GENERATOR_ENABLE_SECURITY` | bool | `OFF` | When `ON`, enables instance-identity verification, parameter-range checks, and frame-integrity checks in all generated proxy stub files. |
docs/README.md:361
- These targets are conditional, not always both produced:
ENABLE_COM_RPC_TESTSandENABLE_JSON_RPC_TESTSindependently gate the twoadd_subdirectory()calls, so one or both executables may be absent. Please say "up to two" or otherwise describe the independent gating.
Two executables are produced, controlled by `ENABLE_COM_RPC_TESTS` and `ENABLE_JSON_RPC_TESTS`:
docs/README.md:274
- This repeats the same reset-scope error:
enum_trackerresets once per input path, butobject_trackerresets for each schema returned from that path. Please align this implementation summary with the actual loop structure and the state-flow description above.
- **State / Lifecycle Management**: Each generator invocation is self-contained. The per-file `EnumTracker` and `ObjectTracker` are reset at the start of each input file, preventing symbol definitions from one interface from affecting the generated code for another.
docs/README.md:35
- The installed CMake modules expose
JsonGenerator(),ProxyStubGenerator(), andwrite_config(); there is noConfigGenerator()helper. Also, PluginSkeletonGenerator and DocumentGenerator are not exposed through these CMake functions. As written, the paragraph overstates the common API and gives a nonexistent helper name.
All generators expose their options both through command-line arguments (for standalone use) and through CMake helper functions (`JsonGenerator()`, `ProxyStubGenerator()`, `ConfigGenerator()`) installed alongside the scripts. This dual interface means developers can invoke generators manually during prototyping while the build system drives them reproducibly during compilation.
docs/README.md:3
- Only the generated C++ headers/sources are compiled into Thunder plugins; configuration JSON is consumed at startup and Markdown documentation is not compiled. Referring to all of the listed artifacts as being compiled into plugins is misleading, so please scope this statement to generated C++ artifacts.
ThunderTools is a collection of host-native, build-time code generation and validation tools for the Thunder (WPEFramework) middleware stack. It is invoked by the build system to produce C++ source artifacts, configuration files, plugin skeletons, and reference documentation from annotated C++ headers and JSON-schema definitions. These generated artifacts are compiled into Thunder plugins and represent a prerequisite step before any Thunder plugin can be built. Alongside the generators, it also provides AI-assisted plugin/interface review and a functional test suite that validate generator output and plugin quality.
docs/README.md:25
- The input description is too broad for the whole toolset: ConfigGenerator consumes Python config scripts, PluginSkeletonGenerator consumes headers plus prompts/CLI options, DocumentGenerator consumes repository/branch arguments, and binalyzer consumes binaries. Please scope the C++/JSON pipeline description to the relevant code generators.
ThunderTools follows a pipeline design: each generator accepts a well-defined input format (C++ header or JSON schema), produces a deterministic output artifact, and is stateless between invocations. Generators are Python 3 scripts, each running in an isolated process context, and can be parallelized at the CMake level by invoking them as separate processes for each interface file.
docs/README.md:206
ObjectTrackeris reset per schema inJsonGenerator.py, not once per complete input file, so it does not deduplicate object definitions across multiple schemas emitted from one header. The table should describe the tracker scope consistently with the lifecycle sections.
| `trackers` | Provides `ObjectTracker` and `EnumTracker` singletons that de-duplicate C++ object and enum type definitions across a single input file to avoid redundant class emissions. | `JsonGenerator/source/trackers.py` |
docs/README.md:212
PluginSkeletonGeneratordoes not import this module and reports through direct console output, soLog.pyis not shared by all generators listed in this document (the same overbroad claim is repeated in the logging section). Please scope the description to the components that actually use it.
| `Log` | Shared logging module for all generators. Supports verbose, warning, and doc-issue severity levels. | `ProxyStubGenerator/Log.py` |
docs/README.md:289
- This repeats the overbroad
Logclaim: PluginSkeletonGenerator and ThunderDevTools use direct console output rather thanProxyStubGenerator/Log.py. The logger description should name only the components that actually reuse it and distinguish their supported options.
- **Logging & Diagnostics**: All generators share the `Log` class from `ProxyStubGenerator/Log.py`. The logger supports three verbosity levels: standard, verbose (`--verbose`), and warnings-silenced (`--no-warnings`). A separate `--no-style-warnings` flag limits output to substantive errors only, suppressing style-convention notices.
docs/README.md:221
- The repository does not currently ignore
PluginQualityAdvisor/Exemptions/*.local.yaml: the root.gitignoreonly covers.vscode,*.pyc, and Lua output. These personal exemption files can therefore be committed accidentally, contrary to this documentation; add an ignore rule (and keep the docs aligned).
| `exempt_manager` | Standalone, dependency-free CLI (stdlib only) for managing local rule exemptions used by the PluginQualityAdvisor review prompts. Reads rule IDs from the YAML rule catalogs and reads/writes the git-ignored local exemption files. | `PluginQualityAdvisor/exempt_manager.py` |
docs/README.md:130
--forcedoes not regenerate all artifacts: it bypasses the mtime checks used for supported JsonGenerator C++ outputs and ProxyStubGenerator stubs, but documentation, the combined API header, ConfigGenerator output, and PluginSkeletonGenerator output do not use this check.
- If the `--force` flag is passed, the modification-time check is bypassed and all artifacts are regenerated unconditionally.
docs/README.md:25
- The installed CMake helpers do not launch generator invocations in parallel:
FindJsonGenerator.cmakeandFindProxyStubGenerator.cmakeiterate inputs and callexecute_processsynchronously. Please qualify this as caller-managed parallelism; otherwise the documented threading/build behavior is misleading.
ThunderTools follows a pipeline design: each generator accepts a well-defined input format (C++ header or JSON schema), produces a deterministic output artifact, and is stateless between invocations. Generators are Python 3 scripts, each running in an isolated process context, and can be parallelized at the CMake level by invoking them as separate processes for each interface file.
docs/README.md:289
- The shared logger's
--no-style-warningsoption controlsLog.DocIssue()output (documentation issues), not a general class of style-convention warnings. This wording can make users believe substantive style diagnostics are being filtered.
- **Logging & Diagnostics**: All generators share the `Log` class from `ProxyStubGenerator/Log.py`. The logger supports three verbosity levels: standard, verbose (`--verbose`), and warnings-silenced (`--no-warnings`). A separate `--no-style-warnings` flag limits output to substantive errors only, suppressing style-convention notices.
docs/README.md:297
ENABLE_TESTINGis a top-level option used only to gateadd_subdirectory(tests); it is not substituted into or installed through the generator find modules. Split this from the generator flags so the configuration guidance matchesCMakeLists.txt.
The following CMake options are set at configure time and baked into the generator CMake find modules installed alongside the scripts.
docs/README.md:315
--forceis not a common option for all generators and does not mean that every output type is unconditionally regenerated. In particular, it applies to the code-generation mtime checks in JsonGenerator and ProxyStubGenerator.
| `--force` | flag | off | Bypass modification-time check and regenerate all output files unconditionally. |
docs/README.md:368
- The CMake target is
ComRpcFunctionalTests, notProxyStubFunctionalTests; the latter does not exist in the functional-test project. Rename this Mermaid node so the diagram points to the buildable target.
subgraph ComRpcTests["ProxyStubFunctionalTests"]
docs/README.md:87
- This repeats the inaccurate claim that the build system itself supplies parallelism. The CMake find helpers invoke each input synchronously; parallel execution is only possible when an external caller or build graph schedules independent generator processes concurrently.
- **Threading Architecture**: Single-threaded per generator invocation. Each generator script is an independent OS process; parallelism is achieved by the build system launching multiple generator processes simultaneously.
- Files reviewed: 1/1 changed files
- Comments generated: 11
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| - **JsonGenerator**: Parses annotated C++ interface headers and JSON-schema definition files to produce JSON data-class headers (`JsonData_<Name>.h`), enum-registration translation units (`JsonEnum_<Name>.cpp`), JSON-RPC dispatch headers (`J<Name>.h`), combined API headers, and Markdown reference documentation for each plugin interface. | ||
| - **ProxyStubGenerator**: Parses C++ interface headers that declare COM-RPC interfaces and emits the corresponding proxy and stub implementation files (`ProxyStubs_<Name>.cpp`) that the Thunder COM-RPC transport layer uses to marshal calls across process boundaries. | ||
| - **ConfigGenerator**: Reads Python-based plugin configuration scripts and produces the JSON configuration files (`<Plugin>.json`) consumed by the Thunder plugin host at startup. | ||
| - **PluginSkeletonGenerator**: Generates a complete, ready-to-compile plugin repository scaffold—header, source, CMakeLists, conf-in, and JSON schema—from a user-supplied interface header and a small set of interactive prompts or a YAML configuration file. |
| Within a single invocation, each input file is processed independently. The generator resets its internal tracking structures—enum tracker and object tracker—before each file, ensuring that generated artifacts for one interface are independent of those for another. | ||
|
|
||
| **State Change Triggers:** | ||
|
|
||
| - Each input file resets the enum and object de-duplication trackers, keeping cross-file symbol definitions isolated to their respective input files. |
| **State Change Triggers:** | ||
|
|
||
| - Each input file resets the enum and object de-duplication trackers, keeping cross-file symbol definitions isolated to their respective input files. | ||
| - If an input file is already up-to-date relative to its output (by file modification time), the generator skips emission and logs a "skipping file, up-to-date" message. This is the only conditional branching in the per-file state. |
| | `exempt_manager` | Standalone, dependency-free CLI (stdlib only) for managing local rule exemptions used by the PluginQualityAdvisor review prompts. Reads rule IDs from the YAML rule catalogs and reads/writes the git-ignored local exemption files. | `PluginQualityAdvisor/exempt_manager.py` | | ||
| | `setup-prompts` | Detects the absolute path of the `PluginQualityAdvisor/Prompts` folder and registers it under `chat.promptFilesLocations` in the user's VS Code `settings.json`, disabling any previously registered PluginQualityAdvisor path to avoid slash-command collisions. | `PluginQualityAdvisor/setup-prompts.py` | | ||
| | `ComRpcServer` / `TestHarness<IF>` | COM-RPC functional test harness: a server exposing generated stubs over a Unix domain socket, paired with a per-interface client fixture that opens a generated proxy and drives it through GoogleTest cases. | `tests/FunctionalTests/comrpc/` | | ||
| | `JsonRpcServer` / `JsonRpcTestHarness<IF>` | JSON-RPC functional test harness: an in-process `PluginHost::JSONRPC` server built on `Test::JsonRPCRegister`, invoked directly via `JSONRPC::Invoke()` to validate generated `J<Interface>` dispatch code without a network transport. | `tests/FunctionalTests/jsonrpc/` | |
| | ------------------- | ------ | ----------- | ---------------------------------------------------------------------------------------------- | | ||
| | `--code` | flag | off | Emit C++ JSON data classes and JSON-RPC dispatch headers. | | ||
| | `--docs` | flag | off | Emit Markdown reference documentation. | | ||
| | `--format` | string | `compliant` | JSON-RPC format: `compliant`, `uncompliant-extended`, or `uncompliant-collapsed`. | |
| | `--coherent` | flag | off | Enable frame coherency checks in generated stubs (ProxyStubGenerator). | | ||
| | `--force` | flag | off | Bypass modification-time check and regenerate all output files unconditionally. | | ||
| | `--no-versioning` | flag | off | Suppress generation of the `J<Name>.h` version header. | | ||
| | `--case-convention` | string | `standard` | Naming convention applied to generated identifiers: `standard`, `legacy`, `keep`, or `custom`. | |
|
|
||
| Two executables are produced, controlled by `ENABLE_COM_RPC_TESTS` and `ENABLE_JSON_RPC_TESTS`: | ||
|
|
||
| - **`ProxyStubFunctionalTests`** runs a COM-RPC server and client in the same process over a Unix domain socket. `ComRpcServer` (an `RPC::Communicator`) resolves interface implementations through a static factory registry (`ImplementationRegistrar<INTERFACE, IMPL>`); each `TestHarness<IF>` fixture opens a generated proxy over `RPC::CommunicatorClient` and drives it with GoogleTest cases, exercising the full proxy-serialize / transport / stub-deserialize / implementation / return path. |
| Two executables are produced, controlled by `ENABLE_COM_RPC_TESTS` and `ENABLE_JSON_RPC_TESTS`: | ||
|
|
||
| - **`ProxyStubFunctionalTests`** runs a COM-RPC server and client in the same process over a Unix domain socket. `ComRpcServer` (an `RPC::Communicator`) resolves interface implementations through a static factory registry (`ImplementationRegistrar<INTERFACE, IMPL>`); each `TestHarness<IF>` fixture opens a generated proxy over `RPC::CommunicatorClient` and drives it with GoogleTest cases, exercising the full proxy-serialize / transport / stub-deserialize / implementation / return path. | ||
| - **`JsonRpcFunctionalTests`** validates `JsonGenerator` output by invoking `PluginHost::JSONRPC::Invoke()` directly against a `JsonRpcServer` (built on `Test::JsonRPCRegister`) attached to a real `IShell`, with no network transport involved. Implementations are shared with the COM-RPC tests and registered through one-line lambda-based static registrars. |
| Client <--> Socket <--> Server | ||
| end | ||
| subgraph JsonRpcTests["JsonRpcFunctionalTests"] | ||
| JClient["JsonRpcTestHarness<IF>"] |
| end | ||
| ``` | ||
|
|
||
| Known limitations are tracked directly in the test suite: `@restrict` violations trigger a stub-side `ASSERT()` rather than a graceful error return; iterator-passing tests insert a fixed sleep to avoid a COM-RPC channel deadlock when draining `RPC::IStringIterator`/`IValueIterator`; and several IDL patterns are commented out with `FIXME` markers where the generators currently produce invalid or non-compiling output, representing open issues against `ProxyStubGenerator` and `JsonGenerator`. |
RDKDEV-1701
Add comprehensive documentation for ThunderTools, detailing its features, design, threading model, configuration, and testing procedures.
Reason for Change:
To add Component Documentation for Thundertools.
Fix:
Added the documentation
Signed-off-by: gourivarma3