Add examples to reference (#1076)
* Updated examples urls * Added links to examples * Updated docs generation script to include code examples * Fixes * Skip index api * Fix link * Fix url generation * API generation * Fix new line * API generation * Fix leftover * API generation
This commit is contained in:
committed by
GitHub
parent
87ccc196a0
commit
d2bc399d9b
@ -4,8 +4,14 @@
|
||||
|
||||
'use strict'
|
||||
|
||||
const { readdirSync } = require('fs')
|
||||
const { join } = require('path')
|
||||
const dedent = require('dedent')
|
||||
|
||||
const codeExamples = readdirSync(join(__dirname, '..', '..', 'docs', 'examples'))
|
||||
.map(file => file.slice(0, -9))
|
||||
.filter(api => api !== 'index')
|
||||
|
||||
function generateDocs (common, spec) {
|
||||
var doc = dedent`
|
||||
[[api-reference]]
|
||||
@ -93,7 +99,7 @@ function commonParameters (spec) {
|
||||
=== Common parameters
|
||||
Parameters that are accepted by all API endpoints.
|
||||
|
||||
link:{ref}/common-options.html[Reference]
|
||||
link:{ref}/common-options.html[Documentation]
|
||||
[cols=2*]
|
||||
|===\n`
|
||||
Object.keys(spec.params).forEach(key => {
|
||||
@ -196,7 +202,10 @@ function generateApiDoc (spec) {
|
||||
client.${camelify(name)}(${codeParameters.length > 0 ? `{\n ${codeParameters}\n}` : ''})
|
||||
----\n`
|
||||
if (documentationUrl) {
|
||||
doc += `link:${documentationUrl}[Reference]\n`
|
||||
doc += `link:${documentationUrl}[Documentation] +\n`
|
||||
}
|
||||
if (codeExamples.includes(name)) {
|
||||
doc += `{jsclient}/${name.replace(/\./g, '_')}_examples.html[Code Example] +\n`
|
||||
}
|
||||
|
||||
if (params.length !== 0) {
|
||||
|
||||
Reference in New Issue
Block a user