UNPKG

short-jsdoc

Version:

short and simple jsdoc Object Oriented syntax format and implementation

104 lines (84 loc) 3.09 kB
//@module shortjsdoc.html // this is the main class for all the application // utilities for rendering jsdoc data generated by jsdocgenerator1 js-indentator plugin // using backbone. The user should provide with underscore templates. // @class AbstractView @extend Backbone.View @module shortjsdoc // @author: sgurin //@class Application /* @constructor Application @param {Object} data is the data.json object outputed by running var maker = new JsDocMaker(); maker.parseFile(myCodeString); maker.postProccess(); var data = maker.data; */ var Application = function(data) { //@property {String} textFormat can be markdown or html. default: markdown this.textFormat = 'markdown'; //@property {Object} templates The templates dictionary (given by template-output.js) this.templates = shortjsdoc; /*@property {Object} data is the data.json object outputed by running: var maker = new JsDocMaker(); maker.parseFile(myCodeString); maker.postProccess(); var data = maker.data; */ this.data = data; //@property {JsDocMaker} maker the JsDocMaker instance we will use for loading the parsed data and doing some post processing stage (type binding and so) this.maker = new JsDocMaker(); // this.maker.lineCommentSeparator = '888898888'; this.maker.data = data; this.maker.postProccess(); this.maker.postProccessBinding(); this.maker.postProccessInherited(); // <-- important - explicitly ask the framework to calculate inherited methods&properties window.shortjsdocdata = data;//for debugging only if(jQuery('#mainContainer').size()===0) { jQuery('body').append('<div id="mainContainer"></div>'); } this.$containerEl = jQuery('#mainContainer'); this.$body = jQuery('.main-view-container'); }; _(Application.prototype).extend({ //@method start starts the application by instantiating routers and history and navigating to the index. start: function() { this.router = new JsDocRouter(this); Backbone.history.start(); var navigateTo = Backbone.history.getHash() || 'index'; Backbone.history.navigate(navigateTo, {trigger: true}); } //@method showView @param {AbstractView} view , showView: function(view) { this.applicationView = this.applicationView || new ApplicationView(this); this.currentView = view; this.$containerEl.empty(); this.applicationView.renderIn(this.$containerEl); document.title = view.title || document.title; } //@method refreshWithNewModel @param {Object}data , refreshWithNewModel: function(data) { this.data = data; Backbone.history.navigate('#index', {trigger: true}); this.showView(this.currentView); } //@method showErrorView @param {String}s , showErrorView: function(s) { var errorView = new AbstractView(); errorView.application = this; errorView.template = _.template('<h1>'+s+'</h1>'); this.showView(errorView) } }); //@method start an application loading it with given data. @static //@param data the output of passing jsindentator JsDocMaker. Application.startApplication = function(data) { var app = new Application(data); app.start(); };