feat(docs-infra): add "suggest edits" feature to all docs (#24378)

PR Close #24378
This commit is contained in:
Martin Sikora 2018-06-08 17:41:30 +02:00 committed by Misko Hevery
parent 06d04002fd
commit 9533cc9809
6 changed files with 17 additions and 8 deletions

View File

@ -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'
},
{

View File

@ -1,4 +1,4 @@
{% import "lib/githubLinks.html" as github -%}
{% import "../githubLinks.html" as github -%}
{% set comma = joiner(',') %}
{% set breadcrumbDelimiter = joiner('>') %}
<article>

View File

@ -1,4 +1,4 @@
{% import "lib/githubLinks.html" as github -%}
{% import "../../githubLinks.html" as github -%}
<!-- INFO BAR -->
<section class="info-bar">

View File

@ -1,4 +1,9 @@
{% import "githubLinks.html" as github -%}
{% if doc.title %}{$ ('# ' + doc.title.trim()) | marked $}{% endif %}
<div class="page-actions">
<a href="{$ github.githubEditHref(doc, versionInfo) $}" aria-label="Suggest Edits" title="Suggest Edits"><i class="material-icons" aria-hidden="true" role="img">mode_edit</i></a>
</div>
<div class="content">
{$ doc.description | marked $}
</div>

View File

@ -1,14 +1,18 @@
{% 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 or doc.fileInfo.relativePath $}#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/{$ doc.fileInfo.realProjectRelativePath or doc.fileInfo.relativePath $}?message=docs(
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 === 'package' %}{$ doc.id.split('/')[0] $}
{%- elseif doc.docType === 'content' %}aio
{%- else %}...{%- endif -%}
)%3A%20describe%20your%20change...#L{$ doc.startingLine + 1 $}-L{$ doc.endingLine + 1 $}
)%3A%20describe%20your%20change...{% if doc.docType !== 'content' %}#L{$ doc.startingLine + 1 $}-L{$ doc.endingLine + 1 $}{% endif %}
{%- endmacro -%}
{% macro githubLinks(doc, versionInfo) -%}
@ -16,4 +20,4 @@ https://github.com/{$ versionInfo.gitRepoInfo.owner $}/{$ versionInfo.gitRepoInf
<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>
<a href="{$ githubViewHref(doc, versionInfo) $}" aria-label="View Source" title="View Source"><i class="material-icons" aria-hidden="true" role="img">code</i></a>
</div>
{%- endmacro -%}
{%- endmacro -%}

View File

@ -1,4 +1,4 @@
{% import "api/lib/githubLinks.html" as github -%}
{% import "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 %}