Skip to content

Commit

Permalink
docs: fix the 'view source' button for snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
Narretz authored and jamesdaily committed Jan 27, 2014
1 parent 8143126 commit 24d80a6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions docs/spec/ngdocSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var ngdoc = require('../src/ngdoc.js');
var DOM = require('../src/dom.js').DOM;
var gruntUtil = require('../../lib/grunt/utils.js');


describe('ngdoc', function() {
var Doc = ngdoc.Doc;
Expand Down Expand Up @@ -287,6 +289,33 @@ describe('ngdoc', function() {
});
});


describe('api section', function() {

it('should render a "view source" button with link to the source in master', function() {
var doc = new Doc({
id: 'ng.abc',
name: 'ng.abc',
section: 'api',
ngdoc: 'service',
file: 'fooService.js',
line: '333'
});

if (gruntUtil.getVersion().full.indexOf('-') === -1) {
expect(doc.html().match(/^(<a .*?<\/a>)/)[1]).toMatch(
/<a href="http:\/\/github\.com\/angular\/angular\.js\/tree\/v\d+\.\d+\.\d+\/fooService\.js#L333" class="view-source/
);
} else {
expect(doc.html().match(/^(<a .*?<\/a>)/)[1]).toMatch(
/<a href="http:\/\/github\.com\/angular\/angular\.js\/tree\/[a-z0-9]{7}\/fooService\.js#L333" class="view-source/
);
}
});
});



////////////////////////////////////////

describe('TAG', function() {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/ngdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ Doc.prototype = {
minerrMsg;

var gitTagFromFullVersion = function(version) {
var match = version.match(/-(\w{7})/);
var match = version.match(/sha\.(\w{7})/);

if (match) {
// git sha
Expand Down

0 comments on commit 24d80a6

Please sign in to comment.