Skip to content

Commit

Permalink
debug failing test on ci only
Browse files Browse the repository at this point in the history
  • Loading branch information
stacey-gammon committed Feb 24, 2021
1 parent 6d1ea2d commit 65270ad
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ it('test extractImportReference', () => {
expect(results[0]).toBe('(param: string) => ');
expect(results[1]).toEqual({
text: 'Bar',
docId: getPluginApiDocId('plugin_a'),
docId: getPluginApiDocId('plugin_a', log),
section: 'def-public.Bar',
pluginId: 'pluginA',
scope: ApiScope.CLIENT,
Expand All @@ -52,7 +52,7 @@ it('test extractImportReference with public folder nested under server folder',
expect(results.length).toBe(1);
expect(results[0]).toEqual({
text: 'Bar',
docId: getPluginApiDocId('plugin_a'),
docId: getPluginApiDocId('plugin_a', log),
section: 'def-server.Bar',
pluginId: 'pluginA',
scope: ApiScope.SERVER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function extractImportReferences(
texts.push({
pluginId: plugin.manifest.id,
scope: getScopeFromPath(path, plugin, log),
docId: getPluginApiDocId(plugin.manifest.id, {
docId: getPluginApiDocId(plugin.manifest.id, log, {
serviceFolders: plugin.manifest.serviceFolders,
apiPath: path,
directory: plugin.directory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function writePluginDoc(folder: string, doc: PluginApi, log: ToolingLog):
let mdx =
dedent(`
---
id: ${getPluginApiDocId(doc.id)}
id: ${getPluginApiDocId(doc.id, log)}
slug: /kibana-dev-docs/${doc.id}PluginApi
title: ${doc.id}
image: https://source.unsplash.com/400x175/?github
Expand Down
12 changes: 8 additions & 4 deletions packages/kbn-docs-utils/src/api_docs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { KibanaPlatformPlugin } from '@kbn/dev-utils';
import { KibanaPlatformPlugin, ToolingLog } from '@kbn/dev-utils';
import {
AnchorLink,
ApiDeclaration,
Expand Down Expand Up @@ -60,9 +60,9 @@ export function groupPluginApi(declarations: ApiDeclaration[]): ScopeApi {
* @param path
*/
export function getServiceForPath(path: string, pluginDirectory: string): string | undefined {
const publicMatchGroups = path.match(`${pluginDirectory}/public\/([^\/]*)\/`);
const serverMatchGroups = path.match(`${pluginDirectory}/server\/([^\/]*)\/`);
const commonMatchGroups = path.match(`${pluginDirectory}/common\/([^\/]*)\/`);
const publicMatchGroups = path.match(`${pluginDirectory}\/public\/([^\/]*)\/`);
const serverMatchGroups = path.match(`${pluginDirectory}\/server\/([^\/]*)\/`);
const commonMatchGroups = path.match(`${pluginDirectory}\/common\/([^\/]*)\/`);

if (publicMatchGroups && publicMatchGroups.length > 1) {
return publicMatchGroups[1];
Expand All @@ -75,6 +75,7 @@ export function getServiceForPath(path: string, pluginDirectory: string): string

export function getPluginApiDocId(
id: string,
log: ToolingLog,
serviceInfo?: {
serviceFolders: readonly string[];
apiPath: string;
Expand All @@ -85,6 +86,9 @@ export function getPluginApiDocId(
const cleanName = id.replace('.', '_');
if (serviceInfo) {
const serviceName = getServiceForPath(serviceInfo.apiPath, serviceInfo.directory);
log.debug(
`Service for path ${serviceInfo.apiPath} and ${serviceInfo.directory} is ${serviceName}`
);
const serviceFolder = serviceInfo.serviceFolders?.find((f) => f === serviceName);

if (serviceFolder) {
Expand Down

0 comments on commit 65270ad

Please sign in to comment.