Follow up of https://github.com/elastic/docs/pull/701.
This commit is contained in:
Tomas Della Vedova
2019-03-28 17:34:45 +01:00
committed by delvedor
parent f2c43a843b
commit f3422a6f43
10 changed files with 22 additions and 1 deletions

View File

@ -23,6 +23,7 @@ const dedent = require('dedent')
function generateDocs (common, spec) {
var doc = dedent`
[[api-reference]]
== API Reference
////////
@ -68,7 +69,7 @@ function commonParameters (spec) {
function generateApiDoc (spec) {
const name = Object.keys(spec)[0]
const documentationUrl = spec[name].documentation
const documentationUrl = fixLink(spec[name].documentation)
const params = []
// url params
const urlParts = spec[name].url.parts
@ -139,6 +140,17 @@ function generateApiDoc (spec) {
return doc
}
// Fixes bad urls in the JSON spec
function fixLink (str) {
if (!str) return ''
if (str.includes('/5.x/')) {
// fixes wrong url in ES5
str = str.replace(/5\.x/, '5.6')
}
return str
}
function getType (type, options) {
switch (type) {
case 'list':