diff --git a/.gitignore b/.gitignore index 3c3629e..55371e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.vscode \ No newline at end of file diff --git a/package.json b/package.json index 3a336fe..ecc0a59 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "marked": "~0.3.2", "lodash": "^4.0.0", "shelljs": "~0.3.0", - "upath": "~0.2.0" + "upath": "~1.1.0" }, "peerDependencies": { "grunt": ">=0.4.0" diff --git a/spec/ngdocSpec.js b/spec/ngdocSpec.js index bcacc00..cad744a 100644 --- a/spec/ngdocSpec.js +++ b/spec/ngdocSpec.js @@ -512,8 +512,8 @@ describe('ngdoc', function() { expect(doc.description). toBe('

foo\n' + '

abc
\n' + - '

bah

\n' + - '

foo \n' + + '

#bah\n' + + 'foo \n' + '

cba
\n
'); }); @@ -607,7 +607,6 @@ describe('ngdoc', function() { var doc = new Doc('@ngdoc overview\n@name angular\n@description\n#heading\ntext'); doc.parse(); expect(doc.html()).toContain('text'); - expect(doc.html()).toContain('

heading

'); expect(doc.html()).not.toContain('Description'); }); }); diff --git a/src/ngdoc.js b/src/ngdoc.js index 45da4ab..7e8f774 100644 --- a/src/ngdoc.js +++ b/src/ngdoc.js @@ -539,6 +539,22 @@ Doc.prototype = { } dom.h(title(this), function() { + + var nameMatcher = self.name.match(/^[^\.]*\.([^:]*):.*$/); + if (self.ngdoc === "object") { + switch (nameMatcher ? nameMatcher[1] : "") { + case "factory": + case "factories": + self.ngdoc = "factory"; + break; + case "constant": + case "constants": + self.ngdoc = "constant"; + break; + default: + } + } + notice('deprecated', 'Deprecated API', self.deprecated); if (self.ngdoc === 'error') { minerrMsg = lookupMinerrMsg(self); @@ -793,6 +809,13 @@ Doc.prototype = { } }, + html_usage_rest_method: function(dom) { + var self = this; + if (self.restMethod) { + dom.html('' + self.restMethod + ''); + } + }, + html_usage_this: function(dom) { var self = this; if (self['this']) { @@ -1078,6 +1101,26 @@ Doc.prototype = { this.html_usage_interface(dom) }, + html_usage_resource: function(dom) { + this.html_usage_interface(dom) + }, + + html_usage_factory: function(dom) { + this.html_usage_interface(dom) + }, + + html_usage_constant: function(dom) { + this.html_usage_interface(dom) + }, + + html_usage_factories: function(dom) { + this.html_usage_interface(dom) + }, + + html_usage_constants: function(dom) { + this.html_usage_interface(dom) + }, + html_usage_object: function(dom) { this.html_usage_interface(dom) }, @@ -1098,6 +1141,9 @@ Doc.prototype = { class: 'view-source icon-eye-open' }, ' '); } + if (method.restMethod) { + method.html_usage_rest_method(dom); + } //filters out .IsProperty parameters from the method signature var signature = (method.param || []).filter(function(e) { return e.isProperty !== true; }).map(property('name')); dom.h(method.shortName + '(' + signature.join(', ') + ')', method, function() { @@ -1108,6 +1154,7 @@ Doc.prototype = { dom.h('Example', method.example, dom.html); }); + }); }); } @@ -1176,6 +1223,9 @@ var GLOBALS = /^angular\.([^\.]+)$/, MODULE = /^([^\.]+)$/, MODULE_MOCK = /^angular\.mock\.([^\.]+)$/, MODULE_CONTROLLER = /^(.+)\.controllers?:([^\.]+)$/, + MODULE_RESOURCE = /^(.+)\.resources?:([^\.]+)$/, + MODULE_FACTORY = /^(.+)\.factories:([^\.]+)$|^(.+)\.factory:([^\.]+)/, + MODULE_CONSTANT = /^(.+)\.constants?:([^\.]+)$/, MODULE_COMPONENT = /^(.+)\.components?:([^\.]+)$/, MODULE_DIRECTIVE = /^(.+)\.directives?:([^\.]+)$/, MODULE_DIRECTIVE_INPUT = /^(.+)\.directives?:input\.([^\.]+)$/, @@ -1227,6 +1277,12 @@ function title(doc) { return makeTitle('angular.mock.' + match[1], 'API', 'module', 'ng'); } else if (match = text.match(MODULE_CONTROLLER) && doc.type === 'controller') { return makeTitle(match[2], 'controller', 'module', match[1]); + } else if (match = text.match(MODULE_RESOURCE) && doc.type === 'resource') { + return makeTitle(match[2], 'resource', 'module', match[1]); + } else if (match = text.match(MODULE_FACTORY)) { + return makeTitle(match[2], 'factory', 'module', match[1]); + } else if (match = text.match(MODULE_CONSTANT)) { + return makeTitle(match[2], 'constant', 'module', match[1]); } else if (match = text.match(MODULE_COMPONENT)) { return makeTitle(match[2], 'component', 'module', match[1]); } else if (match = text.match(MODULE_DIRECTIVE)) { @@ -1516,7 +1572,7 @@ function checkBrokenLinks(docs, apis, options) { docs.forEach(function(doc) { byFullId[doc.section + '/' + doc.id] = doc; if (apis[doc.section]) { - doc.anchors.push('directive', 'service', 'filter', 'function'); + doc.anchors.push('directive', 'service', 'filter', 'function', 'factory', 'constant'); } }); diff --git a/src/reader.js b/src/reader.js index 6d726db..93fe29f 100644 --- a/src/reader.js +++ b/src/reader.js @@ -42,7 +42,9 @@ function processJsFile(content, file, section, options) { text = text.join('\n'); text = text.replace(/^\n/, ''); if (text.match(/@ngdoc/)) { - //console.log(file, startingLine) + //console.log("##########" + file, startingLine); + //console.log("-------" + section); + //console.log(text); docs.push(new ngdoc.Doc('@section ' + section + '\n' + text, file, startingLine, lineNumber, options).parse()); } doc = null; diff --git a/src/templates/css/docs.css b/src/templates/css/docs.css index b1f4281..2e0f531 100644 --- a/src/templates/css/docs.css +++ b/src/templates/css/docs.css @@ -324,3 +324,40 @@ ul.events > li > h3 { .type-hint-number { background:rgb(189, 63, 66); } + +.rest-method { + float: right; + margin-top: -0.8em; + margin-right: 0.5em; +} + +.rest-method-get { + background-color: #0f6ab4; +} +.rest-method-post { + background-color: #10a54a; +} + +.rest-method-put { + background-color: #c5862b; +} + +.rest-method-delete { + background-color: #a41e22; +} + +.rest-method-options { + background-color: #d7df01; +} + +.rest-method-head { + background-color: #642efe; +} + +.rest-method-trace { + background-color: #cc2efa; +} + +.rest-method-connect { + background-color: #8a2908; +} \ No newline at end of file diff --git a/src/templates/index.tmpl b/src/templates/index.tmpl index 68fac97..23fd2b5 100644 --- a/src/templates/index.tmpl +++ b/src/templates/index.tmpl @@ -198,6 +198,13 @@ {{page.shortName}} + +
  • + {{page.shortName}} +
  • + @@ -205,6 +212,20 @@ {{page.shortName}} + +
  • + {{page.shortName}} +
  • + + +
  • + {{page.shortName}} +
  • + diff --git a/src/templates/js/docs.js b/src/templates/js/docs.js index c5e675e..05f898c 100644 --- a/src/templates/js/docs.js +++ b/src/templates/js/docs.js @@ -233,6 +233,9 @@ docsApp.controller.DocsController = function($scope, $location, $window, section MODULE_MOCK = /^angular\.mock\.([^\.]+)$/, MODULE_COMPONENT = /^(.+)\.components?:([^\.]+)$/, MODULE_CONTROLLER = /^(.+)\.controllers?:([^\.]+)$/, + MODULE_RESOURCE = /^(.+)\.resources?:([^\.]+)$/, + MODULE_FACTORY = /^(.+)\.factories:([^\.]+)$|^(.+)\.factory?:([^\.]+)$/, + MODULE_CONSTANT = /^(.+)\.constants?:([^\.]+)$/, MODULE_DIRECTIVE = /^(.+)\.directives?:([^\.]+)$/, MODULE_DIRECTIVE_INPUT = /^(.+)\.directives?:input\.([^\.]+)$/, MODULE_FILTER = /^(.+)\.filters?:([^\.]+)$/, @@ -324,6 +327,15 @@ docsApp.controller.DocsController = function($scope, $location, $window, section } else if (match = partialId.match(MODULE_CONTROLLER)) { breadcrumb.push({ name: match[1], url: sectionPath + '/' + match[1] }); breadcrumb.push({ name: match[2] }); + } else if (match = partialId.match(MODULE_RESOURCE)) { + breadcrumb.push({ name: match[1], url: sectionPath + '/' + match[1] }); + breadcrumb.push({ name: match[2] }); + } else if (match = partialId.match(MODULE_FACTORY)) { + breadcrumb.push({ name: match[1], url: sectionPath + '/' + match[1] }); + breadcrumb.push({ name: match[2] }); + } else if (match = partialId.match(MODULE_CONSTANT)) { + breadcrumb.push({ name: match[1], url: sectionPath + '/' + match[1] }); + breadcrumb.push({ name: match[2] }); } else if (match = partialId.match(MODULE_DIRECTIVE)) { breadcrumb.push({ name: match[1], url: sectionPath + '/' + match[1] }); breadcrumb.push({ name: match[2] }); @@ -414,6 +426,12 @@ docsApp.controller.DocsController = function($scope, $location, $window, section module(page.moduleName || match[1], section).components.push(page); } else if (match = id.match(MODULE_CONTROLLER) && page.type === 'controller') { module(page.moduleName || match[1], section).controllers.push(page); + } else if (match = id.match(MODULE_RESOURCE) && page.type === 'resource') { + module(page.moduleName || match[1], section).resources.push(page); + } else if (match = id.match(MODULE_FACTORY) && page.type === 'factory' && page.type === 'object') { + module(page.moduleName || match[1], section).factories.push(page); + } else if (match = id.match(MODULE_CONSTANT) && page.type === 'constant' && page.type === 'object') { + module(page.moduleName || match[1], section).constants.push(page); } else if (match = id.match(MODULE_DIRECTIVE)) { module(page.moduleName || match[1], section).directives.push(page); } else if (match = id.match(MODULE_DIRECTIVE_INPUT)) { @@ -458,7 +476,10 @@ docsApp.controller.DocsController = function($scope, $location, $window, section globals: [], components: [], controllers: [], + resources: [], directives: [], + factories: [], + constants: [], services: [], others: [], service: function(name) {