Skip to content

Commit

Permalink
Remove extra links in sidebar, link only to API
Browse files Browse the repository at this point in the history
  • Loading branch information
crucialfelix committed Dec 13, 2019
1 parent cc3385a commit 96110be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 102 deletions.
58 changes: 0 additions & 58 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,20 @@
- npm packages
- [@supercollider/dryads](packages/dryads/README.md)
- [API](packages/dryads/api.md)
- [SCServer](packages/dryads/SCServer.md)
- [SCLang](packages/dryads/SCLang.md)
- [Group](packages/dryads/Group.md)
- [Synth](packages/dryads/Synth.md)
- [AudioBus](packages/dryads/AudioBus.md)
- [SCSynthDef](packages/dryads/SCSynthDef.md)
- [SynthControl](packages/dryads/SynthControl.md)
- [SynthStream](packages/dryads/SynthStream.md)
- [SynthEventList](packages/dryads/SynthEventList.md)
- [layer](packages/dryads/layer.md)
- [dryadic](packages/dryads/dryadic.md)
- [play](packages/dryads/play.md)
- [h](packages/dryads/h.md)
- [@supercollider/lang](packages/lang/README.md)
- [API](packages/lang/api.md)
- [SCLang](packages/lang/SCLang.md)
- [boot](packages/lang/boot.md)
- [resolveOptions](packages/lang/resolveOptions.md)
- [SynthDefCompiler](packages/lang/SynthDefCompiler.md)
- [SCLangError](packages/lang/SCLangError.md)
- [@supercollider/logger](packages/logger/README.md)
- [API](packages/logger/api.md)
- [Logger](packages/logger/Logger.md)
- [@supercollider/osc](packages/osc/README.md)
- [API](packages/osc/api.md)
- [packMessage](packages/osc/packMessage.md)
- [packBundle](packages/osc/packBundle.md)
- [unpack](packages/osc/unpack.md)
- [unpackMessage](packages/osc/unpackMessage.md)
- [unpackBundle](packages/osc/unpackBundle.md)
- [pack](packages/osc/pack.md)
- [dateToTimetag](packages/osc/dateToTimetag.md)
- [timetagToDate](packages/osc/timetagToDate.md)
- [deltaTimeTag](packages/osc/deltaTimeTag.md)
- [asNTPTimeTag](packages/osc/asNTPTimeTag.md)
- [@supercollider/scapi](packages/scapi/README.md)
- [API](packages/scapi/api.md)
- [SCAPI](packages/scapi/SCAPI.md)
- [@supercollider/server](packages/server/README.md)
- [API](packages/server/api.md)
- [Server](packages/server/Server.md)
- [boot](packages/server/boot.md)
- [resolveOptions](packages/server/resolveOptions.md)
- [msg](packages/server/msg.md)
- [mapping](packages/server/mapping.md)
- [ServerState](packages/server/ServerState.md)
- [watchNodeNotifications](packages/server/watchNodeNotifications.md)
- [onNodeGo](packages/server/onNodeGo.md)
- [whenNodeGo](packages/server/whenNodeGo.md)
- [onNodeEnd](packages/server/onNodeEnd.md)
- [whenNodeEnd](packages/server/whenNodeEnd.md)
- [updateNodeState](packages/server/updateNodeState.md)
- [deltaTimeTag](packages/server/deltaTimeTag.md)
- [@supercollider/server-plus](packages/server-plus/README.md)
- [API](packages/server-plus/api.md)
- [Group](packages/server-plus/Group.md)
- [Synth](packages/server-plus/Synth.md)
- [AudioBus](packages/server-plus/AudioBus.md)
- [ControlBus](packages/server-plus/ControlBus.md)
- [Buffer](packages/server-plus/Buffer.md)
- [SynthDef](packages/server-plus/SynthDef.md)
- [ServerPlus](packages/server-plus/ServerPlus.md)
- [boot](packages/server-plus/boot.md)
- [supercolliderjs](packages/supercolliderjs/README.md)
- [API](packages/supercolliderjs/api.md)
- [server](packages/supercolliderjs/server.md)
- [dryads](packages/supercolliderjs/dryads.md)
- [lang](packages/supercolliderjs/lang.md)
- [map](packages/supercolliderjs/map.md)
- [msg](packages/supercolliderjs/msg.md)
- [SCLangError](packages/supercolliderjs/SCLangError.md)
- [resolveOptions](packages/supercolliderjs/resolveOptions.md)
- Guide
- [Guide](https://crucialfelix.gitbooks.io/supercollider-js-guide/content/)
- [Examples](https://github.com/crucialfelix/supercolliderjs-examples)
55 changes: 11 additions & 44 deletions tasks/make-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,55 +92,26 @@ async function generateSidebar(packages) {
const sb = [];
sb.push("- " + mdLink("Getting started", ["README.md"]));
sb.push("- npm packages");
const autos = {};
packages.forEach(short => {
autos[short] = [];

const index = readJson("packages", short, "index.json");
const { name } = readJson("packages", short, "package.json");
sb.push(` - ${mdLink(name, ["packages", short, "README.md"])}`);
sb.push(` - ` + mdLink("API", ["packages", short, "api.md"]));
// push one for each top level export
for (const [key, value] of Object.entries(index)) {
if (isString(value)) {
sb.push(` - ` + mdLink(value, ["packages", short, value + ".md"]));
} else {
// it's a module
sb.push(` - ` + mdLink(key, ["packages", short, key + ".md"]));
}
autos[short].push(
isString(value) ? { title: value, filename: value + ".md" } : { title: key, filename: key + ".md" },
);
}
});
sb.push("- Guide");
sb.push(" - " + mdLink("Guide", ["https://crucialfelix.gitbooks.io/supercollider-js-guide/content/"]));
sb.push(" - " + mdLink("Examples", ["https://github.com/crucialfelix/supercolliderjs-examples"]));
const content = sb.join("\n");
// console.log(content);
writeFile(["docs", "_sidebar.md"], content);
}

async function parseSidebar() {
// auto generate md files if they are listed in the sidebar
const sidebar = readFile("docs", "_sidebar.md");
const autos = {};
function pushAuto(package, title, filename) {
if (!autos[package]) {
autos[package] = [];
}
autos[package].push({ title, filename });
}
const re = /\[(.+)\]\(packages\/([a-z\-_]+)\/([^)]+)\)/;
for (const line of sidebar.split("\n")) {
// if has []()
// if file is not README
//
const match = line.match(re);
if (match) {
const title = match[1];
const package = match[2];
const filename = match[3];
// or api?
if (filename !== "README.md") {
pushAuto(package, title, filename);
}
}
}
return autos;
}

Expand Down Expand Up @@ -200,9 +171,7 @@ async function main(version) {
// _coverpage
await renderTplPath("docs/src/_coverpage.md", "docs/_coverpage.md", rootData);

await generateSidebar(packages);

const autos = await parseSidebar();
const autos = await generateSidebar(packages);

for (const pkgdir of packages) {
const pkg = readJson("packages", pkgdir, "package.json");
Expand All @@ -216,15 +185,13 @@ async function main(version) {
homepage: pkg.hompage,
};

// generate api.md file for the exports of a module
// Generate api.md file for the module exports
generateApi(pkg.name, short, packages);

// generate autodocument for each entry in sidebar
// Generate autodocument for each entry in autos
for (const sidebarLink of autos[short] || []) {
if (!(await fileExists("docs/src/packages", short, sidebarLink.filename))) {
const tplBody = generateAutodocument(short, sidebarLink);
await renderTpl(tplBody, path.join("docs", "packages", pkgdir, sidebarLink.filename), data);
}
const tplBody = generateAutodocument(short, sidebarLink);
await renderTpl(tplBody, path.join("docs", "packages", short, sidebarLink.filename), data);
}

for (const filename of fs.readdirSync(path.join("docs/src/packages", pkgdir))) {
Expand Down

0 comments on commit 96110be

Please sign in to comment.