build(aio): add github links to API doc members (#24000)
This change adds Github edit and view links to methods and decorator options. It is possible to add these to properties also but the UI is rather tight as these are displayed in a table. PR Close #24000
This commit is contained in:

committed by
Miško Hevery

parent
f43cb9398c
commit
fbe6871a94
@ -1,4 +1,4 @@
|
|||||||
.page-actions {
|
.github-links {
|
||||||
float: right;
|
float: right;
|
||||||
.material-icons {
|
.material-icons {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
@ -32,12 +32,28 @@
|
|||||||
|
|
||||||
.method-table, .option-table {
|
.method-table, .option-table {
|
||||||
th {
|
th {
|
||||||
padding: 8px 16px;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.github-links {
|
||||||
|
a {
|
||||||
|
color: $mediumgray;
|
||||||
|
.material-icons:hover {
|
||||||
|
background: none;
|
||||||
|
color: $blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
margin: 6px 0;
|
margin: 6px 0;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
clear: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
h4 {
|
h4 {
|
||||||
|
@ -2,10 +2,7 @@
|
|||||||
{% set comma = joiner(',') %}
|
{% set comma = joiner(',') %}
|
||||||
{% set slash = joiner('/') %}
|
{% set slash = joiner('/') %}
|
||||||
<article>
|
<article>
|
||||||
<div class="page-actions">
|
{$ github.githubLinks(doc, versionInfo) $}
|
||||||
<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>
|
|
||||||
<a href="{$ github.githubViewHref(doc, versionInfo) $}" aria-label="View Source" title="View Source"><i class="material-icons" aria-hidden="true" role="img">code</i></a>
|
|
||||||
</div>
|
|
||||||
<div class="breadcrumb">
|
<div class="breadcrumb">
|
||||||
<script type="application/ld+json">
|
<script type="application/ld+json">
|
||||||
{
|
{
|
||||||
|
@ -10,14 +10,14 @@
|
|||||||
{% block additional %}{% endblock %}
|
{% block additional %}{% endblock %}
|
||||||
{% include "includes/description.html" %}
|
{% include "includes/description.html" %}
|
||||||
{$ memberHelpers.renderProperties(doc.staticProperties, 'static-properties', 'static-property', 'Static Properties') $}
|
{$ memberHelpers.renderProperties(doc.staticProperties, 'static-properties', 'static-property', 'Static Properties') $}
|
||||||
{$ memberHelpers.renderMethodDetails(doc.staticMethods, 'static-methods', 'static-method', 'Static Methods') $}
|
{$ memberHelpers.renderMethodDetails(versionInfo, doc.staticMethods, 'static-methods', 'static-method', 'Static Methods') $}
|
||||||
{% if doc.constructorDoc %}
|
{% if doc.constructorDoc %}
|
||||||
<h2>Constructor</h2>
|
<h2>Constructor</h2>
|
||||||
{$ memberHelpers.renderMethodDetail(doc.constructorDoc, 'constructor') $}{% endif %}
|
{$ memberHelpers.renderMethodDetail(versionInfo, doc.constructorDoc, 'constructor') $}{% endif %}
|
||||||
|
|
||||||
{$ memberHelpers.renderProperties(doc.properties, 'instance-properties', 'instance-property', 'Properties') $}
|
{$ memberHelpers.renderProperties(doc.properties, 'instance-properties', 'instance-property', 'Properties') $}
|
||||||
|
|
||||||
{$ memberHelpers.renderMethodDetails(doc.methods, 'instance-methods', 'instance-method', 'Methods') $}
|
{$ memberHelpers.renderMethodDetails(versionInfo, doc.methods, 'instance-methods', 'instance-method', 'Methods') $}
|
||||||
|
|
||||||
{% block annotations %}{% include "includes/annotations.html" %}{% endblock %}
|
{% block annotations %}{% include "includes/annotations.html" %}{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
{% import "lib/githubLinks.html" as github -%}
|
||||||
{% import "lib/memberHelpers.html" as memberHelper -%}
|
{% import "lib/memberHelpers.html" as memberHelper -%}
|
||||||
{% import "lib/paramList.html" as params -%}
|
{% import "lib/paramList.html" as params -%}
|
||||||
{% extends 'export-base.template.html' %}
|
{% extends 'export-base.template.html' %}
|
||||||
@ -11,7 +12,10 @@
|
|||||||
{% for option in doc.members %}
|
{% for option in doc.members %}
|
||||||
<a id="{$ option.anchor $}"></a>
|
<a id="{$ option.anchor $}"></a>
|
||||||
<table class="is-full-width option-table">
|
<table class="is-full-width option-table">
|
||||||
<thead><tr><th><h3>{$ option.name $}</h3></th></tr></thead>
|
<thead><tr><th>
|
||||||
|
<h3>{$ option.name $}</h3>
|
||||||
|
{$ github.githubLinks(option, versionInfo) $}
|
||||||
|
</th></tr></thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% import "lib/descendants.html" as descendants -%}
|
{% import "lib/descendants.html" as descendants -%}
|
||||||
|
|
||||||
{% macro renderOptionsTable(doc) %}
|
{% macro renderOptionsTable(doc) %}
|
||||||
<table class="is-full-width list-table option-table">
|
<table class="is-full-width list-table option-overview">
|
||||||
<thead>
|
<thead>
|
||||||
<tr><th>Option</th><th>Description</th></tr>
|
<tr><th>Option</th><th>Description</th></tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -7,5 +7,5 @@
|
|||||||
{% block details %}
|
{% block details %}
|
||||||
{% include "includes/description.html" %}
|
{% include "includes/description.html" %}
|
||||||
{$ memberHelper.renderProperties(doc.properties, 'instance-properties', 'instance-property', 'Properties') $}
|
{$ memberHelper.renderProperties(doc.properties, 'instance-properties', 'instance-property', 'Properties') $}
|
||||||
{$ memberHelper.renderMethodDetails(doc.methods, 'instance-methods', 'instance-method', 'Methods') $}
|
{$ memberHelper.renderMethodDetails(versionInfo, doc.methods, 'instance-methods', 'instance-method', 'Methods') $}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% macro githubViewHref(doc, versionInfo) -%}
|
{% 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 $}
|
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 %}
|
{%- endmacro -%}
|
||||||
|
|
||||||
|
|
||||||
{% macro githubEditHref(doc, versionInfo) -%}
|
{% macro githubEditHref(doc, versionInfo) -%}
|
||||||
@ -9,4 +9,11 @@ https://github.com/{$ versionInfo.gitRepoInfo.owner $}/{$ versionInfo.gitRepoInf
|
|||||||
{%- elseif doc.docType === 'module' %}{$ doc.id.split('/')[0] $}
|
{%- elseif doc.docType === 'module' %}{$ doc.id.split('/')[0] $}
|
||||||
{%- else %}...{%- endif -%}
|
{%- else %}...{%- endif -%}
|
||||||
)%3A%20describe%20your%20change...#L{$ doc.startingLine + 1 $}-L{$ doc.endingLine + 1 $}
|
)%3A%20describe%20your%20change...#L{$ doc.startingLine + 1 $}-L{$ doc.endingLine + 1 $}
|
||||||
{%- endmacro %}
|
{%- 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 -%}
|
@ -1,3 +1,4 @@
|
|||||||
|
{% import "lib/githubLinks.html" as github -%}
|
||||||
{% import "lib/paramList.html" as params -%}
|
{% import "lib/paramList.html" as params -%}
|
||||||
|
|
||||||
{%- macro renderHeritage(exportDoc) -%}
|
{%- macro renderHeritage(exportDoc) -%}
|
||||||
@ -69,15 +70,18 @@
|
|||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
|
|
||||||
{%- macro renderMethodDetail(method, cssClass) -%}
|
{%- macro renderMethodDetail(versionInfo, method, cssClass) -%}
|
||||||
<a id="{$ method.anchor $}"></a>
|
<a id="{$ method.anchor $}"></a>
|
||||||
<table class="is-full-width method-table {$ cssClass $}">
|
<table class="is-full-width method-table {$ cssClass $}">
|
||||||
{% if method.name !== 'constructor' %}<thead><tr><th><h3>
|
{% if method.name !== 'constructor' %}<thead><tr><th>
|
||||||
|
<h3>
|
||||||
{% if method.isCallMember %}<i>call signature</i>
|
{% if method.isCallMember %}<i>call signature</i>
|
||||||
{% elseif method.isNewMember %}<i>construct signature</i>
|
{% elseif method.isNewMember %}<i>construct signature</i>
|
||||||
{% else %}{$ method.name $}()
|
{% else %}{$ method.name $}()
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</h3></th></tr></thead>{% endif %}
|
</h3>
|
||||||
|
{$ github.githubLinks(method, versionInfo) $}
|
||||||
|
</th></tr></thead>{% endif %}
|
||||||
<tbody>
|
<tbody>
|
||||||
{% if method.shortDescription %}<tr>
|
{% if method.shortDescription %}<tr>
|
||||||
<td class="short-description">
|
<td class="short-description">
|
||||||
@ -133,13 +137,13 @@
|
|||||||
</table>
|
</table>
|
||||||
{% endmacro -%}
|
{% endmacro -%}
|
||||||
|
|
||||||
{%- macro renderMethodDetails(methods, containerClass, itemClass, headingText) -%}
|
{%- macro renderMethodDetails(versionInfo, methods, containerClass, itemClass, headingText) -%}
|
||||||
{% set nonInternalMethods = methods | filterByPropertyValue('internal', undefined) %}
|
{% set nonInternalMethods = methods | filterByPropertyValue('internal', undefined) %}
|
||||||
{% if nonInternalMethods.length %}
|
{% if nonInternalMethods.length %}
|
||||||
<section class="{$ containerClass $}">
|
<section class="{$ containerClass $}">
|
||||||
<h2>{$ headingText $}</h2>
|
<h2>{$ headingText $}</h2>
|
||||||
{% for member in nonInternalMethods %}
|
{% for member in nonInternalMethods %}
|
||||||
{$ renderMethodDetail(member, itemClass) $}
|
{$ renderMethodDetail(versionInfo, member, itemClass) $}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</section>
|
</section>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Reference in New Issue
Block a user