-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'external-elasticsearch-docs' of https://github.com/camu…
…nda/camunda-docs into external-elasticsearch-docs
- Loading branch information
Showing
359 changed files
with
11,214 additions
and
1,789 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const { execSync } = require("child_process"); | ||
|
||
// More strategies to come, for other APIs. | ||
const operate = require("./operate/generation-strategy"); | ||
const zeebe = require("./zeebe/generation-strategy"); | ||
const tasklist = require("./tasklist/generation-strategy"); | ||
const apiStrategies = { | ||
operate, | ||
zeebe, | ||
tasklist, | ||
}; | ||
|
||
// Execute a command as if we were in the terminal | ||
function runCommand(command) { | ||
const result = execSync(command, { stdio: "inherit" }); | ||
return result; | ||
} | ||
|
||
// API name must be passed in as an arg. | ||
const api = process.argv[2]; | ||
if (api === undefined) { | ||
const validAPIs = string.join(apiStrategies.join, ", "); | ||
console.log(`Please specify an API name. Valid names: ${validAPIs}`); | ||
process.exit(); | ||
} | ||
|
||
// The API name must be recognized. | ||
const strategy = apiStrategies[api]; | ||
if (strategy === undefined) { | ||
const validAPIs = string.join(apiStrategies.join, ", "); | ||
console.error(`Invalid API name ${api}. Valid names: ${validAPIs}`); | ||
process.exit(); | ||
} | ||
|
||
// All APIs will execute these same steps, with custom-per-API steps | ||
// implemented by each API's generation-strategy.js. | ||
const steps = [ | ||
// Remove old docs | ||
() => runCommand(`docusaurus clean-api-docs ${api} -p api-${api}-openapi`), | ||
|
||
// Run any custom steps before generation | ||
strategy.preGenerateDocs, | ||
|
||
// Generate the docs | ||
() => runCommand(`docusaurus gen-api-docs ${api} -p api-${api}-openapi`), | ||
|
||
// Run any custom steps after generation | ||
strategy.postGenerateDocs, | ||
|
||
// Run prettier against the generated docs. Twice. Yes, twice. | ||
// I don't know why, but the first run always leaves an extra blank line, | ||
// which the second execution removes. | ||
() => runCommand(`prettier --write ${strategy.outputDir}`), | ||
() => runCommand(`prettier --write ${strategy.outputDir}`), | ||
]; | ||
|
||
// Run the steps! | ||
steps.forEach((step) => step()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const replace = require("replace-in-file"); | ||
|
||
function makeServerDynamic(specFile) { | ||
// The source spec has a hardcoded generated server URL. | ||
// We can make it dynamic so that the user can edit it and get more accurate code samples. | ||
console.log("making server dynamic...."); | ||
|
||
// Note that `v1` is included in this path. | ||
const dynamicServerDefinition = ` - url: "{schema}://{host}:{port}" | ||
variables: | ||
host: | ||
default: localhost | ||
description: The hostname of the API server. | ||
port: | ||
default: "8080" | ||
description: The port of the API server. | ||
schema: | ||
default: http | ||
description: The schema of the API server.`; | ||
replace.sync({ | ||
files: specFile, | ||
// This regex includes the following `description` line, which becomes inaccurate when we make the server dynamic. | ||
from: /^. - url:.*\n. description:.*$/m, | ||
to: dynamicServerDefinition, | ||
}); | ||
} | ||
exports.makeServerDynamic = makeServerDynamic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const { makeServerDynamic } = require("../make-server-dynamic"); | ||
const removeDuplicateVersionBadge = require("../remove-duplicate-version-badge"); | ||
|
||
const outputDir = "docs/apis-tools/operate-api/specifications"; | ||
const specFile = "api/operate/operate-openapi.yaml"; | ||
|
||
function preGenerateDocs() { | ||
makeServerDynamic(specFile); | ||
} | ||
|
||
function postGenerateDocs() { | ||
removeDuplicateVersionBadge(`${outputDir}/operate-public-api.info.mdx`); | ||
} | ||
|
||
module.exports = { | ||
outputDir, | ||
preGenerateDocs, | ||
postGenerateDocs, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.