diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js index 765c71d..7268d6c 100644 --- a/desktop/sources/scripts/commander.js +++ b/desktop/sources/scripts/commander.js @@ -178,18 +178,22 @@ function Commander (ronin) { for (const id in payload) { const parts = payload[id].split(' = ') const name = parts[0] - const params = parts[1].match(/\(([^)]+)\)/) - if (!params) { console.warn('Docs', 'Misformatted ' + name); continue } - this.dict[name] = params[1].split(',').map((word) => { return word.trim() }) + const parent = parts[1].match(/\(([^)]+)\)/) + const params = parent ? parent[1].split(',').map((word) => { return word.trim() }) : [] + const note = payload[id].indexOf('// ') > -1 ? payload[id].split('//')[1].trim() : '' + this.dict[name] = { note, params } + if (params.length < 1) { console.warn('Docs', 'Missing params for ' + name) } + if (note === '') { console.warn('Docs', 'Missing note for ' + name) } } - console.log('Dict', `Loaded ${Object.keys(this.dict).length} functions.`) + console.log('Docs', `Loaded ${Object.keys(this.dict).length} functions.`) console.log(this.toMarkdown()) }, toMarkdown: function () { return Object.keys(this.dict).reduce((acc, item, key) => { - return `${acc}- \`(${item} ${this.dict[item].reduce((acc, item) => { + const example = `${item} ${this.dict[item].params.reduce((acc, item) => { return `${acc}${item} ` - }, '').trim()})\`\n` + }, '').trim()}` + return `${acc}- \`(${example.trim()})\` ${this.dict[item].note}\n` }, '') } } diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index 0cdc753..fccd085 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -31,25 +31,25 @@ function Library (ronin) { return ronin.surface.crop(rect) } - this.folder = (path = ronin.source.path) => { + this.folder = (path = ronin.source.path) => { // Returns the content of a folder path. return fs.existsSync(path) ? fs.readdirSync(path) : [] } - this.exit = () => { - ronin.source.quit() + this.exit = (force = false) => { // Exits Ronin/ + ronin.source.quit(force) } // Logic - this.gt = (a, b) => { + this.gt = (a, b) => { // Returns true if a is greater than b, else false. return a > b } - this.lt = (a, b) => { + this.lt = (a, b) => { // Returns true if a is less than b, else false. return a < b } - this.eq = (a, b) => { + this.eq = (a, b) => { // Returns true if a is equal to b, else false. return a === b } diff --git a/desktop/sources/scripts/source.js b/desktop/sources/scripts/source.js index 29a6457..71bb8eb 100644 --- a/desktop/sources/scripts/source.js +++ b/desktop/sources/scripts/source.js @@ -75,8 +75,8 @@ function Source (ronin) { ronin.commander._input.value = data } - this.quit = function () { - if (this.hasChanges() === true) { + this.quit = function (force = false) { + if (this.hasChanges() === true && force === false) { this.verify() } else { app.exit()