From dd668f68f9f9cc26cc178def827902585326f3dc Mon Sep 17 00:00:00 2001 From: Cyrille Meichel Date: Wed, 12 Aug 2015 15:56:03 +0200 Subject: [PATCH 1/2] feat(docs): add resource type --- src/ngdoc.js | 21 ++++++++++++++++++++- src/templates/css/docs.css | 37 +++++++++++++++++++++++++++++++++++++ src/templates/index.tmpl | 7 +++++++ src/templates/js/docs.js | 7 +++++++ 4 files changed, 71 insertions(+), 1 deletion(-) diff --git a/src/ngdoc.js b/src/ngdoc.js index 4fdc9f5..49a9601 100644 --- a/src/ngdoc.js +++ b/src/ngdoc.js @@ -454,6 +454,8 @@ Doc.prototype = { name: match[1], text: self.markdown(match[2]) }); + } else if (atName == 'restMethod') { + self.restMethod = text.toUpperCase(); } else if(atName == 'property') { match = text.match(/^\{(\S+)\}\s+(\S+)(\s+(.*))?/); if (!match) { @@ -656,6 +658,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']) { @@ -885,6 +894,10 @@ Doc.prototype = { this.html_usage_interface(dom) }, + html_usage_resource: function(dom) { + this.html_usage_interface(dom) + }, + html_usage_object: function(dom) { this.html_usage_interface(dom) }, @@ -904,6 +917,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() { @@ -914,6 +930,7 @@ Doc.prototype = { dom.h('Example', method.example, dom.html); }); + }); }); } @@ -982,6 +999,7 @@ var GLOBALS = /^angular\.([^\.]+)$/, MODULE = /^([^\.]+)$/, MODULE_MOCK = /^angular\.mock\.([^\.]+)$/, MODULE_CONTROLLER = /^(.+)\.controllers?:([^\.]+)$/, + MODULE_RESOURCE = /^(.+)\.resources?:([^\.]+)$/, MODULE_DIRECTIVE = /^(.+)\.directives?:([^\.]+)$/, MODULE_DIRECTIVE_INPUT = /^(.+)\.directives?:input\.([^\.]+)$/, MODULE_CUSTOM = /^(.+)\.([^\.]+):([^\.]+)$/, @@ -1032,6 +1050,8 @@ 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_DIRECTIVE)) { return makeTitle(match[2], 'directive', 'module', match[1]); } else if (match = text.match(MODULE_DIRECTIVE_INPUT)) { @@ -1098,7 +1118,6 @@ function metadata(docs){ if (path.pop() == 'input') { shortName = 'input [' + shortName + ']'; } - pages.push({ section: doc.section, id: doc.id, diff --git a/src/templates/css/docs.css b/src/templates/css/docs.css index 77f2a27..54764df 100644 --- a/src/templates/css/docs.css +++ b/src/templates/css/docs.css @@ -320,3 +320,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 0b4d4c7..59bd775 100644 --- a/src/templates/index.tmpl +++ b/src/templates/index.tmpl @@ -191,6 +191,13 @@ {{page.shortName}} + +
  • + {{page.shortName}} +
  • + diff --git a/src/templates/js/docs.js b/src/templates/js/docs.js index 1e31014..724b422 100644 --- a/src/templates/js/docs.js +++ b/src/templates/js/docs.js @@ -232,6 +232,7 @@ docsApp.controller.DocsController = function($scope, $location, $window, section MODULE = /^([^\.]+)$/, MODULE_MOCK = /^angular\.mock\.([^\.]+)$/, MODULE_CONTROLLER = /^(.+)\.controllers?:([^\.]+)$/, + MODULE_RESOURCE = /^(.+)\.resources?:([^\.]+)$/, MODULE_DIRECTIVE = /^(.+)\.directives?:([^\.]+)$/, MODULE_DIRECTIVE_INPUT = /^(.+)\.directives?:input\.([^\.]+)$/, MODULE_FILTER = /^(.+)\.filters?:([^\.]+)$/, @@ -323,6 +324,9 @@ 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_DIRECTIVE)) { breadcrumb.push({ name: match[1], url: sectionPath + '/' + match[1] }); breadcrumb.push({ name: match[2] }); @@ -411,6 +415,8 @@ docsApp.controller.DocsController = function($scope, $location, $window, section module(page.moduleName || match[1], section).filters.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_DIRECTIVE)) { module(page.moduleName || match[1], section).directives.push(page); } else if (match = id.match(MODULE_DIRECTIVE_INPUT)) { @@ -454,6 +460,7 @@ docsApp.controller.DocsController = function($scope, $location, $window, section url: (NG_DOCS.html5Mode ? '' : '#/') + section + '/' + name, globals: [], controllers: [], + resources: [], directives: [], services: [], others: [], From 014c69ed706cc13e8209065e3bcfd9ba7febb8f9 Mon Sep 17 00:00:00 2001 From: Maxime Caruchet Date: Thu, 7 Feb 2019 09:00:38 +0100 Subject: [PATCH 2/2] chore(): update upath dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"