Skip to content

Commit

Permalink
add(tools): Tool to check the output of a single repo
Browse files Browse the repository at this point in the history
  • Loading branch information
janmeier committed Jun 23, 2016
1 parent 7f1e367 commit 4654325
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 4 deletions.
54 changes: 54 additions & 0 deletions bin/watcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
var gather = require('../lib/gather')
, structure = require('../lib/structure')
, viewParams = require('../lib/view-params')
, Doclet = require('../lib/models/doclet')
, _ = require('underscore')
, jade = require('jade')
, chokidar = require('chokidar')
, path = require('path')
, branch = require('git-branch')
, express = require('express')
, io = require('socket.io')
, http = require('http')
, argv = require('optimist').argv;

if (argv.h) {
console.log('-p 3000 -d [dir]');
return;
}

var app = express()
, server = http.Server(app)
, socket = io(server);

server.listen(argv.p || 3000);

var repoPath = path.resolve(argv.d);
var dbEntry = gather.gatherDocletsAndMeta(repoPath, false, branch.sync(repoPath));

if (dbEntry.error) {
console.log(dbEntry);
return;
}

app.get('/', function (req, res) {
res.send(jade.renderFile('./views/api.jade', _.extend({
doclet: new Doclet({
data: {
hot: true,
doclets: gather.createDoclets(dbEntry.config, repoPath),
articles: dbEntry.articles
}
}),
moment: require('moment'),
_: _
}, dbEntry, structure, viewParams)));
});

app.use(express.static('assets'));

var watch = path.join(repoPath, dbEntry.config.dir);
console.log('Watching ', watch);
chokidar.watch(watch).on('all', function () {
socket.emit('change');
});
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@
},
"devDependencies": {
"acme-jsdoc-example": "lipp/acme-jsdoc-example",
"chokidar": "^1.6.0",
"coveralls": "^2.11.6",
"csslint": "^0.10.0",
"git-branch": "^0.3.0",
"istanbul": "^0.4.1",
"mocha": "^2.5.0",
"optimist": "^0.6.1",
"request": "^2.72.0",
"sinon": "^1.17.2",
"socket.io": "^1.4.6",
"standard": "^5.4.1",
"taffydb": "^2.7.2"
},
Expand Down
13 changes: 9 additions & 4 deletions views/doclayout.jade
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mixin funcdeclx(name, func, isCtor)

extends layout

block styles
block styles
link(rel="stylesheet", href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/styles/default.min.css")


Expand Down Expand Up @@ -109,8 +109,13 @@ block scripts
//window.location = window.location.href;
console.log(window.location.href);
};


if doclet.data.hot
script(src = "/socket.io/socket.io.js")
script.
var socket = io.connect('http://localhost:3000');
socket.on('change', function () {
window.location.reload()
});

block content
#title
Expand Down Expand Up @@ -181,7 +186,7 @@ block content
include nav.jade
.main
block api

a.big.circular.icon.button#scroll-top(href='#title')
i.big.circular.icon.angle.up

Expand Down

0 comments on commit 4654325

Please sign in to comment.