ui: Enable specifying additional docfy config as json (#10464)

This commit is contained in:
John Cowen 2021-06-25 10:41:41 +01:00 committed by GitHub
parent a64c9a3e62
commit ace794d214
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 9 deletions

View File

@ -1,11 +1,33 @@
const path = require('path'); const path = require('path');
const autolinkHeadings = require('remark-autolink-headings'); const autolinkHeadings = require('remark-autolink-headings');
const refractor = require('refractor'); const refractor = require('refractor');
const prism = require('@mapbox/rehype-prism'); const prism = require('@mapbox/rehype-prism');
const fs = require('fs');
const read = fs.readFileSync;
const exists = fs.existsSync;
const chalk = require('chalk'); // comes with ember
// allow extra docfy config
let user = {sources: [], labels: {}};
const $CONSUL_DOCFY_CONFIG = process.env.CONSUL_DOCFY_CONFIG || '';
if($CONSUL_DOCFY_CONFIG.length > 0) {
try {
if(exists($CONSUL_DOCFY_CONFIG)) {
user = JSON.parse(read($CONSUL_DOCFY_CONFIG));
} else {
throw new Error(`Unable to locate ${$CONSUL_DOCFY_CONFIG}`);
}
} catch(e) {
console.error(chalk.yellow(`Docfy: ${e.message}`));
}
}
refractor.alias('handlebars', 'hbs'); refractor.alias('handlebars', 'hbs');
refractor.alias('shell', 'sh'); refractor.alias('shell', 'sh');
module.exports = { module.exports = {
remarkHbsOptions: { remarkHbsOptions: {
escapeCurliesCode: false escapeCurliesCode: false
@ -56,8 +78,9 @@ module.exports = {
urlSchema: 'auto', urlSchema: 'auto',
urlPrefix: 'docs/consul', urlPrefix: 'docs/consul',
} }
], ].concat(user.sources),
labels: { labels: {
"consul": "Consul Components" "consul": "Consul Components",
...user.labels
} }
}; };

View File

@ -90,12 +90,7 @@ CONSUL_HTTP_ADDR=http://10.0.0.1:8500 make start-consul
### Environment Variables ### Environment Variables
There are various environment variable you can use whilst running `make start` or `make test` to configure various features: See [./docs/index.mdx](./docs/index.mdx#environment-variables)
| Variable | Default Value | Description |
| -------- | ------------- | ----------- |
| `TESTEM_AUTOLAUNCH` | Chrome | Controls which browser to open tests in. A setting of "" means 'let me manually open the browser' |
| `EMBER_TEST_REPORT` | | Output a test report |
### Contributing/Engineering Documentation ### Contributing/Engineering Documentation

View File

@ -57,7 +57,8 @@ html.is-debug body > .brand-loader {
} }
> h1, > h1,
> h2, > h2,
> h3 { > h3,
> h4 {
margin-bottom: 1em; margin-bottom: 1em;
} }
> h1 { > h1 {
@ -70,6 +71,9 @@ html.is-debug body > .brand-loader {
> h3 { > h3 {
@extend %h300; @extend %h300;
} }
> h4 {
@extend %h400;
}
> p { > p {
@extend %p1; @extend %p1;
} }

View File

@ -5,6 +5,16 @@ title: Introduction
Welcome to Consul UIs engineering documentation. Welcome to Consul UIs engineering documentation.
## Environment Variables
There are various environment variable you can use whilst running `make start` or `make test` to configure various features:
| Variable | Default Value | Description |
| -------- | ------------- | ----------- |
| `TESTEM_AUTOLAUNCH` | Chrome | Controls which browser to open tests in. A setting of `""` means 'let me manually open the browser' |
| `EMBER_TEST_REPORT` | | Output a test report |
| `CONSUL_DOCFY_CONFIG` | | Define an additional `docfy-config.json` file to use |
## Adding documentation ## Adding documentation
Our documentation use [docfy](https://docfy.dev/docs) for rendering our markdown+glimmer-component documentation. In order to live render any code examples use the `preview-template` meta, for example: Our documentation use [docfy](https://docfy.dev/docs) for rendering our markdown+glimmer-component documentation. In order to live render any code examples use the `preview-template` meta, for example: