Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes #40 - Added external import to server mode on launch

  • Loading branch information...
commit 9727923a8abb1e9e101e54e6d94ae42bbda86aaa 1 parent 308288a
@davglass authored
Showing with 31 additions and 6 deletions.
  1. +31 −6 lib/server.js
View
37 lib/server.js
@@ -7,6 +7,13 @@ YUI.add('server', function(Y) {
*/
var Server = {
/**
+ * Cache for external mixed in data.
+ * @property _externalData
+ * @private
+ * @type Object
+ */
+ _externalData: null,
+ /**
* Middleware to parse the API docs per request
* @method parse
* @param {Request} req Express request object
@@ -17,6 +24,10 @@ YUI.add('server', function(Y) {
var json = (new Y.YUIDoc(Server.options)).run();
Server.options = Y.Project.mix(json, Server.options);
Server.builder = new Y.DocBuilder(Server.options, json);
+ if (Server._externalData) {
+ Server.options.externalData = Server._externalData;
+ Server.builder._mixExternal();
+ }
next();
},
/**
@@ -140,10 +151,7 @@ YUI.add('server', function(Y) {
Server.routes();
Server.app.listen(Server.options.port);
- Y.config.logExclude.yuidoc = true;
- Y.config.logExclude.docparser = true;
- Y.config.logExclude.builder = true;
-
+ Y.log('Starting server: http:/'+'/127.0.0.1:' + Server.options.port, 'info', 'server');
},
/**
* Start the server with the supplied options.
@@ -156,8 +164,25 @@ YUI.add('server', function(Y) {
Server.options.cacheTemplates = false; //Don't cache the Handlebars templates
Server.options.writeJSON = false; //Don't write the JSON file out
- Y.log('Starting server: http:/'+'/127.0.0.1:' + options.port, 'info', 'server');
- Server.init();
+
+ Y.config.logExclude.yuidoc = true;
+ Y.config.logExclude.docparser = true;
+ Y.config.logExclude.builder = true;
+
+ if (Server.options.external) {
+ Y.log('Fetching external data, this may take a minute', 'warn', 'server');
+ var json = (new Y.YUIDoc(Server.options)).run();
+ Server.options = Y.Project.mix(json, Server.options);
+ var builder = new Y.DocBuilder(Server.options, json);
+ builder.mixExternal(function() {
+ Y.log('External data fetched, launching server..', 'info', 'server');
+ Server._externalData = builder.options.externalData;
+ Server.init();
+ });
+
+ } else {
+ Server.init();
+ }
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.