From 65989c6f0d13b8f205ab929999a4b9f66c8c1c93 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 17 Nov 2010 17:26:25 -0800 Subject: add support for {@link} tags within @description and remove implicit linking use as: - foo {@link bar} - foo {@link bar desc} I'm removing implicit linking because it unintentionally links stuff and generally interferes with other conversions. We have to link stuff explicitely from now on. --- docs/collect.js | 16 +++++++++++++--- docs/spec/collectSpec.js | 18 +++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/collect.js b/docs/collect.js index a4db4ed1..7fe326b4 100644 --- a/docs/collect.js +++ b/docs/collect.js @@ -163,14 +163,24 @@ function markdownTag(doc, name, value) { replace(/\<\/pre\>/gmi, ''); } +R_LINK = /{@link ([^\s}]+)((\s|\n)+(.+?))?\s*}/m + // 1 123 3 4 42 + function markdown(text) { - var parts = text.split(/(
[\s\S]*?<\/pre>)/);
+  var parts = text.split(/(
[\s\S]*?<\/pre>)/),
+      match;
+
   parts.forEach(function(text, i){
     if (!text.match(/^
/)) {
       text = text.replace(//gm, '<angular/>');
       text = new Showdown.converter().makeHtml(text);
-      text = text.replace(/[^#][^!](angular\.[\$\w\._\-:]+)/gm, '$1');
-      text = text.replace(/(`(ng:[\w\._\-]+)`)/gm, '$1');
+
+      while (match = text.match(R_LINK)) {
+        text = text.replace(match[0], '' +
+                                        (match[4] || match[1]) +
+                                      '');
+      }
+
       parts[i] = text;
     }
   });
diff --git a/docs/spec/collectSpec.js b/docs/spec/collectSpec.js
index 822e97fb..f6b5a319 100644
--- a/docs/spec/collectSpec.js
+++ b/docs/spec/collectSpec.js
@@ -13,11 +13,11 @@ describe('collect', function(){
     });
     
     it('should not replace anything in 
', function(){
-      expect(collect.markdown('angular.x\n
\nangular.k\n
\nangular.x')). + expect(collect.markdown('bah x\n
\nangular.k\n
\n asdf x')). toEqual( - '

angular.x

' + + '

bah x

' + '
\nangular.k\n
' + - '

angular.x

'); + '

asdf x

'); }); }); @@ -196,6 +196,18 @@ describe('collect', function(){ '
cba
'); }); + + it('should support nested @link annotations with or without description', function() { + TAG.description(doc, 'description', + 'foo {@link angular.foo}\n\n da {@link angular.foo bar foo bar } \n\n' + + 'dad{@link angular.foo}\n\n' + + '{@link angular.directive.ng:foo ng:foo}'); + expect(doc.description). + toBe('

foo angular.foo

\n\n' + + '

da bar foo bar

\n\n' + + '

dadangular.foo

\n\n' + + '

ng:foo

'); + }); }); describe('@example', function(){ -- cgit v1.2.3