mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
chore(ngdocs): replace showdown.js with marked.js
This commit is contained in:
parent
ab18914298
commit
258cae83dc
10 changed files with 62 additions and 54 deletions
|
|
@ -57,7 +57,7 @@ describe('Docs Annotations', function() {
|
|||
$scope.$apply();
|
||||
element.triggerHandler('click');
|
||||
expect(popoverElement.title()).toBe('#title_text');
|
||||
expect(popoverElement.content()).toBe('<h1 id="heading">heading</h1>');
|
||||
expect(popoverElement.content()).toBe('<h1>heading</h1>\n');
|
||||
}));
|
||||
|
||||
});
|
||||
|
|
|
|||
12
docs/components/angular-bootstrap/bootstrap.js
vendored
12
docs/components/angular-bootstrap/bootstrap.js
vendored
|
|
@ -257,7 +257,7 @@ var popoverElement = function() {
|
|||
|
||||
content : function(value) {
|
||||
if(value && value.length > 0) {
|
||||
value = new Showdown.converter().makeHtml(value);
|
||||
value = marked(value);
|
||||
}
|
||||
return this.contentElement.html(value);
|
||||
},
|
||||
|
|
@ -380,4 +380,12 @@ directive.foldout = ['$http', '$animator','$window', function($http, $animator,
|
|||
}
|
||||
}];
|
||||
|
||||
angular.module('bootstrap', []).directive(directive).factory('popoverElement', popoverElement);
|
||||
angular.module('bootstrap', [])
|
||||
.directive(directive)
|
||||
.factory('popoverElement', popoverElement)
|
||||
.run(function() {
|
||||
marked.setOptions({
|
||||
gfm: true,
|
||||
tables: true
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -59,10 +59,10 @@ describe('ngdoc', function() {
|
|||
'@param {function(number, string=)} d fn with optional arguments');
|
||||
doc.parse();
|
||||
expect(doc.param).toEqual([
|
||||
{name:'a', description:'<div class="a-page"><p>short</p></div>', type:'*', optional:false, 'default':undefined},
|
||||
{name:'b', description:'<div class="a-page"><p>med</p></div>', type:'Type', optional:false, 'default':undefined},
|
||||
{name:'c', description:'<div class="a-page"><p>long\nline</p></div>', type:'Class', optional:true, 'default':'2'},
|
||||
{name:'d', description:'<div class="a-page"><p>fn with optional arguments</p></div>',
|
||||
{name:'a', description:'<div class="a-page"><p>short</p>\n</div>', type:'*', optional:false, 'default':undefined},
|
||||
{name:'b', description:'<div class="a-page"><p>med</p>\n</div>', type:'Type', optional:false, 'default':undefined},
|
||||
{name:'c', description:'<div class="a-page"><p>long\nline</p>\n</div>', type:'Class', optional:true, 'default':'2'},
|
||||
{name:'d', description:'<div class="a-page"><p>fn with optional arguments</p>\n</div>',
|
||||
type: 'function(number, string=)', optional: false, 'default':undefined}
|
||||
]);
|
||||
});
|
||||
|
|
@ -72,7 +72,7 @@ describe('ngdoc', function() {
|
|||
doc.parse();
|
||||
expect(doc.returns).toEqual({
|
||||
type: 'Type',
|
||||
description: '<div class="a-page"><p>text <em>bold</em>.</p></div>'
|
||||
description: '<div class="a-page"><p>text <em>bold</em>.</p>\n</div>'
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -142,26 +142,26 @@ describe('ngdoc', function() {
|
|||
'<pre class="prettyprint linenums">\n' +
|
||||
'<b>angular</b>.k\n' +
|
||||
'</pre>\n' +
|
||||
' asdf x</p></div>');
|
||||
' asdf x</p>\n</div>');
|
||||
});
|
||||
|
||||
it('should wrap everything inside a container tag', function() {
|
||||
var doc = new Doc('@name superman').parse();
|
||||
var content = doc.markdown('hello');
|
||||
|
||||
expect(content).toMatch('<div class="superman-page"><p>hello</p></div>');
|
||||
expect(content).toMatch('<div class="superman-page"><p>hello</p>\n</div>');
|
||||
});
|
||||
|
||||
it('should use the content before a colon as the name prefix for the className of the tag container', function() {
|
||||
var doc = new Doc('@name super: man').parse();
|
||||
var content = doc.markdown('hello');
|
||||
|
||||
expect(content).toMatch('<div class="super-page super-man-page"><p>hello</p></div>');
|
||||
expect(content).toMatch('<div class="super-page super-man-page"><p>hello</p>\n</div>');
|
||||
});
|
||||
|
||||
it('should replace text between two <pre></pre> tags', function() {
|
||||
expect(new Doc().markdown('<pre>x</pre>\n# One\n<pre>b</pre>')).
|
||||
toMatch('</pre>\n\n<h1 id="one">One</h1>\n\n<pre');
|
||||
toMatch('</pre>\n<h1>One</h1>\n<pre');
|
||||
});
|
||||
|
||||
it('should replace inline variable type hints', function() {
|
||||
|
|
@ -171,16 +171,16 @@ describe('ngdoc', function() {
|
|||
|
||||
it('should ignore nested doc widgets', function() {
|
||||
expect(new Doc().markdown(
|
||||
'before<div class="tabbable">\n' +
|
||||
'before\n<div class="tabbable">\n' +
|
||||
'<div class="tab-pane well" id="git-mac" ng:model="Git on Mac/Linux">' +
|
||||
'\ngit bla bla\n</doc:tutorial-instruction>\n' +
|
||||
'</doc:tutorial-instructions>')).toEqual(
|
||||
'\ngit bla bla\n</div>\n' +
|
||||
'</div>')).toEqual(
|
||||
|
||||
'<div class="docs-page"><p>before<div class="tabbable">\n' +
|
||||
'<div class="docs-page"><p>before</p>\n<div class="tabbable">\n' +
|
||||
'<div class="tab-pane well" id="git-mac" ng:model="Git on Mac/Linux">\n' +
|
||||
'git bla bla\n' +
|
||||
'</doc:tutorial-instruction>\n' +
|
||||
'</doc:tutorial-instructions></p></div>');
|
||||
'</div>\n' +
|
||||
'</div></div>');
|
||||
});
|
||||
|
||||
it('should unindent text before processing based on the second line', function() {
|
||||
|
|
@ -190,10 +190,10 @@ describe('ngdoc', function() {
|
|||
' fourth line\n\n' +
|
||||
' fifth line')).
|
||||
toMatch('<p>first line\n' +
|
||||
'second line</p>\n\n' +
|
||||
'second line</p>\n' +
|
||||
'<pre><code>third line\n' +
|
||||
' fourth line\n</code></pre>\n\n' +
|
||||
'<p>fifth line</p>');
|
||||
' fourth line</code></pre>\n' +
|
||||
'<p>fifth line</p>\n');
|
||||
});
|
||||
|
||||
it('should unindent text before processing based on the first line', function() {
|
||||
|
|
@ -202,11 +202,11 @@ describe('ngdoc', function() {
|
|||
' third line\n' +
|
||||
' fourth line\n\n' +
|
||||
' fifth line')).
|
||||
toMatch('<p>first line</p>\n\n' +
|
||||
toMatch('<div class="docs-page"><p>first line</p>\n' +
|
||||
'<pre><code>second line\n' +
|
||||
'third line\n' +
|
||||
' fourth line\n</code></pre>\n\n' +
|
||||
'<p>fifth line</p>');
|
||||
' fourth line</code></pre>\n' +
|
||||
'<p>fifth line</p>\n</div>');
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -304,7 +304,7 @@ describe('ngdoc', function() {
|
|||
name : 'number',
|
||||
optional: false,
|
||||
'default' : undefined,
|
||||
description : '<div class="a-page"><p>Number \nto format.</p></div>' }]);
|
||||
description : '<div class="a-page"><p>Number \nto format.</p>\n</div>' }]);
|
||||
});
|
||||
|
||||
it('should parse with default and optional', function() {
|
||||
|
|
@ -315,7 +315,7 @@ describe('ngdoc', function() {
|
|||
name : 'fractionSize',
|
||||
optional: true,
|
||||
'default' : '2',
|
||||
description : '<div class="a-page"><p>desc</p></div>' }]);
|
||||
description : '<div class="a-page"><p>desc</p>\n</div>' }]);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -325,8 +325,8 @@ describe('ngdoc', function() {
|
|||
doc.ngdoc = 'service';
|
||||
doc.parse();
|
||||
expect(doc.requires).toEqual([
|
||||
{name:'$service', text:'<div class="a-page"><p>for \n<code>A</code></p></div>'},
|
||||
{name:'$another', text:'<div class="a-page"><p>for <code>B</code></p></div>'}]);
|
||||
{name:'$service', text:'<div class="a-page"><p>for \n<code>A</code></p>\n</div>'},
|
||||
{name:'$another', text:'<div class="a-page"><p>for <code>B</code></p>\n</div>'}]);
|
||||
expect(doc.html()).toContain('<a href="api/ng.$service">$service</a>');
|
||||
expect(doc.html()).toContain('<a href="api/ng.$another">$another</a>');
|
||||
expect(doc.html()).toContain('<p>for \n<code>A</code></p>');
|
||||
|
|
@ -378,7 +378,7 @@ describe('ngdoc', function() {
|
|||
var doc = new Doc("@name a\n@property {string} name desc rip tion");
|
||||
doc.parse();
|
||||
expect(doc.properties[0].name).toEqual('name');
|
||||
expect(doc.properties[0].description).toEqual('<div class="a-page"><p>desc rip tion</p></div>');
|
||||
expect(doc.properties[0].description).toEqual('<div class="a-page"><p>desc rip tion</p>\n</div>');
|
||||
});
|
||||
|
||||
it('should parse @property with type and description both', function() {
|
||||
|
|
@ -386,7 +386,7 @@ describe('ngdoc', function() {
|
|||
doc.parse();
|
||||
expect(doc.properties[0].name).toEqual('name');
|
||||
expect(doc.properties[0].type).toEqual('bool');
|
||||
expect(doc.properties[0].description).toEqual('<div class="a-page"><p>desc rip tion</p></div>');
|
||||
expect(doc.properties[0].description).toEqual('<div class="a-page"><p>desc rip tion</p>\n</div>');
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -409,26 +409,26 @@ describe('ngdoc', function() {
|
|||
it('should parse @returns with type and description', function() {
|
||||
var doc = new Doc("@name a\n@returns {string} descrip tion");
|
||||
doc.parse();
|
||||
expect(doc.returns).toEqual({type: 'string', description: '<div class="a-page"><p>descrip tion</p></div>'});
|
||||
expect(doc.returns).toEqual({type: 'string', description: '<div class="a-page"><p>descrip tion</p>\n</div>'});
|
||||
});
|
||||
|
||||
it('should parse @returns with complex type and description', function() {
|
||||
var doc = new Doc("@name a\n@returns {function(string, number=)} description");
|
||||
doc.parse();
|
||||
expect(doc.returns).toEqual({type: 'function(string, number=)', description: '<div class="a-page"><p>description</p></div>'});
|
||||
expect(doc.returns).toEqual({type: 'function(string, number=)', description: '<div class="a-page"><p>description</p>\n</div>'});
|
||||
});
|
||||
|
||||
it('should transform description of @returns with markdown', function() {
|
||||
var doc = new Doc("@name a\n@returns {string} descrip *tion*");
|
||||
doc.parse();
|
||||
expect(doc.returns).toEqual({type: 'string', description: '<div class="a-page"><p>descrip <em>tion</em></p></div>'});
|
||||
expect(doc.returns).toEqual({type: 'string', description: '<div class="a-page"><p>descrip <em>tion</em></p>\n</div>'});
|
||||
});
|
||||
|
||||
it('should support multiline content', function() {
|
||||
var doc = new Doc("@name a\n@returns {string} description\n new line\n another line");
|
||||
doc.parse();
|
||||
expect(doc.returns).
|
||||
toEqual({type: 'string', description: '<div class="a-page"><p>description\nnew line\nanother line</p></div>'});
|
||||
toEqual({type: 'string', description: '<div class="a-page"><p>description\nnew line\nanother line</p>\n</div>'});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -437,7 +437,7 @@ describe('ngdoc', function() {
|
|||
var doc = new Doc("@name a\n@description <pre><b>abc</b></pre>");
|
||||
doc.parse();
|
||||
expect(doc.description).
|
||||
toBe('<div class="a-page"><pre class="prettyprint linenums"><b>abc</b></pre></div>');
|
||||
toBe('<div class="a-page"><pre class="prettyprint linenums"><b>abc</b></pre>\n</div>');
|
||||
});
|
||||
|
||||
it('should support multiple pre blocks', function() {
|
||||
|
|
@ -445,11 +445,10 @@ describe('ngdoc', function() {
|
|||
doc.parse();
|
||||
expect(doc.description).
|
||||
toBe('<div class="a-page"><p>foo \n' +
|
||||
'<pre class="prettyprint linenums">abc</pre>\n\n' +
|
||||
'<h1 id="bah">bah</h1>\n\n' +
|
||||
'<pre class="prettyprint linenums">abc</pre>\n' +
|
||||
'<h1>bah</h1>\n' +
|
||||
'<p>foo \n' +
|
||||
'<pre class="prettyprint linenums">cba</pre></div>');
|
||||
|
||||
'<pre class="prettyprint linenums">cba</pre>\n</div>');
|
||||
});
|
||||
|
||||
it('should support nested @link annotations with or without description', function() {
|
||||
|
|
@ -491,7 +490,7 @@ describe('ngdoc', function() {
|
|||
it('should not remove {{}}', function() {
|
||||
var doc = new Doc('@name a\n@example text {{ abc }}');
|
||||
doc.parse();
|
||||
expect(doc.example).toEqual('<div class="a-page"><p>text {{ abc }}</p></div>');
|
||||
expect(doc.example).toEqual('<div class="a-page"><p>text {{ abc }}</p>\n</div>');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -511,11 +510,11 @@ describe('ngdoc', function() {
|
|||
expect(doc.html()).toContain('<h3>Method\'s <code>this</code></h3>\n' +
|
||||
'<div>' +
|
||||
'<div class="a-page">' +
|
||||
'<p>I am self.</p>' +
|
||||
'<p>I am self.</p>\n' +
|
||||
'</div>' +
|
||||
'</div>\n');
|
||||
expect(doc.html()).toContain('<h3>Method\'s <code>this</code></h3>\n' +
|
||||
'<div><div class="a-page"><p>I am self.</p></div></div>');
|
||||
'<div><div class="a-page"><p>I am self.</p>\n</div></div>');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -542,7 +541,7 @@ describe('ngdoc', function() {
|
|||
var doc = new Doc('@ngdoc overview\n@name angular\n@description\n#heading\ntext');
|
||||
doc.parse();
|
||||
expect(doc.html()).toContain('text');
|
||||
expect(doc.html()).toContain('<h2 id="heading">heading</h2>');
|
||||
expect(doc.html()).toContain('<h2>heading</h2>');
|
||||
expect(doc.html()).not.toContain('Description');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -83,8 +83,7 @@ function writeTheRest(writesFuture) {
|
|||
writesFuture.push(writer.copyDir('components/components-font-awesome/font', 'components/font-awesome/font'));
|
||||
writesFuture.push(writer.copyDir('components/bootstrap', 'components/bootstrap'));
|
||||
|
||||
writesFuture.push(writer.copy('node_modules/showdown/src/showdown.js', 'components/showdown.js'));
|
||||
writesFuture.push(writer.copy('node_modules/showdown/compressed/showdown.js', 'components/showdown.min.js'));
|
||||
writesFuture.push(writer.copy('node_modules/marked/lib/marked.js', 'components/marked.js'));
|
||||
writesFuture.push(writer.copy('components/lunr.js/lunr.js', 'components/lunr.js'));
|
||||
writesFuture.push(writer.copy('components/lunr.js/lunr.min.js', 'components/lunr.min.js'));
|
||||
writesFuture.push(writer.copy('components/jquery/jquery.js', 'components/jquery.js'));
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
/**
|
||||
* All parsing/transformation code goes here. All code here should be sync to ease testing.
|
||||
*/
|
||||
|
||||
var Showdown = require('showdown');
|
||||
var DOM = require('./dom.js').DOM;
|
||||
var htmlEscape = require('./dom.js').htmlEscape;
|
||||
var Example = require('./example.js').Example;
|
||||
|
|
@ -10,10 +8,14 @@ var NEW_LINE = /\n\r?/;
|
|||
var globalID = 0;
|
||||
var fs = require('fs');
|
||||
var fspath = require('path');
|
||||
var markdown = new Showdown.converter({ extensions : ['table'] });
|
||||
var shell = require('shelljs');
|
||||
var gruntUtil = require('../../lib/grunt/utils.js');
|
||||
var errorsJson;
|
||||
var marked = require('marked');
|
||||
marked.setOptions({
|
||||
gfm: true,
|
||||
tables: true
|
||||
});
|
||||
|
||||
var lookupMinerrMsg = function (doc) {
|
||||
var code, namespace;
|
||||
|
|
@ -289,7 +291,7 @@ Doc.prototype = {
|
|||
pageClassName = pageClassName || prepareClassName(this.name || 'docs') + suffix;
|
||||
|
||||
text = '<div class="' + pageClassName + '">' +
|
||||
markdown.makeHtml(text) +
|
||||
marked(text) +
|
||||
'</div>';
|
||||
text = text.replace(/(?:<p>)?(REPLACEME\d+)(?:<\/p>)?/g, function(_, id) {
|
||||
return placeholderMap[id];
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
addTag('script', {src: 'components/angular-bootstrap-prettify.js' }, sync);
|
||||
addTag('script', {src: 'components/google-code-prettify.js' }, sync);
|
||||
addTag('script', {src: 'components/' + (debug ? 'lunr.js' : 'lunr.min.js') }, sync);
|
||||
addTag('script', {src: 'components/' + (debug ? 'showdown.js' : 'showdown.min.js') }, sync);
|
||||
addTag('script', {src: 'components/marked.js' }, sync);
|
||||
addTag('script', {src: 'docs-data.js'}, sync);
|
||||
addTag('script', {src: 'js/docs.js'}, sync);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module.exports = function(config) {
|
|||
|
||||
'build/docs/components/lunr.js',
|
||||
'build/docs/components/google-code-prettify.js',
|
||||
'build/docs/components/showdown.js',
|
||||
'build/docs/components/marked.js',
|
||||
|
||||
'build/docs/components/angular-bootstrap.js',
|
||||
'build/docs/components/angular-bootstrap-prettify.js',
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
"karma-sauce-launcher": "~0.0.4",
|
||||
"karma-script-launcher": "~0.0.1",
|
||||
"yaml-js": "0.0.5",
|
||||
"showdown": "0.3.1",
|
||||
"marked": "~0.2.9",
|
||||
"rewire": "1.1.3",
|
||||
"grunt-contrib-jasmine-node": "~0.1.1",
|
||||
"grunt-parallel": "~0.2.0",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* Below is a more detailed breakdown of the supported callback events provided by pre-exisitng ng directives:
|
||||
*
|
||||
* | Directive | Supported Animations |
|
||||
* |========================================================== |====================================================|
|
||||
* |---------------------------------------------------------- |----------------------------------------------------|
|
||||
* | {@link ng.directive:ngRepeat#animations ngRepeat} | enter, leave and move |
|
||||
* | {@link ngRoute.directive:ngView#animations ngView} | enter and leave |
|
||||
* | {@link ng.directive:ngInclude#animations ngInclude} | enter and leave |
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
* Special properties are exposed on the local scope of each template instance, including:
|
||||
*
|
||||
* | Variable | Type | Details |
|
||||
* |===========|=================|=============================================================================|
|
||||
* |-----------|-----------------|-----------------------------------------------------------------------------|
|
||||
* | `$index` | {@type number} | iterator offset of the repeated element (0..length-1) |
|
||||
* | `$first` | {@type boolean} | true if the repeated element is first in the iterator. |
|
||||
* | `$middle` | {@type boolean} | true if the repeated element is between the first and last in the iterator. |
|
||||
|
|
|
|||
Loading…
Reference in a new issue