skill
Make a Wiki Component Page
Public Made by Adomby adom
Create a wiki component page the RIGHT way. Pages are keyed manufacturer-mpn and scoped to ONE DATASHEET, so a datasheet covering six voltages and three packages is ONE page covering all of them, never six pages. Two manufacturers publishing the same MPN are two pages, because their limits genuinely differ. Renders through a hand-built readme.html on the Adom theme tokens with a fixed ten-section shape (identity, at a glance, specifications, symbol+footprint viewers, pin map, variants, assets, i
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
#!/usr/bin/env python3
"""Wrap N adom-footprint embeds into one package-switcher iframe page."""
import html, sys, pathlib
def build(pkgs, out, part):
frames, btns, fmap = [], [], []
for i, (key, label, path) in enumerate(pkgs):
doc = html.escape(pathlib.Path(path).read_text(), quote=True)
hid = "" if i == 0 else " hidden"
frames.append(f' <iframe id="{key}" title="{part} {label} footprint" srcdoc="{doc}"{hid}></iframe>')
btns.append(f' <button role="tab" data-t="{key}" aria-selected="{"true" if i == 0 else "false"}">{label}</button>')
fmap.append(f"{key}:document.getElementById('{key}')")
pathlib.Path(out).write_text(f'''<!doctype html><html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1"><title>{part} footprint</title>
<style>
:root{{color-scheme:light dark}}
html,body{{margin:0;height:100%;background:transparent;font-family:Satoshi,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif}}
.wrap{{position:relative;width:100%;height:100%;min-height:500px}}
.switch{{position:absolute;right:12px;bottom:12px;z-index:10;display:inline-flex;padding:3px;border-radius:10px;
background:rgba(28,33,40,.78);backdrop-filter:blur(6px);box-shadow:0 1px 4px rgba(0,0,0,.35)}}
.switch button{{appearance:none;border:0;cursor:pointer;font:inherit;font-size:12.5px;font-weight:600;
padding:8px 14px;border-radius:8px;color:#c9d1d9;background:transparent;white-space:nowrap;
font-family:"JetBrains Mono",ui-monospace,Menlo,monospace;transition:background .15s,color .15s}}
.switch button[aria-selected="true"]{{background:#00b8b1;color:#05221f}}
.frames{{position:absolute;inset:0}}
.frames iframe{{position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent}}
.frames iframe[hidden]{{display:none}}
</style></head><body>
<div class="wrap">
<div class="frames">
{chr(10).join(frames)}
</div>
<div class="switch" role="tablist" aria-label="Footprint variant">
{chr(10).join(btns)}
</div>
</div>
<script>
var B=document.querySelectorAll('.switch button');
var F={{{','.join(fmap)}}};
B.forEach(function(b){{b.addEventListener('click',function(){{
var t=b.getAttribute('data-t');
B.forEach(function(x){{x.setAttribute('aria-selected', x===b?'true':'false');}});
for(var k in F){{ if(k===t) F[k].removeAttribute('hidden'); else F[k].setAttribute('hidden',''); }}
}});}});
</script></body></html>''')
print(f" {out}: {', '.join(l for _, l, _ in pkgs)}")
if __name__ == "__main__":
base = pathlib.Path(sys.argv[1])
vendor = sys.argv[2]
third = ("so8", "SO-8") if vendor == "AMS" else ("sot89", "SOT-89")
pkgs = [("sot223", "SOT-223", base / "fp-sot223.html"),
("to252", "TO-252", base / "fp-to252.html"),
(third[0], third[1], base / f"fp-{third[0]}.html")]
build(pkgs, sys.argv[3], "AMS1117")