Added docs tools

This commit is contained in:
Devine Lu Linvega
2017-09-27 13:25:27 +13:00
parent 2b5408eace
commit 6ffabd2318
5 changed files with 136 additions and 47 deletions

View File

@@ -11,6 +11,7 @@
<script type="text/javascript" src="scripts/layers/guide.js"></script>
<script type="text/javascript" src="scripts/layers/render.js"></script>
<script type="text/javascript" src="scripts/docs.js"></script>
<script type="text/javascript" src="scripts/io.js"></script>
<script type="text/javascript" src="scripts/query.js"></script>
<script type="text/javascript" src="scripts/keyboard.js"></script>
@@ -26,6 +27,11 @@
</head>
<body>
<script type="text/javascript">
const {dialog,app} = require('electron').remote;
const fs = require('fs');
const app_path = app.getAppPath();
var ronin = new Ronin();
ronin.install();
</script>

86
sources/scripts/docs.js Normal file
View File

@@ -0,0 +1,86 @@
function Docs()
{
this.export = function()
{
var html = "";
html += this.print_intro();
html += "## Modules\n";
html += this.print_modules(ronin.modules);
html += this.print_license();
var str = html;
dialog.showSaveDialog((fileName) => {
if (fileName === undefined){ return; }
fs.writeFile("README.md", str, (err) => {
if(err){ alert("An error ocurred creating the file "+ err.message); return; }
});
});
return html;
}
this.print_intro = function()
{
html = "# Ronin\n";
html += "Ronin is a simple open-source graphic design tool.\n";
html += "<img src='https://raw.githubusercontent.com/hundredrabbits/Ronin/master/PREVIEW.jpg' width='600'/>\n";
return html;
}
this.print_modules = function(modules)
{
var html = "";
for(module_name in modules){
var module = modules[module_name];
html += "## "+module_name+"\n";
html += this.print_settings(module.settings);
html += this.print_methods(module.methods);
html += this.print_ports(module.ports);
}
return html;
}
this.print_settings = function(settings)
{
var html = "### Settings\n";
for(setting_name in settings){
var setting = settings[setting_name];
html += "- "+setting_name+"\n";
}
return html;
}
this.print_methods = function(methods)
{
var html = "### Methods\n";
for(method_name in methods){
var method = methods[method_name];
html += "- "+method_name+"\n";
}
return html;
}
this.print_ports = function(ports)
{
var html = "### Ports\n";
for(port_name in ports){
var port = ports[setting_name];
html += "- "+port_name+"\n";
}
return html;
}
this.print_license = function()
{
html = "## License\n";
html += "See the [LICENSE](LICENSE.md) file for license rights and limitations (CC).\n";
return html;
}
}

View File

@@ -33,6 +33,11 @@ function Keyboard()
ronin.render.clear();
}
if(e.key == "H" && (e.ctrlKey || e.metaKey) && e.shiftKey){
e.preventDefault();
ronin.docs.export();
}
ronin.hint.update(e);
}
}

View File

@@ -8,6 +8,7 @@ function Ronin()
this.commander = new Commander();
this.cursor = new Cursor();
this.hint = new Hint();
this.docs = new Docs();
this.grid = new Grid();
this.guide = new Guide();