From 8e2675029f5ca404a7c649cc161df3ea642d941f Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sat, 28 Apr 2012 22:45:28 -0700 Subject: chore(docs): re-skin main documentation --- docs/src/example.js | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 docs/src/example.js (limited to 'docs/src/example.js') diff --git a/docs/src/example.js b/docs/src/example.js new file mode 100644 index 00000000..519b6cb1 --- /dev/null +++ b/docs/src/example.js @@ -0,0 +1,126 @@ +var seqCount = 0; +var usedIds = {}; +var makeUnique = { + 'index.html': true, + 'style.css': true, + 'script.js': true, + 'unit.js': true, + 'spec.js': true, + 'scenario.js': true +} + +function ids(list) { + return list.map(function(item) { return item.id; }).join(' '); +}; + + +exports.Example = function(scenarios) { + this.module = ''; + this.deps = ['angular.js']; + this.html = []; + this.css = []; + this.js = []; + this.unit = []; + this.scenario = []; + this.scenarios = scenarios; +} + +exports.Example.prototype.setModule = function(module) { + if (module) { + this.module = module; + } +}; + +exports.Example.prototype.addDeps = function(deps) { + deps && deps.split(/[\s\,]/).forEach(function(dep) { + if (dep) { + this.deps.push(dep); + } + }, this); +}; + +exports.Example.prototype.addSource = function(name, content) { + var ext = name == 'scenario.js' ? 'scenario' : name.split('.')[1], + id = name; + + if (makeUnique[name] && usedIds[id]) { + id = name + '-' + (seqCount++); + } + usedIds[id] = true; + + this[ext].push({name: name, content: content, id: id}); + if (name.match(/\.js$/) && name !== 'spec.js' && name !== 'unit.js' && name != 'scenario.js') { + this.deps.push(name); + } + if (ext == 'scenario') { + this.scenarios.push(content); + } +}; + +exports.Example.prototype.toHtml = function() { + return '