it('should have shortName', function(){ var d1 = new Doc('@name a.b.c').parse(); var d2 = new Doc('@name a.b.ng:c').parse(); var d3 = new Doc('@name some text: more text').parse(); expect(ngdoc.metadata([d1])[0].shortName).toEqual('c'); expect(ngdoc.metadata([d2])[0].shortName).toEqual('ng:c'); expect(ngdoc.metadata([d3])[0].shortName).toEqual('more text'); });
it('should have depth information', function(){ var d1 = new Doc('@name a.b.c').parse(); var d2 = new Doc('@name a.b.ng:c').parse(); var d3 = new Doc('@name some text: more text').parse(); expect(ngdoc.metadata([d1])[0].depth).toEqual(2); expect(ngdoc.metadata([d2])[0].depth).toEqual(2); expect(ngdoc.metadata([d3])[0].depth).toEqual(1); });
function writeTheRest(writesFuture) { var metadata = ngdoc.metadata(docs); writesFuture.push(writer.copyDir('img')); writesFuture.push(writer.copyDir('examples')); var manifest = 'manifest="/build/docs/appcache.manifest"'; writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index.html', writer.replace, {'doc:manifest': manifest})); writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-nocache.html', writer.replace, {'doc:manifest': ''})); writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-jq.html', writer.replace, {'doc:manifest': manifest})); writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-jq-nocache.html', writer.replace, {'doc:manifest': ''})); writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-debug.html', writer.replace, {'doc:manifest': ''})); writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-jq-debug.html', writer.replace, {'doc:manifest': ''})); writesFuture.push(writer.copyTpl('offline.html')); writesFuture.push(writer.copyTpl('docs-scenario.html')); writesFuture.push(writer.copyTpl('jquery.min.js')); writesFuture.push(writer.output('docs-keywords.js', ['NG_PAGES=', JSON.stringify(metadata).replace(/{/g, '\n{'), ';'])); writesFuture.push(writer.output('sitemap.xml', new SiteMap(docs).render())); writesFuture.push(writer.output('docs-scenario.js', ngdoc.scenarios(docs))); writesFuture.push(writer.output('robots.txt', 'Sitemap: http://docs.angularjs.org/sitemap.xml\n')); writesFuture.push(writer.output('appcache.manifest',appCache())); writesFuture.push(writer.copyTpl('.htaccess')); writesFuture.push(writer.merge(['docs.js', 'doc_widgets.js'], 'docs-combined.js')); writesFuture.push(writer.merge(['docs.css', 'doc_widgets.css'], 'docs-combined.css')); writesFuture.push(writer.merge(['syntaxhighlighter/shCore.js', 'syntaxhighlighter/shBrushJScript.js', 'syntaxhighlighter/shBrushXml.js'], 'syntaxhighlighter/syntaxhighlighter-combined.js')); writesFuture.push(writer.merge(['syntaxhighlighter/shCore.css', 'syntaxhighlighter/shThemeDefault.css'], 'syntaxhighlighter/syntaxhighlighter-combined.css')); }
}).then(function generateHtmlDocPartials(docs_) { docs = docs_; ngdoc.merge(docs); var fileFutures = []; docs.forEach(function(doc){ fileFutures.push(writer.output('partials/' + doc.section + '/' + doc.id + '.html', doc.html())); }); writeTheRest(fileFutures); return Q.deep(fileFutures); }).then(function generateManifestFile() {
it('should merge child with parent', function(){ var parent = new Doc({name:'angular.service.abc'}); var methodA = new Doc({name:'methodA', methodOf:'angular.service.abc'}); var methodB = new Doc({name:'methodB', methodOf:'angular.service.abc'}); var propA = new Doc({name:'propA', propertyOf:'angular.service.abc'}); var propB = new Doc({name:'propB', propertyOf:'angular.service.abc'}); var docs = [methodB, methodA, propB, propA, parent]; // keep wrong order; ngdoc.merge(docs); expect(docs.length).toEqual(1); expect(docs[0].name).toEqual('angular.service.abc'); expect(docs[0].methods).toEqual([methodA, methodB]); expect(docs[0].properties).toEqual([propA, propB]); });
it('should put angular.fn() in front of angular.widget, etc', function(){ expect(ngdoc.metadata([angular_widget, angular_y, angular_x]).map(property('id'))) .toEqual(['angular.x', 'angular.y', 'angular.widget' ]); });
it('should say where is the non-existing link', function() { ngdoc.merge(docs); expect(console.log.argsForCall[0][0]).toContain('api/fake.id1'); });
it('should say which link doesn\'t exist', function() { ngdoc.merge(docs); expect(console.log.argsForCall[0][0]).toContain('non-existing-link'); });
it('should log warning when any link doesn\'t exist', function() { ngdoc.merge(docs); expect(console.log).toHaveBeenCalled(); expect(console.log.argsForCall[0][0]).toContain('WARNING:'); });