Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcut to build asciidocs #13164

Merged
merged 3 commits into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ A high level overview of our contributing guidelines.
- [Running Browser Automation Tests](#running-browser-automation-tests)
- [Browser Automation Notes](#browser-automation-notes)
- [Building OS packages](#building-os-packages)
- [Writing documentation](#writing-documentation)
- [Signing the contributor license agreement](#signing-the-contributor-license-agreement)
- [Submitting a Pull Request](#submitting-a-pull-request)
- [Code Reviewing](#code-reviewing)
Expand Down Expand Up @@ -362,6 +363,21 @@ npm run build -- --rpm

Distributable packages can be found in `target/` after the build completes.

### Writing documentation

Kibana documentation is written in [asciidoc](http://asciidoc.org/) format in
the `docs/` directory.

To build the docs, you must clone the [elastic/docs](https://github.com/elastic/docs)
repo as a sibling of your kibana repo. Follow the instructions in that project's
README for getting the docs tooling set up.

**To build the docs and open them in your browser:**

```bash
node scripts/docs.js --open
```

## Signing the contributor license agreement

Please make sure you have signed the [Contributor License Agreement](http://www.elastic.co/contributor-agreement/). We are not asking you to assign copyright to us, but to give us the right to distribute your code without restriction. We ask this of all contributors in order to assure our users of the origin and continuing existence of the code. You only need to sign the CLA once.
Expand Down
2 changes: 2 additions & 0 deletions scripts/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require('../src/optimize/babel/register');
require('../src/docs/cli');
21 changes: 21 additions & 0 deletions src/docs/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { execFileSync } from 'child_process';
import { resolve } from 'path';

const kibanaDir = resolve(__dirname, '..', '..');
const docsIndexFile = resolve(kibanaDir, 'docs', 'index.asciidoc');
const docsToolDir = resolve(kibanaDir, '..', 'docs');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a fallback for elastic-docs? I can't stand having a docs project in my dev directory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about an environment variable fallback? I'm not a big fan of hardcoding alternatives

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer a command line flag if it's going to be an argument

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call

const docsToolCmd = resolve(docsToolDir, 'build_docs.pl');

const args = process.argv.slice(2);

try {
execFileSync(docsToolCmd, ['--doc', docsIndexFile, '--chunk=1', ...args]);
} catch (err) {
if (err.code === 'ENOENT') {
console.error(`elastic/docs repo must be cloned to ${docsToolDir}`);
} else {
console.error(err.stack);
}

process.exit(1);
}