@@ -107,13 +107,48 @@ async function printSingleCapability(info: CapabilityInformation, depth: number,
107
107
return nextLine ? `${ mainLine } \\\n${ nextLineIndent } ${ nextLine } ` : mainLine ;
108
108
}
109
109
110
+ interface ChildrenSummary {
111
+ total : number ;
112
+ fully : number ;
113
+ partially : number ;
114
+ not : number ;
115
+ }
116
+
117
+ function summarizeChildren ( capabilities : readonly FlowrCapability [ ] ) : ChildrenSummary {
118
+ const summary : ChildrenSummary = { total : 0 , fully : 0 , partially : 0 , not : 0 } ;
119
+ for ( const capability of capabilities ) {
120
+ if ( capability . capabilities ) {
121
+ const childSummary = summarizeChildren ( capability . capabilities ) ;
122
+ summary . fully += childSummary . fully ;
123
+ summary . partially += childSummary . partially ;
124
+ summary . not += childSummary . not ;
125
+ summary . total += childSummary . total ;
126
+ }
127
+ if ( capability . supported ) {
128
+ summary [ capability . supported ] ++ ;
129
+ summary . total ++ ;
130
+ }
131
+ }
132
+ return summary ;
133
+ }
134
+
135
+ function printSummary ( sum : ChildrenSummary ) : string {
136
+ return `${ sum . fully } fully, ${ sum . partially } partially, ${ sum . not } not supported` ;
137
+ }
138
+
110
139
async function printAsMarkdown ( info : CapabilityInformation , capabilities : readonly FlowrCapability [ ] , depth = 0 , lines : string [ ] = [ ] ) : Promise < string > {
111
140
for ( let i = 0 ; i < capabilities . length ; i ++ ) {
112
141
const capability = capabilities [ i ] ;
113
142
const result = await printSingleCapability ( info , depth , i + 1 , capability ) ;
114
143
lines . push ( result ) ;
115
144
if ( capability . capabilities ) {
145
+ const summary = summarizeChildren ( capability . capabilities ) ;
146
+ lines . push ( `\n\n${ ' ' . repeat ( depth + 1 ) } <details ${ depth > 0 ? 'open' : '' } ><summary>${ summary . total } child${ summary . total === 1 ? '' : 'ren' } (${ printSummary ( summary ) } )</summary>\n\n` ) ;
116
147
await printAsMarkdown ( info , capability . capabilities , depth + 1 , lines ) ;
148
+ lines . push ( `\n\n${ ' ' . repeat ( depth + 1 ) } </details>\n\n` ) ;
149
+ if ( depth === 0 ) {
150
+ lines . push ( '\n\n' + ' ' . repeat ( depth + 1 ) + '-' . repeat ( 42 ) + '\n\n' ) ;
151
+ }
117
152
}
118
153
}
119
154
return lines . join ( '\n' ) ;
0 commit comments