api docs work in progress.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4460 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-09-13 23:00:47 +00:00
parent d2485583fd
commit 15d0383349
2 changed files with 117 additions and 11 deletions

View File

@ -27,17 +27,51 @@ function markdown(md) {
function document(api) {
let doc = markdown(docs.docs[api.split(' = ')[0]]);
return `
<a id="${api}"></a>
<a name="${api}"></a>
<h2 style="color: #aaf">${api}</h2>
<div>${doc}</div>
`;
}
app.setDocument(`<body style="color:#fff">
app.setDocument(`<head>
<base target="_top">
<style type="text/css">
a:link {
color: #268bd2;
}
a:visited {
color: #6c71c4;
}
a:hover {
color: #859900;
}
a:active {
color: #2aa198;
}
</style>
</head>
<body style="color:#fff">
${markdown(docs.docs.global)}
${[...treeify('', globalThis)].map(x => document(x)).join('\n')}
<a id="Database"></a>
${markdown(docs.docs.database)}
${['database.get()', 'database.set()', 'database.exchange()', 'database.remove()', 'database.getAll()', 'database.getLike()'].map(x => document(x)).join('\n')}
${markdown(docs.docs.tfrpc)}
${['tfrpc.register()', 'tfprc.rpc.*()'].map(x => document(x)).join('\n')}
${['tfrpc.register()', 'tfrpc.rpc.*()'].map(x => document(x)).join('\n')}
<script>
window.onload = function() {
console.log('load');
for (let tag of document.getElementsByTagName('a')) {
console.log(tag.href);
tag.onclick = function() {
document.getElementById(tag.href.split('#')[1]).scrollIntoView();
return false;
}
delete tag.href;
}
}
</script>
</body>`);