diff --git a/docs/assets/js/docs.js b/docs/assets/js/docs.js index 130c866..4db249c 100644 --- a/docs/assets/js/docs.js +++ b/docs/assets/js/docs.js @@ -28,7 +28,7 @@ class Docs { } /** - * Called on instanciation by the constructor. + * Called on initialization by the constructor. */ async onExec() { this.routesData = await this.fetchRoutes(); @@ -223,10 +223,22 @@ class RoutingItem { this.hidden = hidden; } - buildSelf() { - const element = document.createElement('div'); - element.innerText = this.name; - return element; + /** + * @param {*} force Wether to force generation or not despite the hidden property. + * @returns {HTMLElement} The RoutingItem as an HTML element (div). + */ + buildSelf(force = false) { + if (this.hidden === false || typeof this.hidden === 'undefined') { + force = true; + } + + if (force) { + const element = document.createElement('div'); + + element.innerText = this.name; + + return element; + } } } @@ -249,7 +261,7 @@ class Route extends RoutingItem { */ buildSelf(force = false) { if (this.hidden === false || typeof this.hidden === 'undefined') { - force = true + force = true; } if (force) { @@ -259,12 +271,13 @@ class Route extends RoutingItem { element.innerText = this.name; return element; - } else { - return; } } /** + * Loads the Route content and returns it as text. + * @param {string} prefix (optional) An url prefix to add *(i.e: different location)*. + * @param {string} suffix (optional) An url suffix to add *(i.e: file extension)*. * @returns {string} The document content to load as a string. */ async loadSelf(prefix, suffix) { @@ -276,8 +289,6 @@ class Route extends RoutingItem { if (typeof suffix === 'undefined') { suffix = ''; - } else { - suffix += '/'; } const response = await fetch(`${prefix}${this.filepath}${suffix}`); @@ -305,6 +316,9 @@ class RoutingNode extends RoutingItem { this.onExec(); } + /** + * Called on initialization by the constructor. + */ onExec() { this.routesData.forEach(routeData => { if ('routes' in routeData) { @@ -316,7 +330,8 @@ class RoutingNode extends RoutingItem { } /** - * @returns {HTMLUListElement} The RoutingNode as an HTML unordered list. + * Builds the HTML representation of the RoutingNode as an HTML unorded list. + * @returns {HTMLUListElement} The RoutingNode as an HTML list. */ buildSelf(force = false) { if (this.hidden === false || typeof this.hidden === 'undefined') { @@ -339,6 +354,11 @@ class RoutingNode extends RoutingItem { } } + /** + * @private + * @param {string} text + * @param {Function} onClickCallback (optional) + */ buildSelf_Heading(text, onClickCallback) { const wrapper = document.createElement('div'); const headingText = document.createElement('span'); @@ -359,6 +379,7 @@ class RoutingNode extends RoutingItem { } /** + * @private * @param {Array.<(Route,RoutingNode)>} entries */ buildSelf_List(entries) {