Skip to content

Conversation

thephez
Copy link
Collaborator

@thephez thephez commented Sep 11, 2025

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?

  • Extracted HTML components (head, preloader, sidebar, main content) into separate functions for better organization
  • Removed ~480 lines of inline CSS generation since docs.css already exists as a separate file
  • Dynamically generate function imports from FUNCTION_NAME_MAP, removing ~100 lines of duplicate function lists
  • Moved ~200 lines of inline test runner JavaScript into its own function
  • Extracted test data and function mappings to module-level constants for better maintainability

Note: 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 unchanged

Breaking Changes

None

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Docs site now exposes SDK functions dynamically and includes a hidden test runner (revealed via triple-click) for running examples.
  • Documentation

    • Full rewrite of docs generation into modular components (head, preloader, sidebar, main content, scripts).
    • Example snippets now use consistent standardized testnet data.
  • Chores

    • Embedded CSS generation removed; styling handled externally.

thephez and others added 5 commits September 11, 2025 11:20
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>
@thephez thephez added this to the v2.1 milestone Sep 11, 2025
Copy link
Contributor

coderabbitai bot commented Sep 11, 2025

Walkthrough

Modularizes 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

Cohort / File(s) Summary
Wasm SDK docs generator
packages/wasm-sdk/generate_docs.py
- Added module-level constants TESTNET_TEST_DATA and FUNCTION_NAME_MAP.
- Replaced inline function-name mapping and local test data usage with centralized constants.
- Added generate_docs_javascript() to import/expose Wasm exports (deduped, includes prefetch_trusted_quorums_testnet handling).
- Added generate_test_runner_javascript() for hidden test-runner UI and handlers (triple-click activation).
- Broke HTML generation into components: generate_html_head(), generate_preloader_html(), generate_sidebar_html(), generate_main_content_html(), generate_user_docs_html().
- Removed generate_docs_css() and stopped writing docs.css from main().
- Kept AI reference and docs manifest generation while switching to modular pipeline.

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)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • QuantumExplorer
  • pauldelucia

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "refactor(wasm-sdk): improve documentation generation maintainability" concisely identifies the scope (wasm-sdk) and the primary intent (refactor to improve documentation generation maintainability), which matches the PR’s described changes to generate_docs.py and the stated objectives. It is specific, clear, and suitable for a PR/commit history summary.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Poem

In burrows of code I hop and prance,
Mapping names and building a glance.
Tests tucked hidden, triple-click to play,
Wasm functions dance, exported today.
A rabbit's nudge — docs now modular, hooray! 🐇✨

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wasm-sdk-doc-generator-refactor

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 concatenation

While 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

📥 Commits

Reviewing files that changed from the base of the PR and between b7550d2 and 976149f.

📒 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:

  1. Eliminating code duplication across example generation
  2. Creating a single source of truth for test values
  3. Making function name mappings easily discoverable and maintainable

108-110: Good consolidation of test data references

The 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 implementation

The 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 implementation

The 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 components

The 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 intended

The 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>
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 data

The 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

📥 Commits

Reviewing files that changed from the base of the PR and between 976149f and 4d0e766.

📒 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 management

This 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 generation

The new generate_docs_javascript() function is excellently designed. It dynamically generates the required JavaScript imports and window assignments from the centralized FUNCTION_NAME_MAP, eliminating the need for manual maintenance of function lists.


652-855: Comprehensive test runner implementation

The 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 approach

The 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 keys

The 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 key

This 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 correctly

All 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.

@QuantumExplorer QuantumExplorer merged commit 443afaf into v2.1-dev Sep 11, 2025
18 of 22 checks passed
@QuantumExplorer QuantumExplorer deleted the wasm-sdk-doc-generator-refactor branch September 11, 2025 21:01
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.

2 participants