Summary
Add comprehensive JSDoc annotations to the AutobahnJS source code to enable:
Auto-generated API documentation via sphinx-js
TypeScript .d.ts type definition generation (Track A from AutobahnJS v26.1.1 Release #595 )
Background
The v26.1.1 documentation infrastructure uses Sphinx with the Furo theme, deployed to GitHub Pages. We initially planned to use sphinx-js for auto-generated JavaScript API documentation, but this requires JSDoc annotations in the source code.
Currently, the AutobahnJS codebase has minimal JSDoc comments. The docs/api/index.rst was converted to a manual API reference as a workaround (see commit 39e4f18 ).
Relationship to Track A: Type Definitions (#595 )
JSDoc annotations are a prerequisite for Track A.
From #595 , Track A's approach is:
Generate .d.ts type definition files from existing code
Add JSDoc type annotations where missing
Configure TypeScript in checkJs mode for validation
Do NOT rewrite codebase in TypeScript (high risk)
JSDoc annotations serve dual purposes :
Purpose
Tool
Benefit
API Documentation
sphinx-js
Auto-generated docs from source
Type Definitions
TypeScript (tsc --declaration)
Generate .d.ts files from JSDoc
Static Analysis
TypeScript (checkJs mode)
Type checking without migration
By adding JSDoc annotations, we enable both goals with a single effort:
sphinx-js reads JSDoc to generate Sphinx documentation
TypeScript reads JSDoc to generate .d.ts type definitions
TypeScript can validate types in CI without converting to .ts files
Scope
Files to Annotate
Priority 1: Public API (packages/autobahn/lib/)
connection.js — Connection class, options, callbacks
session.js — Session class, RPC/PubSub methods
autobahn.js — Main exports
serializer.js — Serializer classes
auth_cra.js — WAMP-CRA authentication
Priority 2: Internal Classes
transport/websocket.js — WebSocket transport
transport/rawsocket.js — RawSocket transport
util.js — Utility functions
log.js — Logging
Priority 3: XBR Extension (packages/autobahn-xbr/lib/)
autobahn-xbr.js — XBR exports
buyer.js, seller.js — Market participants
eip712.js — Ethereum signing
JSDoc Coverage Required
/**
* Manages WebSocket connection and WAMP session lifecycle.
* @class
* @param {Object } options - Connection options
* @param {string } options.url - WebSocket URL (e.g., 'ws://localhost:8080/ws')
* @param {string } options.realm - WAMP realm to join
* @param {string[] } [options.authmethods] - Authentication methods
* @param {string } [options.authid] - Authentication ID
* @param {Function } [options.onchallenge] - Challenge callback
* @param {number } [options.max_retries=15] - Maximum reconnection attempts
* @example
* const connection = new autobahn.Connection({
* url: 'ws://localhost:8080/ws',
* realm: 'realm1'
* });
*/
function Connection ( options ) {
// ...
}
/**
* Open the connection to the WAMP router.
* @returns {void }
*/
Connection . prototype . open = function ( ) {
// ...
} ;
Implementation Plan
Phase 1: Core Public API
Annotate Connection class with all options
Annotate Session class with RPC/PubSub methods
Annotate serializer classes
Annotate authentication functions
Re-enable sphinx-js in docs/conf.py
Verify docs build with auto-generated API
Phase 2: Type Definition Generation
Add tsconfig.json with allowJs, checkJs, declaration options
Run tsc --declaration to generate .d.ts files
Add .d.ts files to npm package
Add TypeScript validation to CI
Phase 3: Internal Classes & XBR
Annotate transport classes
Annotate utility functions
Annotate XBR extension classes
Acceptance Criteria
References
Target
v26.2.1 or later — This is foundational work that enables both improved documentation and Track A type definitions.
Summary
Add comprehensive JSDoc annotations to the AutobahnJS source code to enable:
.d.tstype definition generation (Track A from AutobahnJS v26.1.1 Release #595)Background
The v26.1.1 documentation infrastructure uses Sphinx with the Furo theme, deployed to GitHub Pages. We initially planned to use sphinx-js for auto-generated JavaScript API documentation, but this requires JSDoc annotations in the source code.
Currently, the AutobahnJS codebase has minimal JSDoc comments. The
docs/api/index.rstwas converted to a manual API reference as a workaround (see commit 39e4f18).Relationship to Track A: Type Definitions (#595)
JSDoc annotations are a prerequisite for Track A.
From #595, Track A's approach is:
JSDoc annotations serve dual purposes:
tsc --declaration).d.tsfiles from JSDoccheckJsmode)By adding JSDoc annotations, we enable both goals with a single effort:
.d.tstype definitions.tsfilesScope
Files to Annotate
Priority 1: Public API (packages/autobahn/lib/)
connection.js— Connection class, options, callbackssession.js— Session class, RPC/PubSub methodsautobahn.js— Main exportsserializer.js— Serializer classesauth_cra.js— WAMP-CRA authenticationPriority 2: Internal Classes
transport/websocket.js— WebSocket transporttransport/rawsocket.js— RawSocket transportutil.js— Utility functionslog.js— LoggingPriority 3: XBR Extension (packages/autobahn-xbr/lib/)
autobahn-xbr.js— XBR exportsbuyer.js,seller.js— Market participantseip712.js— Ethereum signingJSDoc Coverage Required
Implementation Plan
Phase 1: Core Public API
Connectionclass with all optionsSessionclass with RPC/PubSub methodsdocs/conf.pyPhase 2: Type Definition Generation
tsconfig.jsonwithallowJs,checkJs,declarationoptionstsc --declarationto generate.d.tsfiles.d.tsfiles to npm packagePhase 3: Internal Classes & XBR
Acceptance Criteria
.d.tsfiles from JSDoctsc --checkJspasses in CI.d.tstype definitionsReferences
Target
v26.2.1 or later — This is foundational work that enables both improved documentation and Track A type definitions.