Skip to content

Commit

Permalink
Merge branch 'main' into a11y-popover
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Nov 8, 2021
2 parents 7cd6bf4 + 83a409c commit cb3a07f
Show file tree
Hide file tree
Showing 624 changed files with 4,109 additions and 2,134 deletions.
2 changes: 1 addition & 1 deletion scripts/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
*/

require('../src/setup_node_env');
require('../src/docs/cli');
require('../src/dev/run_build_docs_cli').runBuildDocsCli();
64 changes: 64 additions & 0 deletions src/dev/run_build_docs_cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import Path from 'path';

import dedent from 'dedent';
import { run, REPO_ROOT, createFailError } from '@kbn/dev-utils';

const DEFAULT_DOC_REPO_PATH = Path.resolve(REPO_ROOT, '..', 'docs');

const rel = (path: string) => Path.relative(process.cwd(), path);

export function runBuildDocsCli() {
run(
async ({ flags, procRunner }) => {
const docRepoPath =
typeof flags.docrepo === 'string' && flags.docrepo
? Path.resolve(process.cwd(), flags.docrepo)
: DEFAULT_DOC_REPO_PATH;

try {
await procRunner.run('build_docs', {
cmd: rel(Path.resolve(docRepoPath, 'build_docs')),
args: [
['--doc', rel(Path.resolve(REPO_ROOT, 'docs/index.asciidoc'))],
['--chunk', '1'],
flags.open ? ['--open'] : [],
].flat(),
cwd: REPO_ROOT,
wait: true,
});
} catch (error) {
if (error.code === 'ENOENT') {
throw createFailError(dedent`
Unable to run "build_docs" script from docs repo.
Does it exist at [${rel(docRepoPath)}]?
Do you need to pass --docrepo to specify the correct path or clone it there?
`);
}

throw error;
}
},
{
description: 'Build the docs and serve them from a docker container',
flags: {
string: ['docrepo'],
boolean: ['open'],
default: {
docrepo: DEFAULT_DOC_REPO_PATH,
},
help: `
--docrepo [path] Path to the doc repo, defaults to ${rel(DEFAULT_DOC_REPO_PATH)}
--open Automatically open the built docs in your default browser after building
`,
},
}
);
}
30 changes: 0 additions & 30 deletions src/docs/cli.js

This file was deleted.

28 changes: 0 additions & 28 deletions src/docs/docs_repo.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import { resolve } from 'path';
const mockConfig = {
resolve: {
alias: {
'../format_service': resolve(__dirname, '../public/__mocks__/format_service.ts'),
'../../../expression_metric/public/services': resolve(
__dirname,
'../public/__mocks__/services.ts'
),
},
},
};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,39 @@ import { Datatable } from '../../../../expressions/common/expression_types/specs

describe('interpreter/functions#metric', () => {
const fn = functionWrapper(metricVisFunction());
const context = {
const context: Datatable = {
type: 'datatable',
rows: [{ 'col-0-1': 0 }],
columns: [{ id: 'col-0-1', name: 'Count' }],
} as unknown as Datatable;
const args = {
columns: [{ id: 'col-0-1', name: 'Count', meta: { type: 'number' } }],
};
const args: MetricArguments = {
percentageMode: false,
useRanges: false,
colorSchema: 'Green to Red',
metricColorMode: 'None',
colorsRange: [
{
from: 0,
to: 10000,
colorMode: 'None',
palette: {
type: 'palette',
name: '',
params: {
colors: ['rgb(0, 0, 0, 0)', 'rgb(112, 38, 231)'],
stops: [0, 10000],
gradient: false,
rangeMin: 0,
rangeMax: 150,
range: 'number',
},
],
labels: {
show: true,
},
invertColors: false,
style: {
bgFill: '#000',
bgColor: false,
labelColor: false,
subText: '',
fontSize: 60,
},
font: { spec: { fontSize: 60 } },
metrics: [
showLabels: true,
font: { spec: { fontSize: '60px' }, type: 'style', css: '' },
metric: [
{
type: 'vis_dimension',
accessor: 0,
format: {
id: 'number',
params: {},
},
params: {},
aggType: 'count',
},
],
} as unknown as MetricArguments;
};

it('returns an object with the correct structure', () => {
const actual = fn(context, args, undefined);
Expand Down
Loading

0 comments on commit cb3a07f

Please sign in to comment.