From 77b6e4f8316c847d4e004c8379458d300f17bd8b Mon Sep 17 00:00:00 2001 From: metonym Date: Sat, 30 Apr 2022 08:47:21 -0700 Subject: [PATCH] docs(action): generate action imports (#1274) --- docs/svelte.config.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/svelte.config.js b/docs/svelte.config.js index 28d2ea0c..034e0ec0 100644 --- a/docs/svelte.config.js +++ b/docs/svelte.config.js @@ -20,6 +20,7 @@ const component_api_by_name = component_api.components.reduce((a, c) => { function createImports(source) { const inlineComponents = new Set(); const icons = new Set(); + const actions = new Set(); // heuristic to guess if the inline component or expression name is a Carbon icon const isIcon = (text) => @@ -40,15 +41,20 @@ function createImports(source) { ) { icons.add(node.expression.name); } + } else if (node.type === "Action") { + actions.add(node.name); } }, }); - const ccs_imports = Array.from(inlineComponents.keys()); + const action_imports = Array.from(actions.keys()); + const ccs_imports = [ + ...Array.from(inlineComponents.keys()), + ...action_imports, + ]; const icon_imports = Array.from(icons.keys()); if (ccs_imports.length === 0) return ""; - // TODO: determine if action is used, and generate import accordingly return `