[generate/api] rewrite doc urls with branch

(cherry picked from commit 8fa499d070)
This commit is contained in:
spalger
2017-07-31 12:19:02 -07:00
parent 5813360d3f
commit 1649059c8c

View File

@ -33,7 +33,9 @@ module.exports = function (branch, done) {
var steps = [ var steps = [
readSpecFiles, readSpecFiles,
parseSpecFiles, function (done) {
parseSpecFiles(branch, done);
},
writeApiFile writeApiFile
]; ];
@ -64,11 +66,11 @@ module.exports = function (branch, done) {
done(); done();
} }
function parseSpecFiles(done) { function parseSpecFiles(branch, done) {
var actions = []; var actions = [];
files.forEach(function (spec) { files.forEach(function (spec) {
__puke__transformSpec(spec).forEach(function (action) { __puke__transformSpec(branch, spec).forEach(function (action) {
actions.push(action); actions.push(action);
}); });
}); });
@ -186,7 +188,7 @@ module.exports = function (branch, done) {
); );
} }
function __puke__transformSpec(spec) { // eslint-disable-line function __puke__transformSpec(branch, spec) { // eslint-disable-line
var actions = []; var actions = [];
// itterate all of the specs within the file, should only be one // itterate all of the specs within the file, should only be one
@ -198,6 +200,11 @@ module.exports = function (branch, done) {
def.documentation = 'http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html'; def.documentation = 'http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html';
} }
def.documentation = def.documentation.replace(
/^https?:\/\/.+?\/guide\/en\/elasticsearch\/(.+?)\/.+?\//,
`https://www.elastic.co/guide/en/elasticsearch/$1/${branch}/`
);
var steps = name.split('.'); var steps = name.split('.');
function transformParamKeys(note, param, key) { function transformParamKeys(note, param, key) {