code wiki / (root) / nx_docpub_site.nx

nx_docpub_site.nx source

↩ module page · 90 lines · 8095 B

1// nx_docpub_site.nx -- R1-scale: the self-generating documentation SITE. Walks a curated set of the arc's organs, 2// renders a REFERENCE page for each from SOURCE (shared nx_docgen_lib render core, DRY #15), and emits a GitBook/ 3// Javadoc-class INDEX landing page (web_assets/docgen/index.html) linking the whole set. This turns the one-page 4// engine into a navigable documentation SITE -- the "self generating live documentation wiki" shape. Sovereign, 5// zero third-party. Gated: all pages generated + index links resolve + a generated page carries real source 6// signatures and zero JS. license_tier: ORIGINAL expect_exit: 0 7import "nx_syscalls.nx" 8import "nx_docgen_lib.nx" 9import "nx_docpub_render.nx" // the doc render core (see nx_docpub_render.nx header) 10 11func dgs_path(name: *u8, outpath: *u8) -> i64 { 12 var o: i64 = 0 13 o = dg_cat(outpath, o, "web_assets/docgen/" as *u8) 14 o = dg_cat(outpath, o, name) 15 o = dg_cat(outpath, o, ".html" as *u8) 16 outpath[o] = 0 as u8 17 return o 18} 19 20// render one organ -> page file + append an index <li>. returns new index offset. pages[0]++ on success. 21func dgs_one(path: *u8, name: *u8, src: *u8, cap: i64, out: *u8, cnt: *i64, idxbuf: *u8, idxo: i64, pages: *i64) -> i64 { 22 let n: i64 = dg_rdfile(path, src, cap) 23 if n <= 0 { dgw(" SKIP (read fail) " as *u8); dgw(path); dgw("\n" as *u8); return idxo } 24 let olen: i64 = dg_render(src, n, name, out, cnt) 25 let op: *u8 = sys_mmap(256) 26 dgs_path(name, op) 27 dg_writefile(op, out, olen) 28 let tg: *u8 = sys_mmap(2048) 29 let tll: i64 = dg_first_doc_line(src, n, tg) 30 var o: i64 = idxo 31 o = dg_cat(idxbuf, o, "<li><a href=" as *u8); o = dg_cat(idxbuf, o, name); o = dg_cat(idxbuf, o, ".html>" as *u8); o = dg_cat(idxbuf, o, name); o = dg_cat(idxbuf, o, "</a><div class=meta>" as *u8) 32 o = dg_catn(idxbuf, o, cnt[0]); o = dg_cat(idxbuf, o, " funcs &middot; " as *u8); o = dg_catn(idxbuf, o, cnt[1]); o = dg_cat(idxbuf, o, " imports</div>" as *u8) 33 if tll > 0 { o = dg_cat(idxbuf, o, "<p class=desc>" as *u8); o = dg_catb_esc(idxbuf, o, tg, 0, tll); o = dg_cat(idxbuf, o, "</p>" as *u8) } 34 o = dg_cat(idxbuf, o, "</li>" as *u8) 35 pages[0] = pages[0] + 1 36 dgw(" GEN " as *u8); dgw(name); dgw(" ("); dgn(cnt[0]); dgw(" funcs, "); dgn(cnt[1]); dgw(" imports) -> "); dgn(olen); dgw("B\n") 37 return o 38} 39 40func main() -> i64 { 41 dgw("=== NX-DOCPUB-SITE -- self-generating documentation SITE (index + reference set) ===\n" as *u8) 42 __syscall(83, "web_assets" as i64, 493, 0, 0, 0, 0) 43 __syscall(83, "web_assets/docgen" as i64, 493, 0, 0, 0, 0) 44 let cap: i64 = 1048576 45 let src: *u8 = sys_mmap(cap) 46 let out: *u8 = sys_mmap(cap) 47 let cnt: *i64 = sys_mmap(16) as *i64 48 let idx: *u8 = sys_mmap(cap) 49 let pages: *i64 = sys_mmap(16) as *i64; pages[0] = 0 50 51 var io: i64 = 0 52 io = dg_cat(idx, io, "<!doctype html><html lang=en><head><meta charset=utf-8><meta name=viewport content='width=device-width,initial-scale=1'><title>Nishi Docs &mdash; Reference</title><style>*{box-sizing:border-box}body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;margin:0;color:#1a2330;background:#fbfcfe;line-height:1.55}header.top{background:#0b2545;color:#fff;padding:11px 24px;font-size:.92rem;font-weight:600}main{max-width:880px;margin:0 auto;padding:30px 24px 70px}h1{font-size:1.95rem;margin:.1em 0;letter-spacing:-.015em}p.lead{color:#475468;font-size:1.06rem;margin:.3em 0 1.8em;max-width:660px}ul.cards{list-style:none;padding:0;margin:0;display:grid;grid-template-columns:repeat(auto-fill,minmax(255px,1fr));gap:13px}ul.cards li{background:#fff;border:1px solid #e6ebf3;border-radius:8px;padding:13px 15px;transition:box-shadow .12s,border-color .12s}ul.cards li:hover{border-color:#2a6fb0;box-shadow:0 3px 12px rgba(11,37,69,.09)}ul.cards a{color:#0b2545;text-decoration:none;font-weight:600;font-size:1rem}ul.cards a:hover{color:#2a6fb0}ul.cards .meta{color:#8493a8;font-size:.78rem;margin:3px 0 0}ul.cards .desc{color:#46566b;font-size:.85rem;margin:7px 0 0;line-height:1.45}@media(max-width:600px){main{padding:20px 16px 50px}h1{font-size:1.5rem}}</style></head><body>" as *u8) 53 io = dg_cat(idx, io, "<header class=top>&#9776; Nishi Docs</header><main>" as *u8) 54 io = dg_cat(idx, io, "<h1>Nishi Docs</h1>" as *u8) 55 io = dg_cat(idx, io, "<p class=lead>Auto-generated reference for the documentation-publishing arc &mdash; every page rendered from organ source, sovereign, zero third-party. The arc documenting itself.</p><ul class=cards>" as *u8) 56 57 // dependencies first, so cross-links to sibling reference pages resolve in a single pass (zero dead links) 58 io = dgs_one("buildroot/runtime/nx_docgen_lib.nx" as *u8, "nx_docgen_lib" as *u8, src, cap, out, cnt, idx, io, pages) 59 io = dgs_one("buildroot/runtime/_hdl_build/nx_publisher.nx" as *u8, "nx_publisher" as *u8, src, cap, out, cnt, idx, io, pages) 60 io = dgs_one("buildroot/runtime/nx_docgen.nx" as *u8, "nx_docgen" as *u8, src, cap, out, cnt, idx, io, pages) 61 io = dgs_one("buildroot/runtime/nx_docpub_census.nx" as *u8, "nx_docpub_census" as *u8, src, cap, out, cnt, idx, io, pages) 62 io = dgs_one("buildroot/runtime/nx_docpub_research_fetch.nx" as *u8, "nx_docpub_research_fetch" as *u8, src, cap, out, cnt, idx, io, pages) 63 io = dgs_one("buildroot/runtime/_hdl_build/nx_docpub_publish.nx" as *u8, "nx_docpub_publish" as *u8, src, cap, out, cnt, idx, io, pages) 64 65 io = dg_cat(idx, io, "</ul></main></body></html>" as *u8) 66 dg_writefile("web_assets/docgen/index.html" as *u8, idx, io) 67 dgw(" pages generated="); dgn(pages[0]); dgw(" index bytes="); dgn(io); dgw("\n") 68 dgw(" artifact: web_assets/docgen/index.html\n" as *u8) 69 70 let pass: *i64 = sys_mmap(16) as *i64; pass[0] = 0 71 let t1: i64 = (pages[0] == 6) as i64 72 if t1 == 1 { dgw(" T1 all 6 reference pages generated: PASS\n" as *u8); pass[0] = pass[0] + 1 } else { dgw(" T1 all 6 reference pages generated: FAIL\n" as *u8) } 73 let t2: i64 = (dg_contains(idx, io, "nx_publisher.html>" as *u8)) & (dg_contains(idx, io, "nx_docgen.html>" as *u8)) & (dg_contains(idx, io, "nx_docpub_census.html>" as *u8)) 74 if t2 == 1 { dgw(" T2 index links the reference set: PASS\n" as *u8); pass[0] = pass[0] + 1 } else { dgw(" T2 index links the reference set: FAIL\n" as *u8) } 75 let chk: *u8 = sys_mmap(cap) 76 let cn: i64 = dg_rdfile("web_assets/docgen/nx_publisher.html" as *u8, chk, cap) 77 let t3: i64 = ((cn > 0) as i64) & (dg_contains(chk, cn, "pub_submit(" as *u8)) & (1 - dg_contains(chk, cn, "<script" as *u8)) & (dg_contains(chk, cn, "class=kw" as *u8)) 78 if t3 == 1 { dgw(" T3 generated page: real signatures + zero-JS + syntax-highlighted: PASS\n" as *u8); pass[0] = pass[0] + 1 } else { dgw(" T3 generated page: real signatures + zero-JS + syntax-highlighted: FAIL\n" as *u8) } 79 let chk2: *u8 = sys_mmap(cap) 80 let cn2: i64 = dg_rdfile("web_assets/docgen/nx_docpub_publish.html" as *u8, chk2, cap) 81 let t4: i64 = ((cn2 > 0) as i64) & (dg_contains(chk2, cn2, "href=nx_publisher.html" as *u8)) 82 if t4 == 1 { dgw(" T4 cross-link resolves (nx_docpub_publish import -> nx_publisher reference page): PASS\n" as *u8); pass[0] = pass[0] + 1 } else { dgw(" T4 cross-link resolves: FAIL\n" as *u8) } 83 // POLISH gate (finish quality, not just function): no leaked build-directives + per-function descriptions present 84 let t5: i64 = ((cn > 0) as i64) & (1 - dg_contains(chk, cn, "license_tier" as *u8)) & (1 - dg_contains(chk, cn, "expect_exit" as *u8)) & (dg_contains(chk, cn, "class=fndoc" as *u8)) 85 if t5 == 1 { dgw(" T5 POLISH: no leaked build-directives + per-function descriptions rendered: PASS\n" as *u8); pass[0] = pass[0] + 1 } else { dgw(" T5 POLISH (no boilerplate leak + fn-docs): FAIL\n" as *u8) } 86 87 dgw("NX-DOCPUB-SITE "); dgn(pass[0]); dgw("/5 ") 88 if pass[0] == 5 { dgw("verdict=GREEN (self-generating documentation SITE: index + reference set + cross-links + POLISH, sovereign)\n" as *u8); sys_exit(0); return 0 } 89 dgw("verdict=RED\n" as *u8); sys_exit(1); return 1 90}