Skip to content
Merged
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
14 changes: 6 additions & 8 deletions lib/api-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const fs = require('fs')
const path = require('path')

const BASE_URL = 'https://api.tgcloud.io'
// Replaced in lib/split-endpoints.js with an AsciiDoc xref. A hand-written
// href cannot be used here: production drops the .html extension and then
// rewrites leftover .html links to site-root paths, which 404 under /docs.
const API_KEY_XREF_MARKER = '@@API_KEY_XREF@@'
// Deep enough for every schema in the current spec; only a guard against a
// pathological one. Recursion already stops when a definition repeats.
const MAX_DEPTH = 12
Expand Down Expand Up @@ -262,13 +266,7 @@ function renderAuthorizations (operation, pad) {
'<p>' + escapeHtml(scheme.description) + '. Send the key in the <code>' +
escapeHtml(scheme.name) + '</code> request ' + scheme.in + '.</p>'
)
// The publisher only rewrites in-content links that carry Antora's xref
// classes; without them this relative href is resolved against the site
// root and loses the /docs base path.
out.push(
indent(pad + 4) +
'<a href="../create-api-key.html" class="xref page">Create an API key</a>'
)
out.push(API_KEY_XREF_MARKER)
out.push(indent(pad + 2) + '</div>')
}
}
Expand Down Expand Up @@ -654,4 +652,4 @@ function renderApiPage (endpoint) {
return out.join('\n')
}

module.exports = { renderApiPage }
module.exports = { renderApiPage, API_KEY_XREF_MARKER }
27 changes: 16 additions & 11 deletions lib/split-endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

const fs = require('fs')
const path = require('path')
const { renderApiPage } = require('./api-page')
const { renderApiPage, API_KEY_XREF_MARKER } = require('./api-page')
const API_KEY_XREF = 'xref:rest-api:create-api-key.adoc[Create an API key]'

const MODULE_DIR = path.join(__dirname, '..', 'modules/savanna/modules/rest-api')
const CATALOG = path.join(MODULE_DIR, '_catalog/endpoints.adoc')
Expand Down Expand Up @@ -151,16 +152,20 @@ function parseCatalog (text) {
}

function renderPage (endpoint, label) {
return [
'= ' + label,
':page-role: api-endpoint-detail',
GENERATED,
'',
'++++',
renderApiPage(endpoint),
'++++',
'',
].join('\n')
// The xref has to be AsciiDoc, not a raw <a href="../create-api-key.html">.
// Production uses html_extension_style: drop, then rewrites any leftover
// .html href into a root-absolute path (/savanna/...). That URL 404s on
// www.tigergraph.com/docs because the /docs prefix is not part of the path.
// Antora resolves this xref to a relative, extensionless URL, which is what
// every other in-content link on the site already uses.
const chunks = renderApiPage(endpoint).split(API_KEY_XREF_MARKER)
const blocks = []
chunks.forEach((chunk, index) => {
blocks.push('++++', chunk.replace(/^\n/, '').replace(/\n$/, ''), '++++')
if (index === chunks.length - 1) return
blocks.push('', '[subs=macros]', '++++', API_KEY_XREF, '++++', '')
})
return ['= ' + label, ':page-role: api-endpoint-detail', GENERATED, '', ...blocks, ''].join('\n')
}

function renderNav (grouped) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-body-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-body-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
<span class="api-required">required</span>
</div>
<p>Authorization for TigerGraph Savanna. Send the key in the <code>x-api-key</code> request header.</p>
<a href="../create-api-key.html" class="xref page">Create an API key</a>
++++

[subs=macros]
++++
xref:rest-api:create-api-key.adoc[Create an API key]
++++

++++
</div>
</section>
<section class="api-section" aria-labelledby="api-path-parameters-title">
Expand Down
Loading
Loading