diff options
| author | Matias Niemelä | 2013-06-06 01:28:50 -0400 |
|---|---|---|
| committer | Misko Hevery | 2013-06-17 22:00:54 -0700 |
| commit | ef22968810d555f78d3bbf7b5428757690c8cc70 (patch) | |
| tree | 1a19f2649e07406bd1988c4d915deec87073c568 /docs/src/ngdoc.js | |
| parent | 07ef1667db632d0fd75472f30343255edcebf43b (diff) | |
| download | angular.js-ef22968810d555f78d3bbf7b5428757690c8cc70.tar.bz2 | |
feat(ngdocs): support popover, foldouts and foldover annotations
Diffstat (limited to 'docs/src/ngdoc.js')
| -rw-r--r-- | docs/src/ngdoc.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index c34b8475..1870f87c 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -225,6 +225,44 @@ Doc.prototype = { text = text.replace(/(?:<p>)?(REPLACEME\d+)(?:<\/p>)?/g, function(_, id) { return placeholderMap[id]; }); + + //!annotate CONTENT + //!annotate="REGEX" CONTENT + //!annotate="REGEX" TITLE|CONTENT + text = text.replace(/\n?\/\/!annotate\s*(?:=\s*['"](.+?)['"])?\s+(.+?)\n\s*(.+?\n)/img, + function(_, pattern, content, line) { + var pattern = new RegExp(pattern || '.+'); + var title, text, split = content.split(/\|/); + if(split.length > 1) { + text = split[1]; + title = split[0]; + } + else { + title = 'Info'; + text = content; + } + return "\n" + line.replace(pattern, function(match) { + return '<div class="nocode nocode-content" data-popover ' + + 'data-content="' + text + '" ' + + 'data-title="' + title + '">' + + match + + '</div>'; + }); + } + ); + + //!details /path/to/local/docs/file.html + //!details="REGEX" /path/to/local/docs/file.html + text = text.replace(/\/\/!details\s*(?:=\s*['"](.+?)['"])?\s+(.+?)\n\s*(.+?\n)/img, + function(_, pattern, url, line) { + url = '/notes/' + url; + var pattern = new RegExp(pattern || '.+'); + return line.replace(pattern, function(match) { + return '<div class="nocode nocode-content" data-foldout data-url="' + url + '">' + match + '</div>'; + }); + } + ); + return text; }, |
