-
Notifications
You must be signed in to change notification settings - Fork 44
refactor(wasm-sdk): improve documentation generation maintainability #2773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Extract test data, function mappings, and JavaScript generation into module-level constants and functions for better code organization and maintainability. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Split HTML generation into focused functions for sidebar, main content, and head sections to improve code organization and maintainability. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Remove generate_docs_css function and CSS file generation logic to simplify the Python script and improve maintainability. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Extract test runner JavaScript into a separate function to improve modularity and maintain clean separation of concerns. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Generate JavaScript function imports and window assignments dynamically from FUNCTION_NAME_MAP to reduce code duplication and improve maintainability. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
WalkthroughModularizes docs HTML/JS generation in packages/wasm-sdk/generate_docs.py, centralizes TESTNET_TEST_DATA and FUNCTION_NAME_MAP, dynamically exposes Wasm exports via generated JS, adds a hidden test runner, and removes embedded CSS generation. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Main as generate_docs.py:main()
participant Gen as HTML/JS Generators
participant FileSys as File System
participant Browser as Browser
participant Wasm as Wasm SDK Module
participant UI as Page UI
Main->>Gen: build components (head, preloader, sidebar, main content, user docs)
Main->>Gen: build docs JS (wasm imports + window.wasmFunctions, test runner JS)
Gen-->>Main: composed HTML + JS
Main->>FileSys: write docs.html (no docs.css)
Note over FileSys,Browser: Build-time output
Browser->>FileSys: load docs.html
Browser->>Wasm: import Wasm module via generated JS
Gen->>Browser: window.wasmFunctions populated (dynamic exports)
Browser->>UI: render sidebar and main content
UI->>Gen: triple-click header -> reveals test runner (runAllTests / runSingleTest)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks (3 passed)✅ Passed checks (3 passed)
Poem
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/wasm-sdk/generate_docs.py (1)
404-404
: Consider using unpacking for list concatenationWhile functionally correct, you could improve readability by using unpacking instead of concatenation.
- named_imports = ['WasmSdkBuilder'] + wasm_functions + additional_functions + named_imports = ['WasmSdkBuilder', *wasm_functions, *additional_functions]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/wasm-sdk/generate_docs.py
(9 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
packages/wasm-sdk/**/generate_docs.py
📄 CodeRabbit inference engine (packages/wasm-sdk/CLAUDE.md)
When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.
Files:
packages/wasm-sdk/generate_docs.py
packages/wasm-sdk/**
📄 CodeRabbit inference engine (CLAUDE.md)
Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK
Files:
packages/wasm-sdk/generate_docs.py
packages/**
📄 CodeRabbit inference engine (AGENTS.md)
Place all source packages under packages/* (JS/TS packages and Rust crates)
Files:
packages/wasm-sdk/generate_docs.py
🧠 Learnings (11)
📓 Common learnings
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-07T22:18:50.883Z
Learning: Applies to packages/wasm-sdk/** : Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK
Learnt from: thephez
PR: dashpay/platform#2754
File: packages/wasm-sdk/docs.html:1970-1971
Timestamp: 2025-09-03T14:42:29.958Z
Learning: In packages/wasm-sdk/, the docs.html file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in docs.html, as manual changes to docs.html would be overwritten during regeneration.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.
Learnt from: thephez
PR: dashpay/platform#2754
File: packages/wasm-sdk/AI_REFERENCE.md:766-766
Timestamp: 2025-09-03T14:41:16.196Z
Learning: In packages/wasm-sdk/, the AI_REFERENCE.md file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in AI_REFERENCE.md, as manual changes to AI_REFERENCE.md would be overwritten during regeneration.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: thephez
PR: dashpay/platform#2739
File: packages/wasm-sdk/test/ui-automation/tests/state-transitions.spec.js:1-171
Timestamp: 2025-09-02T13:30:17.703Z
Learning: In packages/wasm-sdk/index.html, state transition definitions are loaded dynamically from api-definitions.json rather than being hardcoded in the HTML file. The UI loads transition categories, types, inputs, and labels from this JSON configuration file.
Learnt from: QuantumExplorer
PR: dashpay/platform#2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
📚 Learning: 2025-09-03T14:42:29.958Z
Learnt from: thephez
PR: dashpay/platform#2754
File: packages/wasm-sdk/docs.html:1970-1971
Timestamp: 2025-09-03T14:42:29.958Z
Learning: In packages/wasm-sdk/, the docs.html file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in docs.html, as manual changes to docs.html would be overwritten during regeneration.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-09-03T14:41:16.196Z
Learnt from: thephez
PR: dashpay/platform#2754
File: packages/wasm-sdk/AI_REFERENCE.md:766-766
Timestamp: 2025-09-03T14:41:16.196Z
Learning: In packages/wasm-sdk/, the AI_REFERENCE.md file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in AI_REFERENCE.md, as manual changes to AI_REFERENCE.md would be overwritten during regeneration.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-09-07T22:18:50.883Z
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-07T22:18:50.883Z
Learning: Applies to packages/wasm-sdk/** : Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
PR: dashpay/platform#2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-08-14T15:03:56.681Z
Learnt from: thephez
PR: dashpay/platform#2726
File: packages/wasm-sdk/check_documentation.py:69-76
Timestamp: 2025-08-14T15:03:56.681Z
Learning: In packages/wasm-sdk/api-definitions.json, the structure is nested by categories: { "queries": { "categoryName": { "label": "...", "queries": { "actualQueryName": {...} } } } }. The check_documentation.py script correctly iterates over categories and then accesses the nested 'queries'/'transitions' objects within each category to collect the actual query/transition names.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-09-02T13:30:17.703Z
Learnt from: thephez
PR: dashpay/platform#2739
File: packages/wasm-sdk/test/ui-automation/tests/state-transitions.spec.js:1-171
Timestamp: 2025-09-02T13:30:17.703Z
Learning: In packages/wasm-sdk/index.html, state transition definitions are loaded dynamically from api-definitions.json via the loadApiDefinitions() function that fetches './api-definitions.json'. The UI doesn't have hardcoded transition definitions - instead it populates categories, types, inputs, and labels from this JSON configuration file at runtime.
Applied to files:
packages/wasm-sdk/generate_docs.py
🪛 Gitleaks (8.27.2)
packages/wasm-sdk/generate_docs.py
[high] 22-22: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
[high] 27-27: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
[high] 117-117: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🪛 Ruff (0.12.2)
packages/wasm-sdk/generate_docs.py
404-404: Consider iterable unpacking instead of concatenation
Replace with iterable unpacking
(RUF005)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build JS packages / Build JS
- GitHub Check: build-wasm-sdk
🔇 Additional comments (8)
packages/wasm-sdk/generate_docs.py (8)
13-87
: Excellent modularization with centralized constants!Moving test data and function mappings to module-level constants significantly improves maintainability by:
- Eliminating code duplication across example generation
- Creating a single source of truth for test values
- Making function name mappings easily discoverable and maintainable
108-110
: Good consolidation of test data referencesThe refactored parameter mapping now uses the centralized
TESTNET_TEST_DATA
dictionary, eliminating hardcoded values scattered throughout the codebase. This makes it much easier to update test values when needed.
203-210
: Clean function name mapping implementationThe simplified approach using
FUNCTION_NAME_MAP.get()
replaces the previous inline mapping blocks, reducing code duplication and improving consistency.
394-421
: Excellent dynamic function generation!The dynamic generation of function imports from
FUNCTION_NAME_MAP
is a major improvement:
- Eliminates ~100 lines of hardcoded function lists
- Automatically stays in sync with the function mappings
- Uses
list(dict.fromkeys(...))
to remove duplicates efficiently
652-856
: Well-structured test runner implementationThe extraction of the test runner JavaScript into its own function significantly improves code organization. The ~200 lines of inline JavaScript are now properly encapsulated, making the code much more maintainable.
857-973
: Excellent HTML generation modularization!Breaking down the monolithic HTML generation into focused functions (
generate_html_head
,generate_preloader_html
,generate_sidebar_html
,generate_main_content_html
) is a significant improvement:
- Each function has a single responsibility
- Components can be tested and modified independently
- The overall structure is much clearer
974-1012
: Clean composition of HTML componentsThe
generate_user_docs_html
function now clearly shows the document structure by composing the modular components. This makes the overall HTML structure much easier to understand and modify.
1329-1334
: Output unchanged as intendedThe refactoring successfully preserves the existing functionality - the generated docs.html output remains unchanged while the code is now much more maintainable. Great job ensuring backward compatibility!
Replace list concatenation with unpacking operators for cleaner Python code. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/wasm-sdk/generate_docs.py (1)
108-122
: Simplify parameter mapping with centralized test dataThe parameter mapping logic has been improved by using the centralized
TESTNET_TEST_DATA
, making the code more maintainable. However, some entries could be simplified to reduce conditional complexity.Consider simplifying some of the complex conditional parameter mappings:
- 'id': f"'{TESTNET_TEST_DATA['data_contract_history_id']}'" if 'getDataContractHistory' in query_key else f"'{TESTNET_TEST_DATA['data_contract_id']}'" if 'getDataContract' in query_key else f"'{TESTNET_TEST_DATA['identity_id']}'", + 'id': f"'{TESTNET_TEST_DATA.get(query_key + '_id', TESTNET_TEST_DATA['identity_id'])}'" if query_key not in ['getDataContractHistory', 'getDataContract'] else f"'{TESTNET_TEST_DATA['data_contract_history_id' if 'getDataContractHistory' in query_key else 'data_contract_id']}'",This would make the logic more readable and easier to maintain.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/wasm-sdk/generate_docs.py
(9 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
packages/wasm-sdk/**/generate_docs.py
📄 CodeRabbit inference engine (packages/wasm-sdk/CLAUDE.md)
When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.
Files:
packages/wasm-sdk/generate_docs.py
packages/wasm-sdk/**
📄 CodeRabbit inference engine (CLAUDE.md)
Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK
Files:
packages/wasm-sdk/generate_docs.py
packages/**
📄 CodeRabbit inference engine (AGENTS.md)
Place all source packages under packages/* (JS/TS packages and Rust crates)
Files:
packages/wasm-sdk/generate_docs.py
🧠 Learnings (12)
📓 Common learnings
Learnt from: thephez
PR: dashpay/platform#2754
File: packages/wasm-sdk/docs.html:1970-1971
Timestamp: 2025-09-03T14:42:29.958Z
Learning: In packages/wasm-sdk/, the docs.html file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in docs.html, as manual changes to docs.html would be overwritten during regeneration.
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-07T22:18:50.883Z
Learning: Applies to packages/wasm-sdk/** : Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.
Learnt from: thephez
PR: dashpay/platform#2754
File: packages/wasm-sdk/AI_REFERENCE.md:766-766
Timestamp: 2025-09-03T14:41:16.196Z
Learning: In packages/wasm-sdk/, the AI_REFERENCE.md file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in AI_REFERENCE.md, as manual changes to AI_REFERENCE.md would be overwritten during regeneration.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.
📚 Learning: 2025-09-03T14:42:29.958Z
Learnt from: thephez
PR: dashpay/platform#2754
File: packages/wasm-sdk/docs.html:1970-1971
Timestamp: 2025-09-03T14:42:29.958Z
Learning: In packages/wasm-sdk/, the docs.html file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in docs.html, as manual changes to docs.html would be overwritten during regeneration.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-09-07T22:18:50.883Z
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-07T22:18:50.883Z
Learning: Applies to packages/wasm-sdk/** : Keep WASM SDK docs in sync (run generate_docs.py) when updating the WASM SDK
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-09-03T14:41:16.196Z
Learnt from: thephez
PR: dashpay/platform#2754
File: packages/wasm-sdk/AI_REFERENCE.md:766-766
Timestamp: 2025-09-03T14:41:16.196Z
Learning: In packages/wasm-sdk/, the AI_REFERENCE.md file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in AI_REFERENCE.md, as manual changes to AI_REFERENCE.md would be overwritten during regeneration.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
PR: dashpay/platform#2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : Token functions are methods on WasmSdk, not standalone functions; avoid importing them as standalone.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : When implementing WASM SDK functionality, always refer to AI_REFERENCE.md first for accurate method signatures and examples.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-08-14T15:03:56.681Z
Learnt from: thephez
PR: dashpay/platform#2726
File: packages/wasm-sdk/check_documentation.py:69-76
Timestamp: 2025-08-14T15:03:56.681Z
Learning: In packages/wasm-sdk/api-definitions.json, the structure is nested by categories: { "queries": { "categoryName": { "label": "...", "queries": { "actualQueryName": {...} } } } }. The check_documentation.py script correctly iterates over categories and then accesses the nested 'queries'/'transitions' objects within each category to collect the actual query/transition names.
Applied to files:
packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-09-02T13:30:17.703Z
Learnt from: thephez
PR: dashpay/platform#2739
File: packages/wasm-sdk/test/ui-automation/tests/state-transitions.spec.js:1-171
Timestamp: 2025-09-02T13:30:17.703Z
Learning: In packages/wasm-sdk/index.html, state transition definitions are loaded dynamically from api-definitions.json via the loadApiDefinitions() function that fetches './api-definitions.json'. The UI doesn't have hardcoded transition definitions - instead it populates categories, types, inputs, and labels from this JSON configuration file at runtime.
Applied to files:
packages/wasm-sdk/generate_docs.py
🪛 Gitleaks (8.27.2)
packages/wasm-sdk/generate_docs.py
[high] 22-22: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
[high] 27-27: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
[high] 117-117: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build JS packages / Build JS
- GitHub Check: build-wasm-sdk
🔇 Additional comments (8)
packages/wasm-sdk/generate_docs.py (8)
13-86
: LGTM - Excellent refactoring with centralized data managementThis refactor significantly improves maintainability by centralizing test data and function mappings at the module level. The extracted constants make it much easier to maintain and update test values and API-to-SDK function mappings in one place.
394-421
: Well-structured dynamic JavaScript generationThe new
generate_docs_javascript()
function is excellently designed. It dynamically generates the required JavaScript imports and window assignments from the centralizedFUNCTION_NAME_MAP
, eliminating the need for manual maintenance of function lists.
652-855
: Comprehensive test runner implementationThe hidden test runner feature is well-implemented with proper UI management, error handling, and triple-click activation. This will be very useful for automated testing of the documentation examples.
857-983
: Excellent modular HTML generation approachThe new modular approach to HTML generation significantly improves code maintainability by breaking down the monolithic HTML generation into focused, reusable functions. Each function has a clear single responsibility.
22-27
: False positive: These are test data identifiers, not API keysThe static analysis tool is flagging testnet identifiers as potential API keys, but these are actually public testnet data contract IDs and transaction hashes used for testing purposes. These values are meant to be public and are safe to include in the codebase.
117-117
: False positive: This is a testnet token ID, not an API keyThis is a testnet token ID used for testing purposes, not a sensitive API key. The value is meant to be public and is safe to include in the documentation.
1329-1334
: Restore/add docs.css or update HTML reference
- packages/wasm-sdk/generate_docs.py:864 contains
<link rel="stylesheet" href="docs.css">
but no docs.css file was found in the repo; add the stylesheet (or re-enable generation) or update the href to the correct path so generated docs.html has CSS.
203-204
: Verify centralized function mapping works correctlyAll query_key comparisons found in the repo (8 unique keys) have corresponding entries in FUNCTION_NAME_MAP; no missing mappings. FUNCTION_NAME_MAP contains 50 entries total, 42 of which are not referenced by those comparisons.
Issue being fixed or feature implemented
This PR refactors the WASM SDK documentation generator (
generate_docs.py
) to improve maintainability and reduce code duplication. The main focus is on modularizing the HTML/JavaScript generation and eliminating redundant code.What was done?
docs.css
already exists as a separate fileFUNCTION_NAME_MAP
, removing ~100 lines of duplicate function listsNote: All existing features remain intact and the docs.html file output is unchanged (thus no docs.html or manifest changes in the PR)
How Has This Been Tested?
Ran updated
generate_docs.py
locally and confirmed the docs.html output remained unchangedBreaking Changes
None
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
New Features
Documentation
Chores