diff options
| author | Julie | 2014-01-06 15:13:57 -0800 |
|---|---|---|
| committer | Julie | 2014-01-08 13:07:58 -0800 |
| commit | b6c42d5e8155edc9013bd531f553c278ce37c3c8 (patch) | |
| tree | 225bbc1e0522b42b2cdd9bccfe36452ad88ad3d4 /docs/src/ngdoc.js | |
| parent | 1c045f1b463cf8c2d0c470fc6e44170997e85d89 (diff) | |
| download | angular.js-b6c42d5e8155edc9013bd531f553c278ce37c3c8.tar.bz2 | |
feat(docs): adding the <doc:protractor> ngdoc-tag
This is the first step in migrating tests from <doc:scenario> to <doc:protractor>.
In-documentation examples with doc:protractor sections will have their contents
output to a tab on the docs site as well as output to a standalone test file in
build/docs/ptore2e.
Diffstat (limited to 'docs/src/ngdoc.js')
| -rw-r--r-- | docs/src/ngdoc.js | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index 37f5aeaf..c009c950 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -35,6 +35,7 @@ var lookupMinerrMsg = function (doc) { exports.trim = trim; exports.metadata = metadata; exports.scenarios = scenarios; +exports.writeProtractorTest = writeProtractorTest; exports.merge = merge; exports.checkBrokenLinks = checkBrokenLinks; exports.Doc = Doc; @@ -155,6 +156,7 @@ function Doc(text, file, line) { this.line = line; } this.scenarios = this.scenarios || []; + this.protractorTests = this.protractorTests || []; this.requires = this.requires || []; this.param = this.param || []; this.properties = this.properties || []; @@ -292,7 +294,7 @@ Doc.prototype = { replace(/<example(?:\s+module="([^"]*)")?(?:\s+deps="([^"]*)")?(\s+animations="true")?>([\s\S]*?)<\/example>/gmi, function(_, module, deps, animations, content) { - var example = new Example(self.scenarios); + var example = new Example(self.scenarios, self.protractorTests); if(animations) { example.enableAnimations(); example.addDeps('angular-animate.js'); @@ -329,7 +331,7 @@ Doc.prototype = { }). replace(/^<doc:example(\s+[^>]*)?>([\s\S]*)<\/doc:example>/mi, function(_, attrs, content) { var html, script, scenario, - example = new Example(self.scenarios); + example = new Example(self.scenarios, self.protractorTests); example.setModule((attrs||'module=""').match(/^\s*module=["'](.*)["']\s*$/)[1]); content. @@ -347,6 +349,8 @@ Doc.prototype = { }). replace(/(<doc:scenario>)([\s\S]*)(<\/doc:scenario>)/mi, function(_, before, content){ example.addSource('scenario.js', content); + }).replace(/(<doc:protractor>)([\s\S]*)(<\/doc:protractor>)/mi, function(_, before, content){ + example.addSource('protractorTest.js', content); }); return placeholder(example.toHtml()); @@ -1106,6 +1110,22 @@ function scenarios(docs){ } } +function writeProtractorTest(doc){ + var lines = []; + lines.push('describe("' + doc.section + '/' + doc.id + '", function() {'); + lines.push(' beforeEach(function() {'); + lines.push(' browser.get("index-nocache.html#!/' + doc.section + '/' + doc.id + '");'); + lines.push(' });'); + lines.push(''); + doc.protractorTests.forEach(function(test){ + lines.push(indentCode(trim(test), 2)); + lines.push(''); + }); + lines.push('});'); + lines.push(''); + return lines.join('\n'); +} + ////////////////////////////////////////////////////////// function metadata(docs){ |
