Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions aio/tests/e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,25 @@ describe('site App', function() {
expect(results).toContain('Router');
});
});

describe('suggest edit link', () => {
it('should be present on all docs pages', () => {
page.navigateTo('tutorial/toh-pt1');
expect(page.ghLinks.count()).toEqual(1);
/* tslint:disable:max-line-length */
expect(page.ghLinks.get(0).getAttribute('href'))
.toMatch(/https:\/\/github\.com\/angular\/angular\/edit\/master\/aio\/content\/tutorial\/toh-pt1\.md\?message=docs%3A%20describe%20your%20change\.\.\./);

@lacolaco lacolaco Jun 11, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this feature will be released, some angular.io localization sites (at least our angular.jp) will customize it to jump to its own repository.
So I want this specs not to depend on angular/angular repository.

@martinsik martinsik Jun 11, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. After I've send the above comment, I found it's e2e testing so it doesn't affect to build aio. Sorry, and thank you. 🙌


page.navigateTo('guide/http');
expect(page.ghLinks.count()).toEqual(1);
/* tslint:disable:max-line-length */
expect(page.ghLinks.get(0).getAttribute('href'))
.toMatch(/https:\/\/github\.com\/angular\/angular\/edit\/master\/aio\/content\/guide\/http\.md\?message=docs%3A%20describe%20your%20change\.\.\./);
});

it('should not be present on top level pages', () => {
page.navigateTo('features');
expect(page.ghLinks.count()).toEqual(0);
});
});
});
2 changes: 1 addition & 1 deletion aio/tools/transforms/angular-content-package/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = new Package('angular-content', [basePackage, contentPackage])
readFilesProcessor.sourceFiles = readFilesProcessor.sourceFiles.concat([
{
basePath: CONTENTS_PATH,
include: CONTENTS_PATH + '/{cookbook,guide,tutorial}/**/*.md',
include: CONTENTS_PATH + '/{guide,tutorial}/**/*.md',
fileReader: 'contentFileReader'
},
{
Expand Down
2 changes: 1 addition & 1 deletion aio/tools/transforms/templates/api/base.template.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% import "lib/githubLinks.html" as github -%}
{% import "../lib/githubLinks.html" as github -%}
{% set comma = joiner(',') %}
{% set breadcrumbDelimiter = joiner('>') %}
<article>
Expand Down
2 changes: 1 addition & 1 deletion aio/tools/transforms/templates/api/includes/info-bar.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% import "lib/githubLinks.html" as github -%}
{% import "../../lib/githubLinks.html" as github -%}

<!-- INFO BAR -->
<section class="info-bar">
Expand Down
19 changes: 0 additions & 19 deletions aio/tools/transforms/templates/api/lib/githubLinks.html

This file was deleted.

10 changes: 9 additions & 1 deletion aio/tools/transforms/templates/content.template.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{% import "lib/githubLinks.html" as github -%}

{% set relativePath = doc.fileInfo.relativePath %}
{% if doc.title %}{$ ('# ' + doc.title.trim()) | marked $}{% endif %}
{% if 'guide/' in relativePath or 'tutorial/' in relativePath or 'docs.md' in relativePath %}
<div class="github-links">
{$ github.githubEditLink(doc, versionInfo) $}
</div>
{% endif %}
<div class="content">
{$ doc.description | marked $}
</div>
</div>
31 changes: 31 additions & 0 deletions aio/tools/transforms/templates/lib/githubLinks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% macro projectRelativePath(fileInfo) -%}
{$ fileInfo.realProjectRelativePath if fileInfo.realProjectRelativePath else fileInfo.projectRelativePath $}
{%- endmacro %}

{% macro githubViewHref(doc, versionInfo) -%}
https://github.com/{$ versionInfo.gitRepoInfo.owner $}/{$ versionInfo.gitRepoInfo.repo $}/tree/{$ versionInfo.currentVersion.isSnapshot and versionInfo.currentVersion.SHA or versionInfo.currentVersion.raw $}/packages/{$ doc.fileInfo.realProjectRelativePath $}#L{$ doc.startingLine + 1 $}-L{$ doc.endingLine + 1 $}
{%- endmacro %}

{% macro githubEditHref(doc, versionInfo) -%}
https://github.com/{$ versionInfo.gitRepoInfo.owner $}/{$ versionInfo.gitRepoInfo.repo $}/edit/master{$ '/packages' if doc.docType !== 'content' $}/{$ projectRelativePath(doc.fileInfo) $}?message=docs
{%- if doc.moduleDoc %}({$ doc.moduleDoc.id.split('/')[0] $})
{%- elseif doc.docType === 'module' %}({$ doc.id.split('/')[0] $})
{%- elseif doc.docType === 'content' %}
{%- else %}(...){%- endif -%}
%3A%20describe%20your%20change...{% if doc.docType !== 'content' %}#L{$ doc.startingLine + 1 $}-L{$ doc.endingLine + 1 $}{% endif %}
{%- endmacro %}

{% macro githubEditLink(doc, versionInfo) -%}
<a href="{$ githubEditHref(doc, versionInfo) $}" aria-label="Suggest Edits" title="Suggest Edits"><i class="material-icons" aria-hidden="true" role="img">mode_edit</i></a>
{%- endmacro %}

{% macro githubViewLink(doc, versionInfo) -%}
<a href="{$ githubViewHref(doc, versionInfo) $}" aria-label="View Source" title="View Source"><i class="material-icons" aria-hidden="true" role="img">code</i></a>
{%- endmacro %}

{% macro githubLinks(doc, versionInfo) -%}
<div class="github-links">
{$ githubEditLink(doc, versionInfo) $}
{$ githubViewLink(doc, versionInfo) $}
</div>
{%- endmacro -%}
2 changes: 1 addition & 1 deletion aio/tools/transforms/templates/overview-dump.template.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% import "api/lib/githubLinks.html" as github -%}
{% import "lib/githubLinks.html" as github -%}
{% import "api/lib/memberHelpers.html" as members -%}
{% macro goToCode(doc) %}<a href="{$ github.githubViewHref(doc, versionInfo) $}" class="go-to-code" title="Go to source code"><i class="material-icons" aria-hidden="true" role="img">code</i></a>{% endmacro %}
{% macro label(test, class, text) %}{% if test %}<label class="{$ class $}">{$ text $}</label>{% endif %}{% endmacro %}
Expand Down