feat(docs): provide index pages for each angular module

This commit is contained in:
Matias Niemelä
2013-10-16 22:48:32 -04:00
parent 3f568b22f9
commit a7e12b7959
13 changed files with 400 additions and 18 deletions

View File

@@ -213,6 +213,14 @@ Doc.prototype = {
return words.join(' ');
},
shortDescription : function() {
var text = this.description.split("\n")[0];
text = text.replace(/<.+?\/?>/g, '');
text = text.replace(/{/g,'&#123;');
text = text.replace(/}/g,'&#125;');
return text;
},
getMinerrNamespace: function () {
if (this.ngdoc !== 'error') {
throw new Error('Tried to get the minErr namespace, but @ngdoc ' +
@@ -471,11 +479,20 @@ Doc.prototype = {
(this.ngdoc === 'error' ? this.name : '') ||
(((this.file||'').match(/.*(\/|\\)([^(\/|\\)]*)\.ngdoc/)||{})[2]) || // try to extract it from file name
this.name; // default to name
this.moduleName = parseModuleName(this.id);
this.description = this.markdown(this.description);
this.example = this.markdown(this.example);
this['this'] = this.markdown(this['this']);
return this;
function parseModuleName(id) {
var module = id.split('.')[0];
if(module == 'angular') {
module = 'ng';
}
return module;
}
function flush() {
if (atName) {
var text = trim(atText.join('\n')), match;
@@ -1106,6 +1123,8 @@ function metadata(docs){
name: title(doc),
shortName: shortName,
type: doc.ngdoc,
moduleName: doc.moduleName,
shortDescription: doc.shortDescription(),
keywords:doc.keywords()
});
});

View File

@@ -508,3 +508,26 @@ pre ol li {
font-size: 16px;
word-break: normal;
}
.text-info {
color:#3a87ad;
}
.definition-table tr > td:first-child {
font-weight:bold;
width:30%;
}
.definition-table.spaced {
margin-bottom:30px;
}
.component-heading {
text-transform:capitalize;
}
.component-breakdown {
margin-bottom:30px;
padding-bottom:30px;
border-bottom:1px solid #aaa;
}

View File

@@ -207,6 +207,48 @@ docsApp.directive.sourceEdit = function(getEmbeddedTemplate) {
}
};
docsApp.directive.docModuleComponents = ['sections', function(sections) {
return {
template: ' <div class="component-breakdown">' +
' <h2>Module Components</h2>' +
' <div ng-repeat="(key, section) in components">' +
' <h3 class="component-heading" id="{{ section.type }}">{{ section.title }}</h3>' +
' <table class="definition-table">' +
' <tr>' +
' <th>Name</th>' +
' <th>Description</th>' +
' </tr>' +
' <tr ng-repeat="component in section.components">' +
' <td><a ng-href="{{ component.url }}">{{ component.shortName }}</a></td>' +
' <td>{{ component.shortDescription }}</td>' +
' </tr>' +
' </table>' +
' </div>' +
' </div>',
scope : {
module : '@docModuleComponents'
},
controller : ['$scope', function($scope) {
var validTypes = ['property','function','directive','service','object','filter'];
var components = {};
angular.forEach(sections.api, function(item) {
if(item.moduleName == $scope.module) {
var type = item.type;
if(type == 'object') type = 'service';
if(validTypes.indexOf(type) >= 0) {
components[type] = components[type] || {
title : type,
type : type,
components : []
};
components[type].components.push(item);
}
}
});
$scope.components = components;
}]
};
}]
docsApp.directive.docTutorialNav = function(templateMerge) {
var pages = [