Skip to content

Commit

Permalink
docs(api-ref): display tuples properly, lookup type references by name
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickarlt committed Dec 27, 2017
1 parent 881d0ea commit d3729fe
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
4 changes: 3 additions & 1 deletion docs/acetate.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { inspect } = require("util");
const _ = require("lodash");
const slug = require("slug");

const IS_DEV = process.env.ENV !== "prod";
const BASE_URL = process.env.ENV === "prod" ? "/arcgis-rest-js" : "";

module.exports = function(acetate) {
Expand All @@ -25,7 +26,8 @@ module.exports = function(acetate) {
});

acetate.metadata("**/*", {
baseUrl: BASE_URL
baseUrl: BASE_URL,
isDev: IS_DEV
});

/**
Expand Down
31 changes: 25 additions & 6 deletions docs/src/api/_declaration.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{% macro @type(type) -%}
{%- if type.type === 'intrinsic' -%}
<i>{{type.name}}</i>
<i class="text-purple">{{type.name}}</i>
{%- endif -%}

{%- if type.type === 'reference' and type.id -%}
<i><a href="{{ baseUrl + API_TOOLS.findById(data.typedoc, type.id).pageUrl }}">{{type.name}}</a></i>
{%- elif API_TOOLS.findByName(data.typedoc, type.name) -%}
<i><a href="{{ baseUrl + API_TOOLS.findByName(data.typedoc, type.name).pageUrl }}">{{type.name}}</a></i>
{%- elif type.type === 'reference' -%}
<i>{{type.name}}</i>
{%- endif -%}
Expand All @@ -23,7 +25,7 @@
{%- if t.type === 'stringLiteral' -%}
<span class="text-green">"{{t.value}}"</span>
{%- else -%}
{{t.value or t.name}}
{{ @type(t) }}
{%- endif -%}

{%- if (loop.last === false) -%}
Expand All @@ -32,6 +34,21 @@
{%- endfor -%}</i>
{%- endif -%}

{%- if type.type === 'tuple' -%}
<i class="no-wrap">{%- for t in type.elements -%}
{%- if (loop.first) -%}
<span class="text-light-gray">{{ '[' }}</span>
{%- endif -%}
{{ @type(t) }}
{%- if (loop.last === false) -%}
<span class="text-light-gray">{{ ', ' }}</span>
{%- endif -%}
{%- if (loop.last) -%}
<span class="text-light-gray">{{ ']' }}</span>
{%- endif -%}
{%- endfor -%}</i>
{%- endif -%}

{%- if type.typeArguments -%}
<i>{% for arg in type.typeArguments -%}
{%- if (loop.first) -%}<span class="text-light-gray">{{ '<' }}</span>{%- endif -%}
Expand Down Expand Up @@ -455,7 +472,9 @@ <h3>Index Signatures</h3>

<small class="font-size--2">{{kindString}} defined in <a href="https://github.com/Esri/arcgis-rest-js/blob/master/packages/{{sources[0].fileName}}#L{{sources[0].line}}">packages/{{sources[0].fileName}}:{{sources[0].line}}</a></small>

<details class="leader-1">
<summary>Debug Info</summary>
<pre><code>{{__defaultMetadata.indexSignature[0] | inspect}}</code></pre>
</details>
{% if isDev %}
<details class="leader-1">
<summary>Debug Info</summary>
<pre><code>{{__defaultMetadata.children[0].type | inspect}}</code></pre>
</details>
{% endif %}

0 comments on commit d3729fe

Please sign in to comment.