Skip to content

Commit e7f7993

Browse files
nik9000delvedor
authored andcommitted
Docs: Handle more funny cases from ES api spec (#800)
Handles a few "special" doc urls from ES's api spec files. These are only a problem in 6.x but we'd like to keep the generateDocs script the same across all branches for easier backporting.
1 parent baac038 commit e7f7993

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scripts/utils/generateDocs.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,15 @@ const LINK_OVERRIDES = {
156156
}
157157
// Fixes bad urls in the JSON spec
158158
function fixLink (name, str) {
159+
/* In 6.x some API start with `xpack.` when in master they do not. We
160+
* can safely ignore that for link generation. */
161+
name = name.replace(/^xpack\./, '')
159162
const override = LINK_OVERRIDES[name]
160163
if (override) return override
161164
if (!str) return ''
162165
/* Replace references to the guide with the attribute {ref} because
163166
* the json files in the Elasticsearch repo are a bit of a mess. */
164-
str = str.replace(/^.+guide\/en\/elasticsearch\/reference\/[^/]+\/([^./]*\.html)$/, '{ref}/$1')
167+
str = str.replace(/^.+guide\/en\/elasticsearch\/reference\/[^/]+\/([^./]*\.html(?:#.+)?)$/, '{ref}/$1')
165168
str = str.replace(/frozen\.html/, 'freeze-index-api.html')
166169
str = str.replace(/ml-file-structure\.html/, 'ml-find-file-structure.html')
167170
str = str.replace(/security-api-get-user-privileges\.html/, 'security-api-get-privileges.html')

0 commit comments

Comments
 (0)