mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
added readme renderability
This commit is contained in:
parent
b0cacf5e2d
commit
470d58927e
5 changed files with 108 additions and 4 deletions
20
README.md
20
README.md
|
@ -1,3 +1,19 @@
|
|||
# Kibana 4
|
||||
<!-- render {"template":"# Kibana <%= pkg.version %>"} --><!-- /render -->
|
||||
|
||||
[](https://magnum.travis-ci.com/elasticsearch/kibana4)
|
||||
[](https://magnum.travis-ci.com/elasticsearch/kibana4)
|
||||
|
||||
Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elasticsearch.
|
||||
|
||||
## Installation
|
||||
|
||||
* Download: http://www.elasticsearch.org/overview/kibana/installation/
|
||||
* Run **bin/kibana** on unix, or **bin/kibana.bat** on Windows.
|
||||
* Visit http://localhost:5601
|
||||
|
||||
## Need Help?
|
||||
|
||||
Need help? Try #elasticsearch or #logstash on Freenode IRC. You can also find help on the elasticsearch-users@googlegroups.com or logstash-users@googlegroups.com mailing lists.
|
||||
|
||||
You can also find documentation at http://www.elasticsearch.com/guide/en/kibana/current
|
||||
|
||||
<!-- include {"path":"src/kibana/apps/settings/README.md"} --><!-- /include -->
|
|
@ -41,7 +41,7 @@
|
|||
"scripts": {
|
||||
"test": "grunt test --use-jruby",
|
||||
"server": "grunt server",
|
||||
"precommit": "grunt jshint todos"
|
||||
"precommit": "grunt jshint todos render_readme"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -50,6 +50,10 @@ module.exports = function (grunt) {
|
|||
src: '<%= root %>/LICENSE.md',
|
||||
dest: '<%= build %>/dist/LICENSE.md'
|
||||
},
|
||||
{
|
||||
src: '<%= root %>/README.md',
|
||||
dest: '<%= build %>/dist/README.md'
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: '<%= build %>/kibana/',
|
||||
|
|
|
@ -12,7 +12,7 @@ module.exports = function (grunt) {
|
|||
},
|
||||
files: [
|
||||
{
|
||||
src: [join(src, 'server', 'DIST_README.md')],
|
||||
src: [join(src, 'server', 'README.md')],
|
||||
dest: join(build, 'dist', 'README.md')
|
||||
},
|
||||
{
|
||||
|
|
84
tasks/render_readme.js
Normal file
84
tasks/render_readme.js
Normal file
|
@ -0,0 +1,84 @@
|
|||
module.exports = function (grunt) {
|
||||
var expect = require('expect.js');
|
||||
var root = require('path').join.bind(null, __dirname, '../');
|
||||
|
||||
var README = root('README.md');
|
||||
var RE_COMMENT = /<!--(.+?)-->/g;
|
||||
|
||||
var tags = {
|
||||
render: function (args) {
|
||||
return grunt.config.process(args.template);
|
||||
},
|
||||
include: function (args) {
|
||||
return grunt.file.read(args.path);
|
||||
}
|
||||
};
|
||||
|
||||
grunt.registerTask('render_readme', function () {
|
||||
var input = grunt.file.read(README);
|
||||
var chunks = [];
|
||||
|
||||
var comments = findAndParseComments(input);
|
||||
|
||||
|
||||
for (var i = 0; i < comments.length; i += 2) {
|
||||
var open = comments[i];
|
||||
var close = comments[i + 1];
|
||||
|
||||
expect(close.tag).to.be('/' + open.tag);
|
||||
|
||||
if (!tags[open.tag]) {
|
||||
throw new TypeError('unkown tag name ' + open.tag);
|
||||
}
|
||||
|
||||
chunks.push(input.substring(open.i0, open.i1));
|
||||
chunks.push('\n' + tags[open.tag](open.args).trim() + '\n');
|
||||
chunks.push(input.substring(close.i0, close.i1));
|
||||
|
||||
// add the text between this and the next tag
|
||||
if (comments.length > i + 2) {
|
||||
var next = comments[i + 2];
|
||||
chunks.push(input.substring(close.i1, next.i0));
|
||||
}
|
||||
}
|
||||
|
||||
var output = chunks.join('');
|
||||
if (output === input) {
|
||||
grunt.log.ok('no update to the readme');
|
||||
return;
|
||||
}
|
||||
|
||||
grunt.log.ok('readme updated and added to git');
|
||||
grunt.file.write(README, output);
|
||||
grunt.util.spawn({
|
||||
cmd: 'git',
|
||||
args: ['add', README]
|
||||
}, this.async());
|
||||
});
|
||||
|
||||
function findAndParseComments(input) {
|
||||
var comments = [];
|
||||
var match;
|
||||
var comment;
|
||||
|
||||
while (match = RE_COMMENT.exec(input)) {
|
||||
var parts = match[1].trim().split(/\s+/);
|
||||
comment = {
|
||||
tag: parts.shift().trim(),
|
||||
args: parts.join(' ').trim(),
|
||||
i0: match.index,
|
||||
i1: match.index + match[0].length
|
||||
};
|
||||
|
||||
if (comment.args) {
|
||||
comment.args = JSON.parse(comment.args);
|
||||
} else {
|
||||
comment.args = null;
|
||||
}
|
||||
|
||||
comments.push(comment);
|
||||
}
|
||||
|
||||
return comments;
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue