Skip to content

Commit 8ba38e8

Browse files
Narretzjamesdaily
authored andcommitted
docs: fix the 'view source' button for snapshots
Closes angular#5590 Closes angular#5641
1 parent bc02196 commit 8ba38e8

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

Diff for: docs/spec/ngdocSpec.js

+29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var ngdoc = require('../src/ngdoc.js');
22
var DOM = require('../src/dom.js').DOM;
3+
var gruntUtil = require('../../lib/grunt/utils.js');
4+
35

46
describe('ngdoc', function() {
57
var Doc = ngdoc.Doc;
@@ -287,6 +289,33 @@ describe('ngdoc', function() {
287289
});
288290
});
289291

292+
293+
describe('api section', function() {
294+
295+
it('should render a "view source" button with link to the source in master', function() {
296+
var doc = new Doc({
297+
id: 'ng.abc',
298+
name: 'ng.abc',
299+
section: 'api',
300+
ngdoc: 'service',
301+
file: 'fooService.js',
302+
line: '333'
303+
});
304+
305+
if (gruntUtil.getVersion().full.indexOf('-') === -1) {
306+
expect(doc.html().match(/^(<a .*?<\/a>)/)[1]).toMatch(
307+
/<a href="http:\/\/github\.com\/angular\/angular\.js\/tree\/v\d+\.\d+\.\d+\/fooService\.js#L333" class="view-source/
308+
);
309+
} else {
310+
expect(doc.html().match(/^(<a .*?<\/a>)/)[1]).toMatch(
311+
/<a href="http:\/\/github\.com\/angular\/angular\.js\/tree\/[a-z0-9]{7}\/fooService\.js#L333" class="view-source/
312+
);
313+
}
314+
});
315+
});
316+
317+
318+
290319
////////////////////////////////////////
291320

292321
describe('TAG', function() {

Diff for: docs/src/ngdoc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ Doc.prototype = {
552552
minerrMsg;
553553

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

557557
if (match) {
558558
// git sha

0 commit comments

Comments
 (0)