diff --git a/website/css/protractor.less b/website/css/protractor.less index e90cd324e..dc9b6fbbd 100644 --- a/website/css/protractor.less +++ b/website/css/protractor.less @@ -8,6 +8,10 @@ @child-color: #777; @mobile-menu-margin: 15px; +a code { + color: inherit; +} + .protractor-container { margin-bottom: 50px; padding-top: @padding-top; diff --git a/website/docgen/processors/add-links.js b/website/docgen/processors/add-links.js index cc46cb67a..dc3c277e9 100644 --- a/website/docgen/processors/add-links.js +++ b/website/docgen/processors/add-links.js @@ -45,12 +45,13 @@ var addLinkToLinkAnnotation = function(str, doc) { var oldStr = null; while (str != oldStr) { oldStr = str; - var matches = /{\s*@link\s+([^]+?)\s*}/.exec(str); + var matches = /{\s*@link[plain]*\s+([^]+?)\s*}/.exec(str); if (matches) { var str = str.replace( - new RegExp('{\\s*@link\\s+' + + new RegExp('{\\s*@link[plain]*\\s+' + matches[1].replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + '\\s*}'), - toMarkdownLinkFormat(matches[1], doc) + toMarkdownLinkFormat(matches[1], doc, + matches[0].indexOf('linkplain') == -1) ); } } @@ -75,7 +76,7 @@ var escape = function(str) { * @param {!Object} doc Current document. * @return {string} A link for the type. */ -var toMarkdownLinkFormat = function(link, doc) { +var toMarkdownLinkFormat = function(link, doc, code) { var type, desc; // Split type and description @@ -86,6 +87,10 @@ var toMarkdownLinkFormat = function(link, doc) { desc = link.substr(i).trim(); type = link.substr(0, i).trim(); } + if (code) { + desc = '{@code ' + desc + '}' + } + desc = desc.replace(new RegExp('\n', 'g'), ' '); if (!type.match(/^https?:\/\//)) { // Remove extra '()' at the end of types @@ -99,7 +104,7 @@ var toMarkdownLinkFormat = function(link, doc) { } // Replace '#' in the middle of types with '.' - type = type.replace(new RegExp('#', 'g'), '.'); + type = type.replace(new RegExp('#', 'g'), '.prototype.'); // Only create a link if it's in the API if (!typeTable[type]) { diff --git a/website/docgen/spec/add-links-spec.js b/website/docgen/spec/add-links-spec.js index 9ae0de41e..735b3c133 100644 --- a/website/docgen/spec/add-links-spec.js +++ b/website/docgen/spec/add-links-spec.js @@ -173,9 +173,9 @@ describe('add-links', function() { // Then ensure a link was added to the type. expect(docs[1].description). - toBe('A promise that [webdriver.WebElement](webdriver.WebElement)s'); + toBe('A promise that [{@code webdriver.WebElement}](webdriver.WebElement)s'); expect(docs[1].returns.description). - toBe('A promise located [webdriver.WebElement](webdriver.WebElement)s.'); + toBe('A promise located [{@code webdriver.WebElement}](webdriver.WebElement)s.'); }); it('should handle {@link type desc} links', function() { @@ -217,9 +217,9 @@ describe('add-links', function() { // Then ensure a link was added to the type. expect(docs[1].description). - toBe('A promise that [Web Elements](webdriver.WebElement)'); + toBe('A promise that [{@code Web Elements}](webdriver.WebElement)'); expect(docs[1].returns.description). - toBe('A promise located Web Elements.'); + toBe('A promise located {@code Web Elements}.'); }); it('should handle "#" in @link links', function() { @@ -261,9 +261,9 @@ describe('add-links', function() { // Then ensure a link was added to the type. expect(docs[1].description). - toBe('A promise that [Web Drivers](webdriver.WebDriver)'); + toBe('A promise that [{@code Web Drivers}](webdriver.WebDriver)'); expect(docs[1].returns.description). - toBe('A promise located [Web Elements](webdriver.WebElement).'); + toBe('A promise located {@code Web Elements}.'); }); it('should remove extraneous chatacters from @link links', function() { @@ -288,7 +288,7 @@ describe('add-links', function() { canHaveType: true }, tagName: 'return', - description: 'A promise located {@link webdriver.WebElement Web Elements }.', + description: 'A promise located {@linkplain webdriver.WebElement Web Elements }.', startingLine: 119, typeExpression: 'webdriver.WebElement', type: { @@ -305,7 +305,7 @@ describe('add-links', function() { // Then ensure a link was added to the type. expect(docs[1].description). - toBe('A promise that [webdriver.WebElement()](webdriver.WebElement)'); + toBe('A promise that [{@code webdriver.WebElement()}](webdriver.WebElement)'); expect(docs[1].returns.description). toBe('A promise located [Web Elements](webdriver.WebElement).');