@@ -246,7 +246,66 @@ function generateLlmsTxt() {
246246 console . warn ( `Generated: website/public/llms.txt (${ totalAnchors } anchors, ~${ kb } KB)` )
247247}
248248
249+ // ─── Generate website/public/docs/all-anchors.adoc (inlined, no includes) ────
250+
251+ /**
252+ * Shift AsciiDoc heading levels by offset (e.g. +1 turns = into ==)
253+ */
254+ function shiftHeadings ( content , offset ) {
255+ return content . replace ( / ^ ( = + ) ( .+ ) $ / gm, ( _ , eq , rest ) => '=' . repeat ( eq . length + offset ) + rest )
256+ }
257+
258+ /**
259+ * Strip document-level AsciiDoc attributes (:key: value) used as metadata
260+ */
261+ function stripDocAttrs ( content ) {
262+ return content . replace ( / ^ : [ a - z ] [ a - z 0 - 9 - ] * : .* $ / gm, '' )
263+ }
264+
265+ function generateAllAnchorsWebAdoc ( ) {
266+ const WEB_DOCS = path . join ( ROOT , 'website/public/docs' )
267+ fs . mkdirSync ( WEB_DOCS , { recursive : true } )
268+
269+ const lines = [
270+ '= Semantic Anchors — Complete Reference' ,
271+ ':toc:' ,
272+ ':toc-placement: preamble' ,
273+ ':toclevels: 2' ,
274+ '' ,
275+ ]
276+
277+ const aboutPath = path . join ( ROOT , 'docs/about.adoc' )
278+ if ( fs . existsSync ( aboutPath ) ) {
279+ const aboutContent = fs . readFileSync ( aboutPath , 'utf-8' )
280+ lines . push ( shiftHeadings ( stripDocAttrs ( aboutContent ) , 1 ) )
281+ lines . push ( '' )
282+ lines . push ( "'''" )
283+ lines . push ( '' )
284+ }
285+
286+ for ( const category of categories ) {
287+ lines . push ( `== ${ category . name } ` )
288+ lines . push ( '' )
289+ for ( const anchorId of category . anchors ) {
290+ const filepath = path . join ( ROOT , 'docs/anchors' , `${ anchorId } .adoc` )
291+ if ( fs . existsSync ( filepath ) ) {
292+ const anchorContent = fs . readFileSync ( filepath , 'utf-8' )
293+ lines . push ( shiftHeadings ( stripDocAttrs ( anchorContent ) , 2 ) )
294+ lines . push ( '' )
295+ }
296+ }
297+ lines . push ( "'''" )
298+ lines . push ( '' )
299+ }
300+
301+ const output = lines . join ( '\n' )
302+ fs . writeFileSync ( path . join ( WEB_DOCS , 'all-anchors.adoc' ) , output , 'utf-8' )
303+ const kb = Math . round ( Buffer . byteLength ( output , 'utf-8' ) / 1024 )
304+ console . warn ( `Generated: website/public/docs/all-anchors.adoc (~${ kb } KB, inlined)` )
305+ }
306+
249307// ─── Main ────────────────────────────────────────────────────────────────────
250308
251309generateAllAnchorsAdoc ( )
310+ generateAllAnchorsWebAdoc ( )
252311generateLlmsTxt ( )
0 commit comments