diff --git a/docs/config/processors/error-docs.js b/docs/config/processors/error-docs.js index 80a7b996d432..3fed96c578d5 100644 --- a/docs/config/processors/error-docs.js +++ b/docs/config/processors/error-docs.js @@ -8,8 +8,15 @@ module.exports = { runAfter: ['tags-extracted'], init: function(config, injectables) { injectables.value('errorNamespaces', {}); + + var minerrInfoPath = config.get('processing.errors.minerrInfoPath'); + if ( !minerrInfoPath ) { + throw new Error('Error in configuration: Please provide a path to the minerr info file (errors.json) ' + + 'in the `config.processing.errors.minerrInfoPath` property'); + } + injectables.value('minerrInfo', require(minerrInfoPath)); }, - process: function(docs, partialNames, errorNamespaces) { + process: function(docs, partialNames, errorNamespaces, minerrInfo) { // Create error namespace docs and attach error docs to each _.forEach(docs, function(doc) { @@ -32,6 +39,8 @@ module.exports = { namespaceDoc.errors.push(doc); doc.namespace = namespaceDoc; + doc.formattedErrorMessage = minerrInfo.errors[doc.namespace.name][doc.name]; + } }); diff --git a/docs/config/templates/error.template.html b/docs/config/templates/error.template.html new file mode 100644 index 000000000000..f48b397b87e7 --- /dev/null +++ b/docs/config/templates/error.template.html @@ -0,0 +1,17 @@ +{% extends "base.template.html" %} + +{% block content %} +

Error: {$ doc.id $} +
{$ doc.fullName $}
+

+ +
+
{$ doc.formattedErrorMessage $}
+
+ +

Description

+
+ {$ doc.description | marked $} +
+ +{% endblock %} \ No newline at end of file diff --git a/docs/docs.config.js b/docs/docs.config.js index 536728fba27f..afe982fda7c5 100644 --- a/docs/docs.config.js +++ b/docs/docs.config.js @@ -31,6 +31,9 @@ module.exports = function(config) { }); config.set('processing.examples.dependencyPath', '../../..'); + + config.set('processing.errors.minerrInfoPath', path.resolve(basePath, '../build/errors.json')); + config.set('rendering.outputFolder', '../build/docs'); config.set('logging.level', 'info'); diff --git a/test/e2e/docsAppE2E.js b/test/e2e/docsAppE2E.js index da0726b86fd3..8fe30c38b219 100644 --- a/test/e2e/docsAppE2E.js +++ b/test/e2e/docsAppE2E.js @@ -39,22 +39,31 @@ describe('docs.angularjs.org', function () { expect(code.getText()).toContain('guest!!!'); }); + it('should be resilient to trailing slashes', function() { browser.get('index-debug.html#!/api/ng/function/angular.noop/'); var pageBody = element(by.css('h1')); expect(pageBody.getText()).toEqual('angular.noop'); }); + it('should be resilient to trailing "index"', function() { browser.get('index-debug.html#!/api/ng/function/angular.noop/index'); var pageBody = element(by.css('h1')); expect(pageBody.getText()).toEqual('angular.noop'); }); + it('should be resilient to trailing "index/"', function() { browser.get('index-debug.html#!/api/ng/function/angular.noop/index/'); var pageBody = element(by.css('h1')); expect(pageBody.getText()).toEqual('angular.noop'); }); + + + it('should display formatted error messages on error doc pages', function() { + browser.get('index-debug.html#!error/ng/areq?p0=Missing&p1=not%20a%20function,%20got%20undefined'); + expect(element(by.css('.minerr-errmsg')).getText()).toEqual("Argument 'Missing' is not a function, got undefined"); + }); }); }); \ No newline at end of file