refactor(docs-infra): refactor templates (#24378)

PR Close #24378
This commit is contained in:
Martin Sikora 2018-06-09 14:40:44 +02:00 committed by Misko Hevery
parent b89a7dd4a2
commit d539122466
6 changed files with 38 additions and 30 deletions

View File

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

View File

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

View File

@ -1,12 +1,12 @@
{% import "githubLinks.html" as github -%}
{% 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="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 class="github-links">
{$ github.githubEditLink(doc, versionInfo) $}
</div>
{% endif %}
<div class="content">
{$ doc.description | marked $}
</div>
</div>

View File

@ -1,23 +0,0 @@
{% 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' 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...{% if doc.docType !== 'content' %}#L{$ doc.startingLine + 1 $}-L{$ doc.endingLine + 1 $}{% endif %}
{%- endmacro -%}
{% macro githubLinks(doc, versionInfo) -%}
<div class="github-links">
<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 -%}

View File

@ -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 -%}

View File

@ -1,4 +1,4 @@
{% import "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 %}