diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..167ab9f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+node_modules/
+yarn.lock
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
index 699211d..ab649a1 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1 +1,3 @@
-changelogs.md
\ No newline at end of file
+changelogs.md
+.prettierrc
+.github/
\ No newline at end of file
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..1ddcdd0
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,5 @@
+{
+ "semi": true,
+ "singleQuote": false,
+ "printWidth": 400
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index 5e3059a..f531acd 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,9 @@
A clean and minimalistic JSDoc theme
-![Preview](https://skyceil.zyrouge.gq/images/main.png)
+![Preview](https://jsdoc.snowflakedev.xyz/images/main.png)
-# [Documentation](https://skyceil.zyrouge.gq)
+# [Documentation](https://jsdoc.snowflakedev.xyz)
## Install
```bash
@@ -18,12 +18,12 @@ $ jsdoc ./ -t /path/to/skyceil
## Clone
```bash
-$ git clone https://github.com/zyrouge/jsdoc-skyceil
+$ git clone https://github.com/DevSnowflake/jsdoc-skyceil
```
## Helpful Links
-* [Website/Docs](https://skyceil.zyrouge.gq/)
-* [Source](https://github.com/zyrouge/jsdoc-skyceil)
-* [Changelogs](https://github.com/zyrouge/jsdoc-skyceil/blob/master/changelogs.md)
-* [Discord](https://zyrouge.gq/discord)
+* [Website/Docs](https://jsdoc.snowflakedev.xyz)
+* [Source](https://github.com/DevSnowflake/jsdoc-skyceil)
+* [Changelogs](https://github.com/DevSnowflake/jsdoc-skyceil/blob/master/changelogs.md)
+* [Discord](https://snowflakedev.xyz/discord)
diff --git a/package.json b/package.json
index 86e1dfa..85a142d 100644
--- a/package.json
+++ b/package.json
@@ -1,23 +1,31 @@
{
"name": "jsdoc-skyceil",
- "version": "1.0.6",
- "description": "A clean and minimalistic JSDoc theme",
+ "version": "2.0.0",
+ "description": "A clean and minimalistic JSDoc theme for everyone",
"main": "publish.js",
"scripts": {
+ "format": "prettier --write **/*.{js,css}",
"test": "jsdoc -R ../jsdoc-skyceil-docs/example/readme.md -d ../jsdoc-skyceil-docs/example -t . --verbose ../jsdoc-skyceil-docs/example/thecode.js"
},
"repository": {
"type": "git",
- "url": "git+https://github.com/zyrouge/jsdoc-skyceil.git"
+ "url": "git+https://github.com/DevSnowflake/jsdoc-skyceil.git"
},
"keywords": [
"jsdoc",
- "theme"
+ "theme",
+ "docs",
+ "docgen",
+ "jsdoc-theme"
],
"author": "ZYROUGE",
"license": "ISC",
"bugs": {
- "url": "https://github.com/zyrouge/jsdoc-skyceil/issues"
+ "url": "https://github.com/DevSnowflake/jsdoc-skyceil/issues"
},
- "homepage": "https://skyceil.zyrouge.gq"
+ "homepage": "https://jsdoc.snowflakedev.xyz",
+ "devDependencies": {
+ "jsdoc": "^3.6.7",
+ "prettier": "^2.3.0"
+ }
}
diff --git a/publish.js b/publish.js
index bea7401..f531134 100644
--- a/publish.js
+++ b/publish.js
@@ -1,12 +1,12 @@
-const doop = require('jsdoc/util/doop');
-const env = require('jsdoc/env');
-const fs = require('jsdoc/fs');
-const helper = require('jsdoc/util/templateHelper');
-const logger = require('jsdoc/util/logger');
-const path = require('jsdoc/path');
-const taffy = require('taffydb').taffy;
-const template = require('jsdoc/template');
-const util = require('util');
+const doop = require("jsdoc/util/doop");
+const env = require("jsdoc/env");
+const fs = require("jsdoc/fs");
+const helper = require("jsdoc/util/templateHelper");
+const logger = require("jsdoc/util/logger");
+const path = require("jsdoc/path");
+const taffy = require("taffydb").taffy;
+const template = require("jsdoc/template");
+const util = require("util");
const htmlsafe = helper.htmlsafe;
const linkto = helper.linkto;
@@ -19,245 +19,238 @@ let view;
let outdir = path.normalize(env.opts.destination);
function find(spec) {
- return helper.find(data, spec);
+ return helper.find(data, spec);
}
function tutoriallink(tutorial) {
- return helper.toTutorial(tutorial, null, {
- tag: 'em',
- classname: 'disabled',
- prefix: 'Tutorial: '
- });
+ return helper.toTutorial(tutorial, null, {
+ tag: "em",
+ classname: "disabled",
+ prefix: "Tutorial: ",
+ });
}
function getAncestorLinks(doclet) {
- return helper.getAncestorLinks(data, doclet);
+ return helper.getAncestorLinks(data, doclet);
}
function hashToLink(doclet, hash) {
- let url;
+ let url;
- if ( !/^(#.+)/.test(hash) ) {
- return hash;
- }
+ if (!/^(#.+)/.test(hash)) {
+ return hash;
+ }
- url = helper.createLink(doclet);
- url = url.replace(/(#.+|$)/, hash);
+ url = helper.createLink(doclet);
+ url = url.replace(/(#.+|$)/, hash);
- return `${hash}`;
+ return `${hash}`;
}
-function needsSignature({kind, type, meta}) {
- let needsSig = false;
-
- // function and class definitions always get a signature
- if (kind === 'function' || kind === 'class') {
- needsSig = true;
- }
- // typedefs that contain functions get a signature, too
- else if (kind === 'typedef' && type && type.names &&
- type.names.length) {
- for (let i = 0, l = type.names.length; i < l; i++) {
- if (type.names[i].toLowerCase() === 'function') {
- needsSig = true;
- break;
- }
- }
- }
- // and namespaces that are functions get a signature (but finding them is a
- // bit messy)
- else if (kind === 'namespace' && meta && meta.code &&
- meta.code.type && meta.code.type.match(/[Ff]unction/)) {
+function needsSignature({ kind, type, meta }) {
+ let needsSig = false;
+
+ // function and class definitions always get a signature
+ if (kind === "function" || kind === "class") {
+ needsSig = true;
+ }
+ // typedefs that contain functions get a signature, too
+ else if (kind === "typedef" && type && type.names && type.names.length) {
+ for (let i = 0, l = type.names.length; i < l; i++) {
+ if (type.names[i].toLowerCase() === "function") {
needsSig = true;
+ break;
+ }
}
-
- return needsSig;
+ }
+ // and namespaces that are functions get a signature (but finding them is a
+ // bit messy)
+ else if (kind === "namespace" && meta && meta.code && meta.code.type && meta.code.type.match(/[Ff]unction/)) {
+ needsSig = true;
+ }
+
+ return needsSig;
}
-function getSignatureAttributes({optional, nullable}) {
- const attributes = [];
+function getSignatureAttributes({ optional, nullable }) {
+ const attributes = [];
- if (optional) {
- attributes.push('opt');
- }
+ if (optional) {
+ attributes.push("opt");
+ }
- if (nullable === true) {
- attributes.push('nullable');
- }
- else if (nullable === false) {
- attributes.push('non-null');
- }
+ if (nullable === true) {
+ attributes.push("nullable");
+ } else if (nullable === false) {
+ attributes.push("non-null");
+ }
- return attributes;
+ return attributes;
}
function updateItemName(item) {
- const attributes = getSignatureAttributes(item);
- let itemName = item.name || '';
+ const attributes = getSignatureAttributes(item);
+ let itemName = item.name || "";
- if (item.variable) {
- itemName = `…${itemName}`;
- }
+ if (item.variable) {
+ itemName = `…${itemName}`;
+ }
- if (attributes && attributes.length) {
- itemName = util.format( '%s%s', itemName,
- attributes.join(', ') );
- }
+ if (attributes && attributes.length) {
+ itemName = util.format('%s%s', itemName, attributes.join(", "));
+ }
- return itemName;
+ return itemName;
}
function addParamAttributes(params) {
- return params.filter(({name}) => name && !name.includes('.')).map(updateItemName);
+ return params.filter(({ name }) => name && !name.includes(".")).map(updateItemName);
}
function buildItemTypeStrings(item) {
- const types = [];
+ const types = [];
- if (item && item.type && item.type.names) {
- item.type.names.forEach(name => {
- types.push( linkto(name, htmlsafe(name)) );
- });
- }
+ if (item && item.type && item.type.names) {
+ item.type.names.forEach((name) => {
+ types.push(linkto(name, htmlsafe(name)));
+ });
+ }
- return types;
+ return types;
}
function buildAttribsString(attribs) {
- let attribsString = '';
+ let attribsString = "";
- if (attribs && attribs.length) {
- attribsString = htmlsafe( util.format('(%s) ', attribs.join(', ')) );
- }
+ if (attribs && attribs.length) {
+ attribsString = htmlsafe(util.format("(%s) ", attribs.join(", ")));
+ }
- return attribsString;
+ return attribsString;
}
function addNonParamAttributes(items) {
- let types = [];
+ let types = [];
- items.forEach(item => {
- types = types.concat( buildItemTypeStrings(item) );
- });
+ items.forEach((item) => {
+ types = types.concat(buildItemTypeStrings(item));
+ });
- return types;
+ return types;
}
function addSignatureParams(f) {
- const params = f.params ? addParamAttributes(f.params) : [];
+ const params = f.params ? addParamAttributes(f.params) : [];
- f.signature = util.format( '%s(%s)', (f.signature || ''), params.join(', ') );
+ f.signature = util.format("%s(%s)", f.signature || "", params.join(", "));
}
function addSignatureReturns(f) {
- const attribs = [];
- let attribsString = '';
- let returnTypes = [];
- let returnTypesString = '';
- const source = f.yields || f.returns;
-
- // jam all the return-type attributes into an array. this could create odd results (for example,
- // if there are both nullable and non-nullable return types), but let's assume that most people
- // who use multiple @return tags aren't using Closure Compiler type annotations, and vice-versa.
- if (source) {
- source.forEach(item => {
- helper.getAttribs(item).forEach(attrib => {
- if (!attribs.includes(attrib)) {
- attribs.push(attrib);
- }
- });
- });
+ const attribs = [];
+ let attribsString = "";
+ let returnTypes = [];
+ let returnTypesString = "";
+ const source = f.yields || f.returns;
+
+ // jam all the return-type attributes into an array. this could create odd results (for example,
+ // if there are both nullable and non-nullable return types), but let's assume that most people
+ // who use multiple @return tags aren't using Closure Compiler type annotations, and vice-versa.
+ if (source) {
+ source.forEach((item) => {
+ helper.getAttribs(item).forEach((attrib) => {
+ if (!attribs.includes(attrib)) {
+ attribs.push(attrib);
+ }
+ });
+ });
- attribsString = buildAttribsString(attribs);
- }
+ attribsString = buildAttribsString(attribs);
+ }
- if (source) {
- returnTypes = addNonParamAttributes(source);
- }
- if (returnTypes.length) {
- returnTypesString = util.format( ' → %s{%s}', attribsString, returnTypes.join('|') );
- }
+ if (source) {
+ returnTypes = addNonParamAttributes(source);
+ }
+ if (returnTypes.length) {
+ returnTypesString = util.format(" → %s{%s}", attribsString, returnTypes.join("|"));
+ }
- f.signature = `${f.signature || ''}${returnTypesString}`;
+ f.signature = `${f.signature || ""}${returnTypesString}`;
}
function addSignatureTypes(f) {
- const types = f.type ? buildItemTypeStrings(f) : [];
+ const types = f.type ? buildItemTypeStrings(f) : [];
- f.signature = `${f.signature || ''}${types.length ? ` :${types.join('|')}` : ''}`;
+ f.signature = `${f.signature || ""}${types.length ? ` :${types.join("|")}` : ""}`;
}
function addAttribs(f) {
- const attribs = helper.getAttribs(f);
- const attribsString = buildAttribsString(attribs);
+ const attribs = helper.getAttribs(f);
+ const attribsString = buildAttribsString(attribs);
- f.attribs = util.format('%s', attribsString);
+ f.attribs = util.format('%s', attribsString);
}
function shortenPaths(files, commonPrefix) {
- Object.keys(files).forEach(file => {
- files[file].shortened = files[file].resolved.replace(commonPrefix, '')
- // always use forward slashes
- .replace(/\\/g, '/');
- });
-
- return files;
+ Object.keys(files).forEach((file) => {
+ files[file].shortened = files[file].resolved
+ .replace(commonPrefix, "")
+ // always use forward slashes
+ .replace(/\\/g, "/");
+ });
+
+ return files;
}
-function getPathFromDoclet({meta}) {
- if (!meta) {
- return null;
- }
+function getPathFromDoclet({ meta }) {
+ if (!meta) {
+ return null;
+ }
- return meta.path && meta.path !== 'null' ?
- path.join(meta.path, meta.filename) :
- meta.filename;
+ return meta.path && meta.path !== "null" ? path.join(meta.path, meta.filename) : meta.filename;
}
function generate(title, docs, filename, resolveLinks) {
- let docData;
- let html;
- let outpath;
+ let docData;
+ let html;
+ let outpath;
- resolveLinks = resolveLinks !== false;
+ resolveLinks = resolveLinks !== false;
- docData = {
- env: env,
- title: title,
- docs: docs
- };
+ docData = {
+ env: env,
+ title: title,
+ docs: docs,
+ };
- outpath = path.join(outdir, filename);
- html = view.render('container.tmpl', docData);
+ outpath = path.join(outdir, filename);
+ html = view.render("container.tmpl", docData);
- if (resolveLinks) {
- html = helper.resolveLinks(html); // turn {@link foo} into foo
- }
+ if (resolveLinks) {
+ html = helper.resolveLinks(html); // turn {@link foo} into foo
+ }
- fs.writeFileSync(outpath, html, 'utf8');
+ fs.writeFileSync(outpath, html, "utf8");
}
-function generateSourceFiles(sourceFiles, encoding = 'utf8') {
- Object.keys(sourceFiles).forEach(file => {
- let source;
- // links are keyed to the shortened path in each doclet's `meta.shortpath` property
- const sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
-
- helper.registerLink(sourceFiles[file].shortened, sourceOutfile);
-
- try {
- source = {
- kind: 'source',
- code: helper.htmlsafe( fs.readFileSync(sourceFiles[file].resolved, encoding) )
- };
- }
- catch (e) {
- logger.error('Error while generating source file %s: %s', file, e.message);
- }
+function generateSourceFiles(sourceFiles, encoding = "utf8") {
+ Object.keys(sourceFiles).forEach((file) => {
+ let source;
+ // links are keyed to the shortened path in each doclet's `meta.shortpath` property
+ const sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
+
+ helper.registerLink(sourceFiles[file].shortened, sourceOutfile);
+
+ try {
+ source = {
+ kind: "source",
+ code: helper.htmlsafe(fs.readFileSync(sourceFiles[file].resolved, encoding)),
+ };
+ } catch (e) {
+ logger.error("Error while generating source file %s: %s", file, e.message);
+ }
- generate(`Source: ${sourceFiles[file].shortened}`, [source], sourceOutfile,
- false);
- });
+ generate(`Source: ${sourceFiles[file].shortened}`, [source], sourceOutfile, false);
+ });
}
/**
@@ -272,90 +265,83 @@ function generateSourceFiles(sourceFiles, encoding = 'utf8') {
* @param {Array.} modules - The array of module doclets to search.
*/
function attachModuleSymbols(doclets, modules) {
- const symbols = {};
-
- // build a lookup table
- doclets.forEach(symbol => {
- symbols[symbol.longname] = symbols[symbol.longname] || [];
- symbols[symbol.longname].push(symbol);
- });
-
- modules.forEach(module => {
- if (symbols[module.longname]) {
- module.modules = symbols[module.longname]
- // Only show symbols that have a description. Make an exception for classes, because
- // we want to show the constructor-signature heading no matter what.
- .filter(({description, kind}) => description || kind === 'class')
- .map(symbol => {
- symbol = doop(symbol);
-
- if (symbol.kind === 'class' || symbol.kind === 'function') {
- symbol.name = `${symbol.name.replace('module:', '(require("')}"))`;
- }
-
- return symbol;
- });
- }
- });
+ const symbols = {};
+
+ // build a lookup table
+ doclets.forEach((symbol) => {
+ symbols[symbol.longname] = symbols[symbol.longname] || [];
+ symbols[symbol.longname].push(symbol);
+ });
+
+ modules.forEach((module) => {
+ if (symbols[module.longname]) {
+ module.modules = symbols[module.longname]
+ // Only show symbols that have a description. Make an exception for classes, because
+ // we want to show the constructor-signature heading no matter what.
+ .filter(({ description, kind }) => description || kind === "class")
+ .map((symbol) => {
+ symbol = doop(symbol);
+
+ if (symbol.kind === "class" || symbol.kind === "function") {
+ symbol.name = `${symbol.name.replace("module:", '(require("')}"))`;
+ }
+
+ return symbol;
+ });
+ }
+ });
}
function buildMemberNav(items, itemHeading, itemsSeen, linktoFn) {
- let nav = '';
-
- if (items.length) {
- let itemsNav = '';
-
- items.forEach(item => {
- var methods = find({ kind: "function", memberof: item.longname })
- var members = find({ kind: "member", memberof: item.longname })
- var hasMethods = !!(methods.length || members.length);
- let displayName;
-
- if ( !hasOwnProp.call(item, 'longname') ) {
- itemsNav += `${getIcon(itemHeading)}${linktoFn('', item.name)}`;
- }
- else if ( !hasOwnProp.call(itemsSeen, item.longname) ) {
- if (env.conf.templates.default.useLongnameInNav) {
- displayName = item.longname;
- } else {
- displayName = item.name;
- }
- itemsNav += [
- ``,
- `${getIcon(itemHeading)}${hasMethods ? "" : ""}${linktoFn(item.longname, displayName.replace(/\b(module|event):/g, ''))}${hasMethods ? "" : ""}`,
- hasMethods ?
- [
- ``,
- methods.map(meth => `- ${getIcon(meth.kind)}${linktoFn(meth.longname, meth.name)}
`).join(""),
- members.map(meth => `- ${getIcon(meth.kind)}${linktoFn(meth.longname, meth.name)}
`).join(""),
- `
`
- ].join("") : "",
- ``
- ].join("");
-
- itemsSeen[item.longname] = true;
- }
- });
-
- if (itemsNav !== '') {
- nav += `${itemHeading}
`;
+ let nav = "";
+
+ if (items.length) {
+ let itemsNav = "";
+
+ items.forEach((item) => {
+ var methods = find({ kind: "function", memberof: item.longname });
+ var members = find({ kind: "member", memberof: item.longname });
+ var hasMethods = !!(methods.length || members.length);
+ let displayName;
+
+ if (!hasOwnProp.call(item, "longname")) {
+ itemsNav += `${getIcon(itemHeading)}${linktoFn("", item.name)}`;
+ } else if (!hasOwnProp.call(itemsSeen, item.longname)) {
+ if (env.conf.templates.default.useLongnameInNav) {
+ displayName = item.longname;
+ } else {
+ displayName = item.name;
}
+ itemsNav += [
+ ``,
+ `${getIcon(itemHeading)}${hasMethods ? "" : ""}${linktoFn(item.longname, displayName.replace(/\b(module|event):/g, ""))}${hasMethods ? "" : ""}`,
+ hasMethods ? [``, methods.map((meth) => `- ${getIcon(meth.kind)}${linktoFn(meth.longname, meth.name)}
`).join(""), members.map((meth) => `- ${getIcon(meth.kind)}${linktoFn(meth.longname, meth.name)}
`).join(""), `
`].join("") : "",
+ ``,
+ ].join("");
+
+ itemsSeen[item.longname] = true;
+ }
+ });
+
+ if (itemsNav !== "") {
+ nav += `${itemHeading}
`;
}
+ }
- return nav;
+ return nav;
}
-function getIcon (name) {
- const icon = name.charAt(0).toUpperCase();
- return `${icon}`;
+function getIcon(name) {
+ const icon = name.charAt(0).toUpperCase();
+ return `${icon}`;
}
function linktoTutorial(longName, name) {
- return tutoriallink(name);
+ return tutoriallink(name);
}
function linktoExternal(longName, name) {
- return linkto(longName, name.replace(/(^"|"$)/g, ''));
+ return linkto(longName, name.replace(/(^"|"$)/g, ""));
}
/**
@@ -373,92 +359,90 @@ function linktoExternal(longName, name) {
* @return {string} The HTML for the navigation sidebar.
*/
function buildNav(members) {
- let globalNav;
- let nav = '';
- const seen = {};
- const seenTutorials = {};
-
- nav += buildMemberNav(members.modules, 'Modules', {}, linkto);
- nav += buildMemberNav(members.externals, 'Externals', seen, linktoExternal);
- nav += buildMemberNav(members.namespaces, 'Namespaces', seen, linkto);
- nav += buildMemberNav(members.classes, 'Classes', seen, linkto);
- nav += buildMemberNav(members.interfaces, 'Interfaces', seen, linkto);
- nav += buildMemberNav(members.events, 'Events', seen, linkto);
- nav += buildMemberNav(members.mixins, 'Mixins', seen, linkto);
- nav += buildMemberNav(members.tutorials, 'Tutorials', seenTutorials, linktoTutorial);
-
- if (members.globals.length) {
- globalNav = '';
-
- members.globals.forEach(({kind, longname, name}) => {
- if ( kind !== 'typedef' && !hasOwnProp.call(seen, longname) ) {
- globalNav += `${linkto(longname, name)}`;
- }
- seen[longname] = true;
- });
+ let globalNav;
+ let nav = '';
+ const seen = {};
+ const seenTutorials = {};
+
+ nav += buildMemberNav(members.modules, "Modules", {}, linkto);
+ nav += buildMemberNav(members.externals, "Externals", seen, linktoExternal);
+ nav += buildMemberNav(members.namespaces, "Namespaces", seen, linkto);
+ nav += buildMemberNav(members.classes, "Classes", seen, linkto);
+ nav += buildMemberNav(members.interfaces, "Interfaces", seen, linkto);
+ nav += buildMemberNav(members.events, "Events", seen, linkto);
+ nav += buildMemberNav(members.mixins, "Mixins", seen, linkto);
+ nav += buildMemberNav(members.tutorials, "Tutorials", seenTutorials, linktoTutorial);
+
+ if (members.globals.length) {
+ globalNav = "";
+
+ members.globals.forEach(({ kind, longname, name }) => {
+ if (kind !== "typedef" && !hasOwnProp.call(seen, longname)) {
+ globalNav += `${linkto(longname, name)}`;
+ }
+ seen[longname] = true;
+ });
- if (!globalNav) {
- // turn the heading into a link so you can actually get to the global page
- nav += `${linkto('global', 'Global')}
`;
- }
- else {
- nav += `Global
`;
- }
+ if (!globalNav) {
+ // turn the heading into a link so you can actually get to the global page
+ nav += `${linkto("global", "Global")}
`;
+ } else {
+ nav += `Global
`;
}
+ }
- return nav;
+ return nav;
}
function buildMemberSearch(items, itemHeading, itemsSeen, linktoFn) {
- let search = [];
-
- if (items.length) {
- let itemsSearch = [];
-
- items.forEach(item => {
- var methods = find({ kind: "function", memberof: item.longname })
- var members = find({ kind: "member", memberof: item.longname })
- var hasMethods = !!(methods.length || members.length);
- let displayName;
-
- if ( !hasOwnProp.call(item, 'longname') ) {
- itemsSearch.push({ name: item.name, url: linktoFn('', item.name) });
- }
- else if ( !hasOwnProp.call(itemsSeen, item.longname) ) {
- if (env.conf.templates.default.useLongnameInNav) {
- displayName = item.longname;
- } else {
- displayName = item.name;
- }
-
- itemsSearch.push({
- name: displayName,
- url: linktoFn(item.longname, displayName.replace(/\b(module|event):/g, ''))
- });
-
- if(hasMethods) {
- methods.forEach(meth => {
- itemsSearch.push({
- name: meth.longname,
- url: linktoFn(meth.longname, meth.name)
- });
- });
- members.forEach(meth => {
- itemsSearch.push({
- name: meth.longname,
- url: linktoFn(meth.longname, meth.name)
- });
- });
- }
- }
+ let search = [];
+
+ if (items.length) {
+ let itemsSearch = [];
+
+ items.forEach((item) => {
+ var methods = find({ kind: "function", memberof: item.longname });
+ var members = find({ kind: "member", memberof: item.longname });
+ var hasMethods = !!(methods.length || members.length);
+ let displayName;
+
+ if (!hasOwnProp.call(item, "longname")) {
+ itemsSearch.push({ name: item.name, url: linktoFn("", item.name) });
+ } else if (!hasOwnProp.call(itemsSeen, item.longname)) {
+ if (env.conf.templates.default.useLongnameInNav) {
+ displayName = item.longname;
+ } else {
+ displayName = item.name;
+ }
+
+ itemsSearch.push({
+ name: displayName,
+ url: linktoFn(item.longname, displayName.replace(/\b(module|event):/g, "")),
});
- if (itemsSearch.length) {
- search.push(...itemsSearch);
+ if (hasMethods) {
+ methods.forEach((meth) => {
+ itemsSearch.push({
+ name: meth.longname,
+ url: linktoFn(meth.longname, meth.name),
+ });
+ });
+ members.forEach((meth) => {
+ itemsSearch.push({
+ name: meth.longname,
+ url: linktoFn(meth.longname, meth.name),
+ });
+ });
}
+ }
+ });
+
+ if (itemsSearch.length) {
+ search.push(...itemsSearch);
}
+ }
- return search;
+ return search;
}
/**
@@ -476,44 +460,43 @@ function buildMemberSearch(items, itemHeading, itemsSeen, linktoFn) {
* @return {string} The HTML for the navigation sidebar.
*/
function buildSearch(members) {
- let globalNav;
- let search = [{ name: "Home", url: 'Home' }];
- const seen = {};
- const seenTutorials = {};
-
- search.push(...buildMemberSearch(members.modules, 'Modules', {}, linkto));
- search.push(...buildMemberSearch(members.externals, 'Externals', seen, linktoExternal));
- search.push(...buildMemberSearch(members.namespaces, 'Namespaces', seen, linkto));
- search.push(...buildMemberSearch(members.classes, 'Classes', seen, linkto));
- search.push(...buildMemberSearch(members.interfaces, 'Interfaces', seen, linkto));
- search.push(...buildMemberSearch(members.events, 'Events', seen, linkto));
- search.push(...buildMemberSearch(members.mixins, 'Mixins', seen, linkto));
- search.push(...buildMemberSearch(members.tutorials, 'Tutorials', seenTutorials, linktoTutorial));
-
- if (members.globals.length) {
- globalNav = [];
-
- members.globals.forEach(({kind, longname, name}) => {
- if ( kind !== 'typedef' && !hasOwnProp.call(seen, longname) ) {
- globalNav.push({ name: name, url: linkto(longname, name) });
- }
- });
+ let globalNav;
+ let search = [{ name: "Home", url: 'Home' }];
+ const seen = {};
+ const seenTutorials = {};
+
+ search.push(...buildMemberSearch(members.modules, "Modules", {}, linkto));
+ search.push(...buildMemberSearch(members.externals, "Externals", seen, linktoExternal));
+ search.push(...buildMemberSearch(members.namespaces, "Namespaces", seen, linkto));
+ search.push(...buildMemberSearch(members.classes, "Classes", seen, linkto));
+ search.push(...buildMemberSearch(members.interfaces, "Interfaces", seen, linkto));
+ search.push(...buildMemberSearch(members.events, "Events", seen, linkto));
+ search.push(...buildMemberSearch(members.mixins, "Mixins", seen, linkto));
+ search.push(...buildMemberSearch(members.tutorials, "Tutorials", seenTutorials, linktoTutorial));
+
+ if (members.globals.length) {
+ globalNav = [];
+
+ members.globals.forEach(({ kind, longname, name }) => {
+ if (kind !== "typedef" && !hasOwnProp.call(seen, longname)) {
+ globalNav.push({ name: name, url: linkto(longname, name) });
+ }
+ });
- if (!globalNav.length) {
- search.push({ name: "Global", url: linkto('global', 'Global') });
- }
- else {
- search.push(...globalNav);
- }
+ if (!globalNav.length) {
+ search.push({ name: "Global", url: linkto("global", "Global") });
+ } else {
+ search.push(...globalNav);
}
+ }
- return search;
+ return search;
}
-function prettifyReadme (readme) {
- let prettifiedReadme = readme;
- prettifiedReadme = prettifiedReadme.replace(/class="prettyprint/g, "class=\"prettyprint linenums");
- return prettifiedReadme;
+function prettifyReadme(readme) {
+ let prettifiedReadme = readme;
+ prettifiedReadme = prettifiedReadme.replace(/class="prettyprint/g, 'class="prettyprint linenums');
+ return prettifiedReadme;
}
/**
@@ -522,299 +505,300 @@ function prettifyReadme (readme) {
@param {Tutorial} tutorials
*/
exports.publish = (taffyData, opts, tutorials) => {
- let classes;
- let conf;
- let externals;
- let files;
- let fromDir;
- let globalUrl;
- let indexUrl;
- let interfaces;
- let members;
- let mixins;
- let modules;
- let namespaces;
- let outputSourceFiles;
- let packageInfo;
- let packages;
- const sourceFilePaths = [];
- let sourceFiles = {};
- let staticFileFilter;
- let staticFilePaths;
- let staticFiles;
- let staticFileScanner;
- let templatePath;
-
- data = taffyData;
-
- conf = env.conf.templates || {};
- conf.default = conf.default || {};
-
- templatePath = path.normalize(opts.template);
- view = new template.Template( path.join(templatePath, 'tmpl') );
-
- // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
- // doesn't try to hand them out later
- indexUrl = helper.getUniqueFilename('index');
- // don't call registerLink() on this one! 'index' is also a valid longname
-
- globalUrl = helper.getUniqueFilename('global');
- helper.registerLink('global', globalUrl);
-
- // set up templating
- view.layout = conf.default.layoutFile ?
- path.getResourcePath(path.dirname(conf.default.layoutFile),
- path.basename(conf.default.layoutFile) ) :
- 'layout.tmpl';
-
- // set up tutorials for helper
- helper.setTutorials(tutorials);
-
- data = helper.prune(data);
- data.sort('longname, version, since');
- helper.addEventListeners(data);
-
- data().each(doclet => {
- let sourcePath;
-
- doclet.attribs = '';
-
- if (doclet.examples) {
- doclet.examples = doclet.examples.map(example => {
- let caption;
- let code;
-
- if (example.match(/^\s*([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) {
- caption = RegExp.$1;
- code = RegExp.$3;
- }
-
- return {
- caption: caption || '',
- code: code || example
- };
- });
- }
- if (doclet.see) {
- doclet.see.forEach((seeItem, i) => {
- doclet.see[i] = hashToLink(doclet, seeItem);
- });
+ let classes;
+ let conf;
+ let externals;
+ let files;
+ let fromDir;
+ let globalUrl;
+ let indexUrl;
+ let interfaces;
+ let members;
+ let mixins;
+ let modules;
+ let namespaces;
+ let outputSourceFiles;
+ let packageInfo;
+ let packages;
+ const sourceFilePaths = [];
+ let sourceFiles = {};
+ let staticFileFilter;
+ let staticFilePaths;
+ let staticFiles;
+ let staticFileScanner;
+ let templatePath;
+
+ data = taffyData;
+
+ conf = env.conf.templates || {};
+ conf.default = conf.default || {};
+
+ templatePath = path.normalize(opts.template);
+ view = new template.Template(path.join(templatePath, "tmpl"));
+
+ // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
+ // doesn't try to hand them out later
+ indexUrl = helper.getUniqueFilename("index");
+ // don't call registerLink() on this one! 'index' is also a valid longname
+
+ globalUrl = helper.getUniqueFilename("global");
+ helper.registerLink("global", globalUrl);
+
+ // set up templating
+ view.layout = conf.default.layoutFile ? path.getResourcePath(path.dirname(conf.default.layoutFile), path.basename(conf.default.layoutFile)) : "layout.tmpl";
+
+ // set up tutorials for helper
+ helper.setTutorials(tutorials);
+
+ data = helper.prune(data);
+ data.sort("longname, version, since");
+ helper.addEventListeners(data);
+
+ data().each((doclet) => {
+ let sourcePath;
+
+ doclet.attribs = "";
+
+ if (doclet.examples) {
+ doclet.examples = doclet.examples.map((example) => {
+ let caption;
+ let code;
+
+ if (example.match(/^\s*([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) {
+ caption = RegExp.$1;
+ code = RegExp.$3;
}
- // build a list of source files
- if (doclet.meta) {
- sourcePath = getPathFromDoclet(doclet);
- sourceFiles[sourcePath] = {
- resolved: sourcePath,
- shortened: null
- };
- if (!sourceFilePaths.includes(sourcePath)) {
- sourceFilePaths.push(sourcePath);
- }
- }
- });
+ return {
+ caption: caption || "",
+ code: code || example,
+ };
+ });
+ }
+ if (doclet.see) {
+ doclet.see.forEach((seeItem, i) => {
+ doclet.see[i] = hashToLink(doclet, seeItem);
+ });
+ }
- // update outdir if necessary, then create outdir
- packageInfo = ( find({kind: 'package'}) || [] )[0];
- if (packageInfo && packageInfo.name) {
- outdir = path.join( outdir, packageInfo.name, (packageInfo.version || '') );
+ // build a list of source files
+ if (doclet.meta) {
+ sourcePath = getPathFromDoclet(doclet);
+ sourceFiles[sourcePath] = {
+ resolved: sourcePath,
+ shortened: null,
+ };
+ if (!sourceFilePaths.includes(sourcePath)) {
+ sourceFilePaths.push(sourcePath);
+ }
}
- fs.mkPath(outdir);
+ });
- // copy the template's static files to outdir
- fromDir = path.join(templatePath, 'static');
- staticFiles = fs.ls(fromDir, 3);
+ // update outdir if necessary, then create outdir
+ packageInfo = (find({ kind: "package" }) || [])[0];
+ if (packageInfo && packageInfo.name) {
+ outdir = path.join(outdir, packageInfo.name, packageInfo.version || "");
+ }
+ fs.mkPath(outdir);
- staticFiles.forEach(fileName => {
- const toDir = fs.toDir( fileName.replace(fromDir, outdir) );
+ // copy the template's static files to outdir
+ fromDir = path.join(templatePath, "static");
+ staticFiles = fs.ls(fromDir, 3);
- fs.mkPath(toDir);
- fs.copyFileSync(fileName, toDir);
- });
+ staticFiles.forEach((fileName) => {
+ const toDir = fs.toDir(fileName.replace(fromDir, outdir));
- // copy user-specified static files to outdir
- if (conf.default.staticFiles) {
- // The canonical property name is `include`. We accept `paths` for backwards compatibility
- // with a bug in JSDoc 3.2.x.
- staticFilePaths = conf.default.staticFiles.include ||
- conf.default.staticFiles.paths ||
- [];
- staticFileFilter = new (require('jsdoc/src/filter').Filter)(conf.default.staticFiles);
- staticFileScanner = new (require('jsdoc/src/scanner').Scanner)();
+ fs.mkPath(toDir);
+ fs.copyFileSync(fileName, toDir);
+ });
- staticFilePaths.forEach(filePath => {
- let extraStaticFiles;
+ // copy user-specified static files to outdir
+ if (conf.default.staticFiles) {
+ // The canonical property name is `include`. We accept `paths` for backwards compatibility
+ // with a bug in JSDoc 3.2.x.
+ staticFilePaths = conf.default.staticFiles.include || conf.default.staticFiles.paths || [];
+ staticFileFilter = new (require("jsdoc/src/filter").Filter)(conf.default.staticFiles);
+ staticFileScanner = new (require("jsdoc/src/scanner").Scanner)();
- filePath = path.resolve(env.pwd, filePath);
- extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter);
+ staticFilePaths.forEach((filePath) => {
+ let extraStaticFiles;
- extraStaticFiles.forEach(fileName => {
- const sourcePath = fs.toDir(filePath);
- const toDir = fs.toDir( fileName.replace(sourcePath, outdir) );
+ filePath = path.resolve(env.pwd, filePath);
+ extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter);
- fs.mkPath(toDir);
- fs.copyFileSync(fileName, toDir);
- });
- });
- }
+ extraStaticFiles.forEach((fileName) => {
+ const sourcePath = fs.toDir(filePath);
+ const toDir = fs.toDir(fileName.replace(sourcePath, outdir));
- if (sourceFilePaths.length) {
- sourceFiles = shortenPaths( sourceFiles, path.commonPrefix(sourceFilePaths) );
- }
- data().each(doclet => {
- let docletPath;
- const url = helper.createLink(doclet);
-
- helper.registerLink(doclet.longname, url);
-
- // add a shortened version of the full path
- if (doclet.meta) {
- docletPath = getPathFromDoclet(doclet);
- docletPath = sourceFiles[docletPath].shortened;
- if (docletPath) {
- doclet.meta.shortpath = docletPath;
- }
- }
+ fs.mkPath(toDir);
+ fs.copyFileSync(fileName, toDir);
+ });
});
+ }
+
+ if (sourceFilePaths.length) {
+ sourceFiles = shortenPaths(sourceFiles, path.commonPrefix(sourceFilePaths));
+ }
+ data().each((doclet) => {
+ let docletPath;
+ const url = helper.createLink(doclet);
+
+ helper.registerLink(doclet.longname, url);
+
+ // add a shortened version of the full path
+ if (doclet.meta) {
+ docletPath = getPathFromDoclet(doclet);
+ docletPath = sourceFiles[docletPath].shortened;
+ if (docletPath) {
+ doclet.meta.shortpath = docletPath;
+ }
+ }
+ });
- data().each(doclet => {
- const url = helper.longnameToUrl[doclet.longname];
-
- if (url.includes('#')) {
- doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop();
- }
- else {
- doclet.id = doclet.name;
- }
-
- if ( needsSignature(doclet) ) {
- addSignatureParams(doclet);
- addSignatureReturns(doclet);
- addAttribs(doclet);
- }
- });
+ data().each((doclet) => {
+ const url = helper.longnameToUrl[doclet.longname];
- // do this after the urls have all been generated
- data().each(doclet => {
- doclet.ancestors = getAncestorLinks(doclet);
+ if (url.includes("#")) {
+ doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop();
+ } else {
+ doclet.id = doclet.name;
+ }
- if (doclet.kind === 'member') {
- addSignatureTypes(doclet);
- addAttribs(doclet);
- }
+ if (needsSignature(doclet)) {
+ addSignatureParams(doclet);
+ addSignatureReturns(doclet);
+ addAttribs(doclet);
+ }
+ });
- if (doclet.kind === 'constant') {
- addSignatureTypes(doclet);
- addAttribs(doclet);
- doclet.kind = 'member';
- }
- });
+ // do this after the urls have all been generated
+ data().each((doclet) => {
+ doclet.ancestors = getAncestorLinks(doclet);
- members = helper.getMembers(data);
- members.tutorials = tutorials.children;
-
- // output pretty-printed source files by default
- outputSourceFiles = conf.default && conf.default.outputSourceFiles !== false;
-
- // add template helpers
- view.find = find;
- view.linkto = linkto;
- view.resolveAuthorLinks = resolveAuthorLinks;
- view.tutoriallink = tutoriallink;
- view.htmlsafe = htmlsafe;
- view.outputSourceFiles = outputSourceFiles;
-
- // once for all
- view.nav = buildNav(members);
- attachModuleSymbols( find({ longname: { left: 'module:'} }), members.modules );
- view.search = buildSearch(members);
- fs.writeFileSync(path.join(outdir, "search.json"), JSON.stringify(view.search));
-
- // generate the pretty-printed source files first so other pages can link to them
- if (outputSourceFiles) {
- generateSourceFiles(sourceFiles, opts.encoding);
+ if (doclet.kind === "member") {
+ addSignatureTypes(doclet);
+ addAttribs(doclet);
}
- if (members.globals.length) { generate('Global', [{kind: 'globalobj'}], globalUrl); }
-
- // index page displays information from package.json and lists files
- files = find({kind: 'file'});
- packages = find({kind: 'package'});
-
- generate('Home',
- packages.concat(
- [{
- kind: 'mainpage',
- readme: opts.readme ? prettifyReadme(opts.readme) : undefined,
- longname: (opts.mainpagetitle) ? opts.mainpagetitle : 'Main Page'
- }]
- ).concat(files), indexUrl);
-
- // set up the lists that we'll use to generate pages
- classes = taffy(members.classes);
- modules = taffy(members.modules);
- namespaces = taffy(members.namespaces);
- mixins = taffy(members.mixins);
- externals = taffy(members.externals);
- interfaces = taffy(members.interfaces);
-
- Object.keys(helper.longnameToUrl).forEach(longname => {
- const myClasses = helper.find(classes, {longname: longname});
- const myExternals = helper.find(externals, {longname: longname});
- const myInterfaces = helper.find(interfaces, {longname: longname});
- const myMixins = helper.find(mixins, {longname: longname});
- const myModules = helper.find(modules, {longname: longname});
- const myNamespaces = helper.find(namespaces, {longname: longname});
-
- if (myModules.length) {
- generate(`Module: ${myModules[0].name}`, myModules, helper.longnameToUrl[longname]);
- }
-
- if (myClasses.length) {
- generate(`Class: ${myClasses[0].name}`, myClasses, helper.longnameToUrl[longname]);
- }
+ if (doclet.kind === "constant") {
+ addSignatureTypes(doclet);
+ addAttribs(doclet);
+ doclet.kind = "member";
+ }
+ });
+
+ members = helper.getMembers(data);
+ members.tutorials = tutorials.children;
+
+ // output pretty-printed source files by default
+ outputSourceFiles = conf.default && conf.default.outputSourceFiles !== false;
+
+ // add template helpers
+ view.find = find;
+ view.linkto = linkto;
+ view.resolveAuthorLinks = resolveAuthorLinks;
+ view.tutoriallink = tutoriallink;
+ view.htmlsafe = htmlsafe;
+ view.outputSourceFiles = outputSourceFiles;
+
+ // once for all
+ view.nav = buildNav(members);
+ attachModuleSymbols(find({ longname: { left: "module:" } }), members.modules);
+ view.search = buildSearch(members);
+ fs.writeFileSync(path.join(outdir, "search.json"), JSON.stringify(view.search));
+
+ // generate the pretty-printed source files first so other pages can link to them
+ if (outputSourceFiles) {
+ generateSourceFiles(sourceFiles, opts.encoding);
+ }
+
+ if (members.globals.length) {
+ generate("Global", [{ kind: "globalobj" }], globalUrl);
+ }
+
+ // index page displays information from package.json and lists files
+ files = find({ kind: "file" });
+ packages = find({ kind: "package" });
+
+ generate(
+ "Home",
+ packages
+ .concat([
+ {
+ kind: "mainpage",
+ readme: opts.readme ? prettifyReadme(opts.readme) : undefined,
+ longname: opts.mainpagetitle ? opts.mainpagetitle : "Main Page",
+ },
+ ])
+ .concat(files),
+ indexUrl
+ );
+
+ // set up the lists that we'll use to generate pages
+ classes = taffy(members.classes);
+ modules = taffy(members.modules);
+ namespaces = taffy(members.namespaces);
+ mixins = taffy(members.mixins);
+ externals = taffy(members.externals);
+ interfaces = taffy(members.interfaces);
+
+ Object.keys(helper.longnameToUrl).forEach((longname) => {
+ const myClasses = helper.find(classes, { longname: longname });
+ const myExternals = helper.find(externals, { longname: longname });
+ const myInterfaces = helper.find(interfaces, { longname: longname });
+ const myMixins = helper.find(mixins, { longname: longname });
+ const myModules = helper.find(modules, { longname: longname });
+ const myNamespaces = helper.find(namespaces, { longname: longname });
+
+ if (myModules.length) {
+ generate(`Module: ${myModules[0].name}`, myModules, helper.longnameToUrl[longname]);
+ }
- if (myNamespaces.length) {
- generate(`Namespace: ${myNamespaces[0].name}`, myNamespaces, helper.longnameToUrl[longname]);
- }
+ if (myClasses.length) {
+ generate(`Class: ${myClasses[0].name}`, myClasses, helper.longnameToUrl[longname]);
+ }
- if (myMixins.length) {
- generate(`Mixin: ${myMixins[0].name}`, myMixins, helper.longnameToUrl[longname]);
- }
+ if (myNamespaces.length) {
+ generate(`Namespace: ${myNamespaces[0].name}`, myNamespaces, helper.longnameToUrl[longname]);
+ }
- if (myExternals.length) {
- generate(`External: ${myExternals[0].name}`, myExternals, helper.longnameToUrl[longname]);
- }
+ if (myMixins.length) {
+ generate(`Mixin: ${myMixins[0].name}`, myMixins, helper.longnameToUrl[longname]);
+ }
- if (myInterfaces.length) {
- generate(`Interface: ${myInterfaces[0].name}`, myInterfaces, helper.longnameToUrl[longname]);
- }
- });
+ if (myExternals.length) {
+ generate(`External: ${myExternals[0].name}`, myExternals, helper.longnameToUrl[longname]);
+ }
- // TODO: move the tutorial functions to templateHelper.js
- function generateTutorial(title, tutorial, filename) {
- const tutorialData = {
- title: title,
- header: tutorial.title,
- content: tutorial.parse(),
- children: tutorial.children
- };
- const tutorialPath = path.join(outdir, filename);
- let html = view.render('tutorial.tmpl', tutorialData);
+ if (myInterfaces.length) {
+ generate(`Interface: ${myInterfaces[0].name}`, myInterfaces, helper.longnameToUrl[longname]);
+ }
+ });
+
+ // TODO: move the tutorial functions to templateHelper.js
+ function generateTutorial(title, tutorial, filename) {
+ const tutorialData = {
+ title: title,
+ header: tutorial.title,
+ content: tutorial.parse(),
+ children: tutorial.children,
+ };
+ const tutorialPath = path.join(outdir, filename);
+ let html = view.render("tutorial.tmpl", tutorialData);
- // yes, you can use {@link} in tutorials too!
- html = helper.resolveLinks(html); // turn {@link foo} into foo
+ // yes, you can use {@link} in tutorials too!
+ html = helper.resolveLinks(html); // turn {@link foo} into foo
- fs.writeFileSync(tutorialPath, html, 'utf8');
- }
+ fs.writeFileSync(tutorialPath, html, "utf8");
+ }
- // tutorials can have only one parent so there is no risk for loops
- function saveChildren({children}) {
- children.forEach(child => {
- generateTutorial(`Tutorial: ${child.title}`, child, helper.tutorialToUrl(child.name));
- saveChildren(child);
- });
- }
+ // tutorials can have only one parent so there is no risk for loops
+ function saveChildren({ children }) {
+ children.forEach((child) => {
+ generateTutorial(`Tutorial: ${child.title}`, child, helper.tutorialToUrl(child.name));
+ saveChildren(child);
+ });
+ }
- saveChildren(tutorials);
-};
\ No newline at end of file
+ saveChildren(tutorials);
+};
diff --git a/static/scripts/linenumber.js b/static/scripts/linenumber.js
index 4354785..e1b852f 100644
--- a/static/scripts/linenumber.js
+++ b/static/scripts/linenumber.js
@@ -1,25 +1,25 @@
/*global document */
(() => {
- const source = document.getElementsByClassName('prettyprint source linenums');
- let i = 0;
- let lineNumber = 0;
- let lineId;
- let lines;
- let totalLines;
- let anchorHash;
+ const source = document.getElementsByClassName("prettyprint source linenums");
+ let i = 0;
+ let lineNumber = 0;
+ let lineId;
+ let lines;
+ let totalLines;
+ let anchorHash;
- if (source && source[0]) {
- anchorHash = document.location.hash.substring(1);
- lines = source[0].getElementsByTagName('li');
- totalLines = lines.length;
+ if (source && source[0]) {
+ anchorHash = document.location.hash.substring(1);
+ lines = source[0].getElementsByTagName("li");
+ totalLines = lines.length;
- for (; i < totalLines; i++) {
- lineNumber++;
- lineId = `line${lineNumber}`;
- lines[i].id = lineId;
- if (lineId === anchorHash) {
- lines[i].className += ' selected';
- }
- }
+ for (; i < totalLines; i++) {
+ lineNumber++;
+ lineId = `line${lineNumber}`;
+ lines[i].id = lineId;
+ if (lineId === anchorHash) {
+ lines[i].className += " selected";
+ }
}
+ }
})();
diff --git a/static/scripts/nav.js b/static/scripts/nav.js
index 518e4fb..d811ff3 100644
--- a/static/scripts/nav.js
+++ b/static/scripts/nav.js
@@ -1,97 +1,99 @@
const init = async () => {
- document.addEventListener("DOMContentLoaded", function () {
- const body = document.querySelector("body");
+ document.addEventListener("DOMContentLoaded", function () {
+ const body = document.querySelector("body");
- // Burger
- const burger = document.querySelector(".burger"),
- nav = document.querySelector(".navbar"),
- navLinks = nav.querySelectorAll("a");
-
- burger.addEventListener("click", function () {
- toggleClass(burger, "is-active");
- toggleClass(nav, "is-active");
- });
+ // Burger
+ const burger = document.querySelector(".burger"),
+ nav = document.querySelector(".navbar"),
+ navLinks = nav.querySelectorAll("a");
- navLinks.forEach(link => {
- link.addEventListener("click", function () {
- if (burger.classList.contains("is-active")) {
- toggleClass(burger, "is-active");
- toggleClass(nav, "is-active");
- }
- });
- });
+ burger.addEventListener("click", function () {
+ toggleClass(burger, "is-active");
+ toggleClass(nav, "is-active");
+ });
- // Utilities
- const utilitiesDiv = document.querySelector(".utilities");
+ navLinks.forEach((link) => {
+ link.addEventListener("click", function () {
+ if (burger.classList.contains("is-active")) {
+ toggleClass(burger, "is-active");
+ toggleClass(nav, "is-active");
+ }
+ });
+ });
- // Theme
- const themeBtn = utilitiesDiv.querySelector(".theme");
- updateTheme();
+ // Utilities
+ const utilitiesDiv = document.querySelector(".utilities");
- themeBtn.addEventListener("click", function () {
- const DBTheme = localStorage.getItem("theme") || "light";
- if (DBTheme === "light") localStorage.setItem("theme", "dark");
- else localStorage.setItem("theme", "light");
- updateTheme();
- });
+ // Theme
+ const themeBtn = utilitiesDiv.querySelector(".theme");
+ updateTheme();
- function updateTheme () {
- const bodyTheme = body.getAttribute("data-theme") || "light";
- const DBTheme = localStorage.getItem("theme") || "light";
+ themeBtn.addEventListener("click", function () {
+ const DBTheme = localStorage.getItem("theme") || "light";
+ if (DBTheme === "light") localStorage.setItem("theme", "dark");
+ else localStorage.setItem("theme", "light");
+ updateTheme();
+ });
- if (DBTheme === "dark" && bodyTheme !== "dark") {
- body.setAttribute("data-theme", "dark");
- themeBtn.innerHTML = "";
- } else if (DBTheme === "light" && bodyTheme !== "light") {
- body.setAttribute("data-theme", "light");
- themeBtn.innerHTML = "";
- }
- }
+ function updateTheme() {
+ const bodyTheme = body.getAttribute("data-theme") || "light";
+ const DBTheme = localStorage.getItem("theme") || "light";
- makeSearch();
- });
+ if (DBTheme === "dark" && bodyTheme !== "dark") {
+ body.setAttribute("data-theme", "dark");
+ themeBtn.innerHTML = '';
+ } else if (DBTheme === "light" && bodyTheme !== "light") {
+ body.setAttribute("data-theme", "light");
+ themeBtn.innerHTML = '';
+ }
+ }
- function toggleClass(element, className) {
- if (element.classList.contains(className)) {
- element.classList.remove(className);
- } else {
- element.classList.add(className);
- }
+ makeSearch();
+ });
+
+ function toggleClass(element, className) {
+ if (element.classList.contains(className)) {
+ element.classList.remove(className);
+ } else {
+ element.classList.add(className);
}
+ }
- async function makeSearch() {
- const searchData = await fetch("search.json");
- const data = await searchData.json();
- const textbox = document.getElementById("search-box");
- const results = document.getElementById("search-results");
- const fuse = new Fuse(data, {
- includeScore: true,
- keys: ['name']
- });
- textbox.addEventListener("change", textboxhandle);
- textbox.addEventListener("keydown", textboxhandle);
- textbox.addEventListener("keyup", textboxhandle);
- textbox.addEventListener("keypress", textboxhandle);
- function textboxhandle() {
- const val = textbox.value.trim();
- if(val.length) {
- const items = fuse.search(val);
- let resHtml = "";
- if(items.length) {
- items.sort((a, b) => b.score - a.score).forEach(({ item }) => {
- resHtml += `${item.name}${item.url}
`;
- });
- } else {
- resHtml += "No result
"
- }
- results.innerHTML = resHtml;
- results.style.display = "block";
- } else {
- results.innerHTML = "";
- results.style.display = "none";
- }
+ async function makeSearch() {
+ const searchData = await fetch("search.json");
+ const data = await searchData.json();
+ const textbox = document.getElementById("search-box");
+ const results = document.getElementById("search-results");
+ const fuse = new Fuse(data, {
+ includeScore: true,
+ keys: ["name"],
+ });
+ textbox.addEventListener("change", textboxhandle);
+ textbox.addEventListener("keydown", textboxhandle);
+ textbox.addEventListener("keyup", textboxhandle);
+ textbox.addEventListener("keypress", textboxhandle);
+ function textboxhandle() {
+ const val = textbox.value.trim();
+ if (val.length) {
+ const items = fuse.search(val);
+ let resHtml = "";
+ if (items.length) {
+ items
+ .sort((a, b) => b.score - a.score)
+ .forEach(({ item }) => {
+ resHtml += `${item.name}${item.url}
`;
+ });
+ } else {
+ resHtml += "No result
";
}
+ results.innerHTML = resHtml;
+ results.style.display = "block";
+ } else {
+ results.innerHTML = "";
+ results.style.display = "none";
+ }
}
-}
+ }
+};
-init();
\ No newline at end of file
+init();
diff --git a/static/scripts/prettify/lang-css.js b/static/scripts/prettify/lang-css.js
index 041e1f5..2d8df51 100644
--- a/static/scripts/prettify/lang-css.js
+++ b/static/scripts/prettify/lang-css.js
@@ -1,2 +1,21 @@
-PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n"]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com",
-/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);
+PR.registerLangHandler(
+ PR.createSimpleLexer(
+ [["pln", /^[\t\n\f\r ]+/, null, " \t\r\n"]],
+ [
+ ["str", /^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/, null],
+ ["str", /^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/, null],
+ ["lang-css-str", /^url\(([^"')]*)\)/i],
+ ["kwd", /^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i, null],
+ ["lang-css-kw", /^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],
+ ["com", /^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],
+ ["com", /^(?:<\!--|--\>)/],
+ ["lit", /^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],
+ ["lit", /^#[\da-f]{3,6}/i],
+ ["pln", /^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],
+ ["pun", /^[^\s\w"']+/],
+ ]
+ ),
+ ["css"]
+);
+PR.registerLangHandler(PR.createSimpleLexer([], [["kwd", /^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]), ["css-kw"]);
+PR.registerLangHandler(PR.createSimpleLexer([], [["str", /^[^"')]+/]]), ["css-str"]);
diff --git a/static/scripts/prettify/prettify.js b/static/scripts/prettify/prettify.js
index eef5ad7..cb35c58 100644
--- a/static/scripts/prettify/prettify.js
+++ b/static/scripts/prettify/prettify.js
@@ -1,28 +1,413 @@
-var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
-(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
-[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
-l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
-q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
-q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
-"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
-a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
-for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
-"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
-H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
-J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
-I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]+/],["dec",/^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^