Skip to content

Commit

Permalink
Fix display and links for "external" modules
Browse files Browse the repository at this point in the history
  • Loading branch information
crucialfelix committed Jan 3, 2020
1 parent 3f4adb2 commit 1d0a320
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions tasks/render-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,19 @@ const CallSignature = signature => {
// TODO breakout parameters that have comments and types
};

const nodeSummary = node => `${node.kindString} ${node.name}`;
const nodeSummary = node => `${kindString(node.kindString)} ${node.name}`;
// pre({ name: node.name, kindString: node.kindString, comment: comment(node.comment) });
// const nodeSummary = node => pre({ name: node.name, kindString: node.kindString, comment: comment(node.comment) });

const stripQuotes = str => str && str.replace(/"/g, "");

const ExternalModule = node => {
const name = stripQuotes(node.name);

if (node.children) {
return div(
join(
`${span("module", "token keyword")} ${node.name}`,
`${span("module", "token keyword")} ${name}`,
...node.children
.map(node.children.length > 100 ? nodeSummary : renderNode)
.map(html => div(html, "module-child")),
Expand All @@ -313,7 +317,7 @@ const ExternalModule = node => {
// modules that only have exports do not have any children in api.json
// only a sources

return div(joins(span("module", "token keyword"), node.name), "Module");
return div(joins(span("module", "token keyword"), name), "Module");
// direct exports are not exposed in the typedocs json:
// export { SCLangError } from "@supercollider/lang";
// return `Empty module ${JSON.stringify(node)}`;
Expand All @@ -323,7 +327,7 @@ const indexEntry = node => {
if (node.kindString === "External module") {
return ExternalModule(node);
}
return `${node.kindString} ${node.name}`;
return `${kindString(node.kindString)} ${node.name}`;
};

const Index = node => {
Expand Down Expand Up @@ -358,6 +362,8 @@ const Variable = node => {
return joins(span(node.name, "token property"), ":", type(node.type), "=", node.defaultValue);
};

const kindString = str => (str === "External module" ? "module" : str);

const Function = Method;

// [node.kindString] : function
Expand Down Expand Up @@ -456,12 +462,17 @@ const renderIndexJson = (kv, package, packages) => {

const apiLink = name => {
const renderApiLink = (node, link) =>
ahref(link, joins(span(node.kindString.toLowerCase(), "token keyword"), span(node.name, node.kindString)));
ahref(
link,
joins(
span(kindString(node.kindString).toLowerCase(), "token keyword"),
span(node.name, kindString(node.kindString)),
),
);

const buildLink = (pkg, name) => {
const page = pageForName(pkg, name);
// TODO append ?id=
return `#/packages/${pkg}/${page || name}`;
const page = pageForName(pkg, name) || `api?id=${stripQuotes(name)}`;
return `#/packages/${pkg}/${page}`;
};

const node = find(package, api, name);
Expand Down

0 comments on commit 1d0a320

Please sign in to comment.