mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-05-16 10:29:37 +08:00
chore(doc-gen): improve error page navigation
This commit is contained in:
@@ -10,6 +10,7 @@ module.exports = function(config) {
|
||||
|
||||
config.append('processing.processors', [
|
||||
require('./processors/git-data'),
|
||||
require('./processors/error-docs'),
|
||||
require('./processors/keywords'),
|
||||
require('./processors/versions-data'),
|
||||
require('./processors/pages-data'),
|
||||
|
||||
42
docs/config/processors/error-docs.js
Normal file
42
docs/config/processors/error-docs.js
Normal file
@@ -0,0 +1,42 @@
|
||||
var _ = require('lodash');
|
||||
var log = require('winston');
|
||||
var path = require('canonical-path');
|
||||
|
||||
module.exports = {
|
||||
name: 'error-docs',
|
||||
description: 'Compute the various fields for docs in the Error area',
|
||||
runAfter: ['tags-extracted'],
|
||||
init: function(config, injectables) {
|
||||
injectables.value('errorNamespaces', {});
|
||||
},
|
||||
process: function(docs, partialNames, errorNamespaces) {
|
||||
|
||||
// Create error namespace docs and attach error docs to each
|
||||
_.forEach(docs, function(doc) {
|
||||
if ( doc.docType === 'error' ) {
|
||||
|
||||
var namespaceDoc = errorNamespaces[doc.namespace];
|
||||
if ( !namespaceDoc ) {
|
||||
// First time we came across this namespace, so create a new one
|
||||
namespaceDoc = errorNamespaces[doc.namespace] = {
|
||||
area: doc.area,
|
||||
name: doc.namespace,
|
||||
errors: [],
|
||||
path: path.dirname(doc.path),
|
||||
outputPath: path.dirname(doc.outputPath) + '.html',
|
||||
docType: 'errorNamespace'
|
||||
};
|
||||
}
|
||||
|
||||
// Add this error to the namespace
|
||||
namespaceDoc.errors.push(doc);
|
||||
doc.namespace = namespaceDoc;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
return docs.concat(_.values(errorNamespaces));
|
||||
}
|
||||
};
|
||||
@@ -103,7 +103,7 @@ var navGroupMappers = {
|
||||
return {
|
||||
name: page.name,
|
||||
href: page.path,
|
||||
type: 'error'
|
||||
type: page.docType === 'errorNamespace' ? 'section' : 'error'
|
||||
};
|
||||
})];
|
||||
},
|
||||
@@ -142,7 +142,8 @@ module.exports = {
|
||||
|
||||
// We are only interested in docs that are in a area and not landing pages
|
||||
var navPages = _.filter(docs, function(page) {
|
||||
return page.area && page.docType != 'componentGroup';
|
||||
return page.area &&
|
||||
page.docType != 'componentGroup';
|
||||
});
|
||||
|
||||
// Generate an object collection of pages that is grouped by area e.g.
|
||||
|
||||
28
docs/config/templates/errorNamespace.template.html
Normal file
28
docs/config/templates/errorNamespace.template.html
Normal file
@@ -0,0 +1,28 @@
|
||||
{% extends 'base.template.html' %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{$ doc.name $}</h1>
|
||||
|
||||
<div class="description">
|
||||
Here are the list of errors in the {$ doc.name $} namespace.
|
||||
|
||||
</div>
|
||||
|
||||
<div class="component-breakdown">
|
||||
<div>
|
||||
<table class="definition-table">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
{% for errorDoc in doc.errors -%}
|
||||
<tr>
|
||||
<td><a href="{$ errorDoc.path $}">{$ errorDoc.name $}</td>
|
||||
<td>{$ errorDoc.fullName $}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user