-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shortcut to build asciidocs (#13164)
* Shortcut to build asciidocs The command to build the Kibana docs using the elastic/docs repo can be easy to forget, so this script is an easy to way to do it right every time. * Configurable docs repo location For folks that clone the elastic docs repo to a different location than as a sibling of kibana.
- Loading branch information
Showing
4 changed files
with
64 additions
and
0 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
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,2 @@ | ||
require('../src/optimize/babel/register'); | ||
require('../src/docs/cli'); |
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,26 @@ | ||
import { execFileSync } from 'child_process'; | ||
import { Command } from 'commander'; | ||
|
||
import { | ||
defaultDocsRepoPath, | ||
buildDocsScript, | ||
buildDocsArgs | ||
} from './docs_repo'; | ||
|
||
const cmd = new Command('node scripts/docs'); | ||
cmd | ||
.option('--docrepo [path]', 'local path to the docs repo', defaultDocsRepoPath()) | ||
.option('--open', 'open the docs in the browser', false) | ||
.parse(process.argv); | ||
|
||
try { | ||
execFileSync(buildDocsScript(cmd), buildDocsArgs(cmd)); | ||
} catch (err) { | ||
if (err.code === 'ENOENT') { | ||
console.error(`elastic/docs repo must be cloned to ${cmd.docrepo}`); | ||
} else { | ||
console.error(err.stack); | ||
} | ||
|
||
process.exit(1); | ||
} |
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,20 @@ | ||
import { resolve } from 'path'; | ||
|
||
const kibanaDir = resolve(__dirname, '..', '..'); | ||
|
||
export function buildDocsScript(cmd) { | ||
return resolve(process.cwd(), cmd.docrepo, 'build_docs.pl'); | ||
} | ||
|
||
export function buildDocsArgs(cmd) { | ||
const docsIndexFile = resolve(kibanaDir, 'docs', 'index.asciidoc'); | ||
let args = ['--doc', docsIndexFile, '--chunk=1']; | ||
if (cmd.open) { | ||
args = [...args, '--open']; | ||
} | ||
return args; | ||
} | ||
|
||
export function defaultDocsRepoPath() { | ||
return resolve(kibanaDir, '..', 'docs'); | ||
} |