build(aio): fix generated github links

The change from `modules` to `packages` needed to be applied to these links.
This commit is contained in:
Peter Bacon Darwin 2017-03-17 23:02:03 +00:00 committed by Miško Hevery
parent b4081e3713
commit 31ef92fc36
3 changed files with 18 additions and 4 deletions

View File

@ -17,6 +17,14 @@ describe('site App', function() {
it('should convert a doc with a code-example');
describe('api-docs', () => {
it('should show a link to github', () => {
page.navigateTo('api/common/NgClass');
expect(page.ghLink.getAttribute('href'))
.toMatch(/https:\/\/github.com\/angular\/angular\/tree\/.+\/packages\/common\/src\/directives\/ng_class\.ts/);
});
});
describe('google analytics', () => {
beforeEach(done => page.gaReady.then(done));

View File

@ -1,16 +1,22 @@
import { browser, element, by, promise } from 'protractor';
import { browser, element, by, promise, ElementFinder } from 'protractor';
const githubRegex = /https:\/\/github.com\/angular\/angular\//;
export class SitePage {
links = element.all(by.css('md-toolbar a'));
docViewer = element(by.css('aio-doc-viewer'));
codeExample = element.all(by.css('aio-doc-viewer pre > code'));
ghLink = this.docViewer
.all(by.css('a'))
.filter((a: ElementFinder) => a.getAttribute('href').then(href => githubRegex.test(href)))
.first();
featureLink = element(by.css('md-toolbar a[href="features"]'));
gaReady: promise.Promise<any>;
ga = () => browser.executeScript('return window["gaCalls"]') as promise.Promise<any[][]>;
locationPath = () => browser.executeScript('return document.location.pathname') as promise.Promise<string>;
navigateTo() {
return browser.get('/').then(_ => this.replaceGa(_));
navigateTo(pageUrl = '') {
return browser.get('/' + pageUrl).then(_ => this.replaceGa(_));
}
getDocViewerText() {

View File

@ -1,5 +1,5 @@
{% macro githubHref(doc, versionInfo) -%}
https://github.com/{$ versionInfo.gitRepoInfo.owner $}/{$ versionInfo.gitRepoInfo.repo $}/tree/{$ versionInfo.currentVersion.isSnapshot and versionInfo.currentVersion.SHA or versionInfo.currentVersion.raw $}/modules/{$ doc.fileInfo.projectRelativePath $}#L{$ doc.location.start.line+1 $}-L{$ doc.location.end.line+1 $}
https://github.com/{$ versionInfo.gitRepoInfo.owner $}/{$ versionInfo.gitRepoInfo.repo $}/tree/{$ versionInfo.currentVersion.isSnapshot and versionInfo.currentVersion.SHA or versionInfo.currentVersion.raw $}/packages/{$ doc.fileInfo.projectRelativePath $}#L{$ doc.location.start.line+1 $}-L{$ doc.location.end.line+1 $}
{%- endmacro %}
{% macro githubViewLink(doc, versionInfo) -%}