diff options
| author | Misko Hevery | 2012-02-13 21:59:10 -0800 |
|---|---|---|
| committer | Misko Hevery | 2012-02-21 22:45:58 -0800 |
| commit | 22c1db17444e09bcf13b0f24f4f805a65d8a3be0 (patch) | |
| tree | 4b36307758965b14fc6bee5ccfe4cfc0c5c0db3a /docs | |
| parent | 292a5dae072ecd4edf3f01def71dd83b88dfe2d4 (diff) | |
| download | angular.js-22c1db17444e09bcf13b0f24f4f805a65d8a3be0.tar.bz2 | |
fix(ngdoc): extract keywords from properties/methods.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/spec/ngdocSpec.js | 7 | ||||
| -rw-r--r-- | docs/src/ngdoc.js | 31 |
2 files changed, 28 insertions, 10 deletions
diff --git a/docs/spec/ngdocSpec.js b/docs/spec/ngdocSpec.js index c6f17628..8082e4b1 100644 --- a/docs/spec/ngdocSpec.js +++ b/docs/spec/ngdocSpec.js @@ -23,6 +23,13 @@ describe('ngdoc', function() { expect(new Doc('The `ng:class-odd` and').keywords()).toEqual('and ng:class-odd the'); }); + it('should get property and methods', function() { + var doc = new Doc('Document'); + doc.properties.push(new Doc('Proprety')); + doc.properties.push(new Doc('Method')); + expect(doc.keywords()).toEqual('document method proprety'); + }); + it('should have shortName', function() { var d1 = new Doc('@name a.b.c').parse(); var d2 = new Doc('@name a.b.ng:c').parse(); diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index e39cb362..87f9ab62 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -46,18 +46,29 @@ Doc.METADATA_IGNORE = (function() { Doc.prototype = { keywords: function keywords() { var keywords = {}; - Doc.METADATA_IGNORE.forEach(function(ignore){ keywords[ignore] = true; }); var words = []; - var tokens = this.text.toLowerCase().split(/[,\.\`\'\"\s]+/mg); - tokens.forEach(function(key){ - var match = key.match(/^(([\$\_a-z]|ng\:)[\w\_\-]{2,})/); - if (match){ - key = match[1]; - if (!keywords[key]) { - keywords[key] = true; - words.push(key); + Doc.METADATA_IGNORE.forEach(function(ignore){ keywords[ignore] = true; }); + + function extractWords(text) { + var tokens = text.toLowerCase().split(/[,\.\`\'\"\s]+/mg); + tokens.forEach(function(key){ + var match = key.match(/^(([\$\_a-z]|ng\:)[\w\_\-]{2,})/); + if (match){ + key = match[1]; + if (!keywords[key]) { + keywords[key] = true; + words.push(key); + } } - } + }); + } + + extractWords(this.text); + this.properties.forEach(function(prop) { + extractWords(prop.text || prop.description || ''); + }); + this.methods.forEach(function(method) { + extractWords(method.text || method.description || ''); }); words.sort(); return words.join(' '); |
