Implemented docs
This commit is contained in:
parent
521ece7937
commit
eedd6868a1
@ -10,8 +10,8 @@ function Commander (ronin) {
|
||||
this.el.appendChild(this._input)
|
||||
this.el.appendChild(this._status)
|
||||
host.appendChild(this.el)
|
||||
|
||||
this._input.addEventListener('input', this.onInput)
|
||||
this.docs.install()
|
||||
}
|
||||
|
||||
this.start = function () {
|
||||
@ -162,4 +162,27 @@ function Commander (ronin) {
|
||||
this.hide()
|
||||
}
|
||||
}
|
||||
|
||||
// Docs micro-module
|
||||
|
||||
this.docs = {
|
||||
path: 'sources/scripts/library.js',
|
||||
load: function () {
|
||||
const fs = require('fs')
|
||||
if (!fs.existsSync(this.path)) { console.warn('Docs', 'File does not exist: ' + this.path); return }
|
||||
const lines = fs.readFileSync(this.path, 'utf8').split('\n').filter((line) => { return line.substr(0, 7) === ' this.' })
|
||||
return lines.map((line) => { return line.trim().substr(5, line.length - 5).trim() })
|
||||
},
|
||||
install: function (payload = this.load()) {
|
||||
const dict = {}
|
||||
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 }
|
||||
dict[name] = params[1].split(',').map((word) => { return word.trim() })
|
||||
}
|
||||
console.log(dict)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
function Library (ronin) {
|
||||
console.log(ronin)
|
||||
this.open = async (path) => {
|
||||
return ronin.surface.open(path)
|
||||
}
|
||||
@ -337,5 +336,4 @@ function Library (ronin) {
|
||||
|
||||
// javascript interop
|
||||
this.js = window
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user