@@ -476,6 +476,17 @@ function generateCode() {
476476 const lines : string [ ] = [ ] ;
477477
478478 for ( const prop of structure . properties ) {
479+ // Add property documentation if it exists
480+ if ( prop . documentation ) {
481+ const propDoc = formatDocumentation ( prop . documentation ) ;
482+ if ( propDoc ) {
483+ // Add the documentation with proper indentation
484+ for ( const line of propDoc . split ( "\n" ) . filter ( l => l ) ) {
485+ lines . push ( `${ indent } ${ line } ` ) ;
486+ }
487+ }
488+ }
489+
479490 const type = resolveType ( prop . type ) ;
480491
481492 // For reference types that are structures, use a named resolved type
@@ -553,7 +564,30 @@ function generateCode() {
553564 // Main function is exported, helpers are unexported
554565 const funcName = isMain ? `Resolve${ structure . name } ` : `resolve${ structure . name } ` ;
555566
556- // Generate the resolved type
567+ // Generate the resolved type with documentation
568+ if ( ! isMain ) {
569+ // For non-main types, add standard documentation header
570+ if ( structure . documentation ) {
571+ const typeDoc = formatDocumentation ( structure . documentation ) ;
572+ if ( typeDoc ) {
573+ // Prepend comment explaining this is the resolved version
574+ lines . push ( `// ${ typeName } is a resolved version of ${ structure . name } with all optional fields` ) ;
575+ lines . push ( `// converted to non-pointer values for easier access.` ) ;
576+ lines . push ( `//` ) ;
577+ // Add the original structure documentation
578+ for ( const line of typeDoc . split ( "\n" ) . filter ( l => l ) ) {
579+ lines . push ( line ) ;
580+ }
581+ }
582+ }
583+ else {
584+ // If no documentation, just add a basic comment
585+ lines . push ( `/ / ${typeName } is a resolved version of ${structure . name } with all optional fields `);
586+ lines.push(` // converted to non-pointer values for easier access.`);
587+ }
588+ }
589+ // For main type, documentation is added separately before calling this function
590+
557591 lines . push ( `type ${ typeName } struct {` ) ;
558592 lines . push ( ...generateResolvedStruct ( structure , "\t" ) ) ;
559593 lines . push ( `}` ) ;
@@ -1037,6 +1071,13 @@ function generateCode() {
10371071 writeLine ( "// ResolvedClientCapabilities is a version of ClientCapabilities where all nested" ) ;
10381072 writeLine ( "// fields are values (not pointers), making it easier to access deeply nested capabilities." ) ;
10391073 writeLine ( "// Use ResolveClientCapabilities to convert from ClientCapabilities." ) ;
1074+ if ( clientCapsStructure . documentation ) {
1075+ writeLine ( "//" ) ;
1076+ const typeDoc = formatDocumentation ( clientCapsStructure . documentation ) ;
1077+ for ( const line of typeDoc . split ( "\n" ) . filter ( l => l ) ) {
1078+ writeLine ( line ) ;
1079+ }
1080+ }
10401081 const mainLines = generateResolvedTypeAndHelper ( clientCapsStructure , true ) ;
10411082 for ( const line of mainLines ) {
10421083 writeLine ( line ) ;
0 commit comments