@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.22 → 2.2.0-next.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements-manifest.config.mjs +2 -1
- package/custom-elements.json +312 -17
- package/llms/components/obc-accordion-card.md +141 -0
- package/llms/components/obc-accordion-item.md +90 -0
- package/llms/components/obc-advice-button.md +87 -0
- package/llms/components/obc-advice-floating-item.md +113 -0
- package/llms/components/obc-advice-menu-item.md +87 -0
- package/llms/components/obc-advice-message-item.md +138 -0
- package/llms/components/obc-alert-button-item.md +117 -0
- package/llms/components/obc-alert-button.md +134 -0
- package/llms/components/obc-alert-counter-item.md +74 -0
- package/llms/components/obc-alert-detail-page.md +45 -0
- package/llms/components/obc-alert-floating-item.md +53 -0
- package/llms/components/obc-alert-frame.md +142 -0
- package/llms/components/obc-alert-icon.md +79 -0
- package/llms/components/obc-alert-list-details-experimental.md +89 -0
- package/llms/components/obc-alert-list-details.md +38 -0
- package/llms/components/obc-alert-list-page-small.md +39 -0
- package/llms/components/obc-alert-list.md +37 -0
- package/llms/components/obc-alert-menu-item.md +128 -0
- package/llms/components/obc-alert-menu.md +115 -0
- package/llms/components/obc-alert-subsystem-button.md +88 -0
- package/llms/components/obc-alert-subsystem-counter.md +110 -0
- package/llms/components/obc-analog-threeway-valve.md +106 -0
- package/llms/components/obc-analog-valve.md +74 -0
- package/llms/components/obc-app-button.md +83 -0
- package/llms/components/obc-app-menu.md +69 -0
- package/llms/components/obc-area-graph.md +333 -0
- package/llms/components/obc-attachment-list-item.md +49 -0
- package/llms/components/obc-audio-output.md +59 -0
- package/llms/components/obc-audio-recording-item.md +91 -0
- package/llms/components/obc-automation-badge.md +66 -0
- package/llms/components/obc-automation-button-readout-stack.md +71 -0
- package/llms/components/obc-automation-button.md +86 -0
- package/llms/components/obc-automation-input-modal.md +48 -0
- package/llms/components/obc-automation-readout.md +32 -0
- package/llms/components/obc-automation-tank.md +156 -0
- package/llms/components/obc-azimuth-thruster-labeled.md +56 -0
- package/llms/components/obc-azimuth-thruster.md +80 -0
- package/llms/components/obc-badge-command.md +26 -0
- package/llms/components/obc-badge.md +151 -0
- package/llms/components/obc-bar-horizontal.md +123 -0
- package/llms/components/obc-bar-vertical.md +125 -0
- package/llms/components/obc-battery-icon.md +38 -0
- package/llms/components/obc-bearing-indicator.md +27 -0
- package/llms/components/obc-bipolar-transistor.md +64 -0
- package/llms/components/obc-breadcrumb.md +58 -0
- package/llms/components/obc-brilliance-menu.md +115 -0
- package/llms/components/obc-bus.md +64 -0
- package/llms/components/obc-button.md +110 -0
- package/llms/components/obc-calendar.md +91 -0
- package/llms/components/obc-capacitor.md +64 -0
- package/llms/components/obc-card.md +103 -0
- package/llms/components/obc-chart-object-vessel-button.md +103 -0
- package/llms/components/obc-chat-message.md +35 -0
- package/llms/components/obc-check-button.md +104 -0
- package/llms/components/obc-checkbox-item.md +95 -0
- package/llms/components/obc-checkbox-list.md +73 -0
- package/llms/components/obc-checkbox.md +97 -0
- package/llms/components/obc-circular-progress.md +36 -0
- package/llms/components/obc-clock.md +86 -0
- package/llms/components/obc-command-button.md +56 -0
- package/llms/components/obc-command-menu.md +135 -0
- package/llms/components/obc-communication-table.md +31 -0
- package/llms/components/obc-compass-flat.md +79 -0
- package/llms/components/obc-compass-indicator.md +61 -0
- package/llms/components/obc-compass-sector.md +110 -0
- package/llms/components/obc-compass.md +157 -0
- package/llms/components/obc-context-menu-input.md +191 -0
- package/llms/components/obc-converter.md +64 -0
- package/llms/components/obc-corner-line.md +29 -0
- package/llms/components/obc-current.md +79 -0
- package/llms/components/obc-damper.md +62 -0
- package/llms/components/obc-date-item.md +66 -0
- package/llms/components/obc-depth-actual.md +69 -0
- package/llms/components/obc-depth-indicator.md +31 -0
- package/llms/components/obc-depth-top-band.md +43 -0
- package/llms/components/obc-depth.md +94 -0
- package/llms/components/obc-diagnostic-button.md +71 -0
- package/llms/components/obc-diagnostic-menu.md +88 -0
- package/llms/components/obc-digital-threeway-valve.md +112 -0
- package/llms/components/obc-digital-valve.md +78 -0
- package/llms/components/obc-diodes.md +64 -0
- package/llms/components/obc-direction-line.md +28 -0
- package/llms/components/obc-divider.md +44 -0
- package/llms/components/obc-donut-chart.md +116 -0
- package/llms/components/obc-draft-trim.md +67 -0
- package/llms/components/obc-dropdown-button.md +99 -0
- package/llms/components/obc-electricity-battery.md +83 -0
- package/llms/components/obc-elevated-card-radio-group.md +103 -0
- package/llms/components/obc-elevated-card-radio.md +104 -0
- package/llms/components/obc-elevated-card.md +146 -0
- package/llms/components/obc-end-point-line.md +29 -0
- package/llms/components/obc-event-item.md +47 -0
- package/llms/components/obc-event-list.md +37 -0
- package/llms/components/obc-fan.md +68 -0
- package/llms/components/obc-filter-chip.md +91 -0
- package/llms/components/obc-filter.md +64 -0
- package/llms/components/obc-floating-item.md +125 -0
- package/llms/components/obc-form-container.md +45 -0
- package/llms/components/obc-form-footer-container.md +34 -0
- package/llms/components/obc-form-group.md +80 -0
- package/llms/components/obc-form-item.md +95 -0
- package/llms/components/obc-gauge-bar-indicator.md +46 -0
- package/llms/components/obc-gauge-generator.md +102 -0
- package/llms/components/obc-gauge-horizontal.md +169 -0
- package/llms/components/obc-gauge-motors-and-pumps.md +110 -0
- package/llms/components/obc-gauge-proportional.md +134 -0
- package/llms/components/obc-gauge-radial-indicator.md +76 -0
- package/llms/components/obc-gauge-radial.md +163 -0
- package/llms/components/obc-gauge-trend-indicator.md +53 -0
- package/llms/components/obc-gauge-trend.md +271 -0
- package/llms/components/obc-gauge-valve.md +114 -0
- package/llms/components/obc-gauge-vertical.md +169 -0
- package/llms/components/obc-gnss-skyplot.md +80 -0
- package/llms/components/obc-graph-mini.md +28 -0
- package/llms/components/obc-ground.md +64 -0
- package/llms/components/obc-heading-indicator.md +42 -0
- package/llms/components/obc-heading.md +106 -0
- package/llms/components/obc-heat-exchanger.md +80 -0
- package/llms/components/obc-heat-pump.md +79 -0
- package/llms/components/obc-heave-indicator.md +38 -0
- package/llms/components/obc-heave.md +60 -0
- package/llms/components/obc-horizontal-line.md +29 -0
- package/llms/components/obc-hydraulic-check-valve.md +36 -0
- package/llms/components/obc-hydraulic-separator.md +80 -0
- package/llms/components/obc-hydraulic-valve-4-3.md +71 -0
- package/llms/components/obc-hydraulic-valve-x-2.md +68 -0
- package/llms/components/obc-icon-button.md +117 -0
- package/llms/components/obc-icon-check-button.md +85 -0
- package/llms/components/obc-indicator-battery.md +69 -0
- package/llms/components/obc-indicator-engine.md +39 -0
- package/llms/components/obc-indicator-generator.md +59 -0
- package/llms/components/obc-indicator-graph.md +33 -0
- package/llms/components/obc-indicator-tank-atmospheric.md +69 -0
- package/llms/components/obc-input-chip.md +96 -0
- package/llms/components/obc-instrument-field.md +172 -0
- package/llms/components/obc-instrument-radial.md +77 -0
- package/llms/components/obc-integration-app-bar.md +41 -0
- package/llms/components/obc-integration-bar-dropdown.md +71 -0
- package/llms/components/obc-integration-bar.md +72 -0
- package/llms/components/obc-integration-button.md +62 -0
- package/llms/components/obc-integration-dropdown-button.md +75 -0
- package/llms/components/obc-integration-fleet-button.md +41 -0
- package/llms/components/obc-integration-tabs.md +28 -0
- package/llms/components/obc-integration-vessel-menu.md +58 -0
- package/llms/components/obc-integration-vessel-selector.md +32 -0
- package/llms/components/obc-keyboard-full.md +175 -0
- package/llms/components/obc-keyboard-numeric.md +77 -0
- package/llms/components/obc-line-cross.md +28 -0
- package/llms/components/obc-line-graph.md +164 -0
- package/llms/components/obc-line-overlap.md +28 -0
- package/llms/components/obc-logic.md +64 -0
- package/llms/components/obc-main-engine-indicator.md +55 -0
- package/llms/components/obc-main-engine.md +54 -0
- package/llms/components/obc-menu-button.md +158 -0
- package/llms/components/obc-message-menu-item.md +165 -0
- package/llms/components/obc-modal-window.md +139 -0
- package/llms/components/obc-mosfet.md +64 -0
- package/llms/components/obc-motor.md +73 -0
- package/llms/components/obc-navigation-item-group.md +82 -0
- package/llms/components/obc-navigation-item.md +138 -0
- package/llms/components/obc-navigation-menu.md +135 -0
- package/llms/components/obc-non-return-valve.md +79 -0
- package/llms/components/obc-notification-badge-button.md +87 -0
- package/llms/components/obc-notification-button.md +92 -0
- package/llms/components/obc-notification-floating-item.md +121 -0
- package/llms/components/obc-notification-menu-item.md +87 -0
- package/llms/components/obc-notification-message-item.md +127 -0
- package/llms/components/obc-number-input-field.md +97 -0
- package/llms/components/obc-pagination.md +95 -0
- package/llms/components/obc-pie-chart.md +120 -0
- package/llms/components/obc-pitch-indicator.md +39 -0
- package/llms/components/obc-pitch-roll-heave.md +86 -0
- package/llms/components/obc-pitch-roll-yaw.md +72 -0
- package/llms/components/obc-pitch-roll.md +63 -0
- package/llms/components/obc-pitch.md +81 -0
- package/llms/components/obc-pivot-item-group.md +79 -0
- package/llms/components/obc-pivot-item.md +75 -0
- package/llms/components/obc-poi-aton.md +68 -0
- package/llms/components/obc-poi-button-aton.md +54 -0
- package/llms/components/obc-poi-button-data.md +53 -0
- package/llms/components/obc-poi-button-vessel.md +55 -0
- package/llms/components/obc-poi-button.md +94 -0
- package/llms/components/obc-poi-card-header.md +90 -0
- package/llms/components/obc-poi-card.md +110 -0
- package/llms/components/obc-poi-controller.md +151 -0
- package/llms/components/obc-poi-data.md +72 -0
- package/llms/components/obc-poi-graphic-line.md +70 -0
- package/llms/components/obc-poi-group.md +85 -0
- package/llms/components/obc-poi-header.md +71 -0
- package/llms/components/obc-poi-layer-stack.md +85 -0
- package/llms/components/obc-poi-layer.md +110 -0
- package/llms/components/obc-poi-line.md +70 -0
- package/llms/components/obc-poi-object-aton.md +45 -0
- package/llms/components/obc-poi-object-data.md +48 -0
- package/llms/components/obc-poi-object-vessel.md +95 -0
- package/llms/components/obc-poi-object.md +82 -0
- package/llms/components/obc-poi-pointer.md +70 -0
- package/llms/components/obc-poi-selection-frame.md +66 -0
- package/llms/components/obc-poi-vessel.md +70 -0
- package/llms/components/obc-poi.md +140 -0
- package/llms/components/obc-polar-chart.md +126 -0
- package/llms/components/obc-position-deviation.md +84 -0
- package/llms/components/obc-pressure-reduction-valve.md +88 -0
- package/llms/components/obc-pressure-sustain-valve.md +85 -0
- package/llms/components/obc-progress-bar.md +102 -0
- package/llms/components/obc-progress-button.md +111 -0
- package/llms/components/obc-progress-indicator-dots.md +57 -0
- package/llms/components/obc-propulsion-azimuth-indicator.md +48 -0
- package/llms/components/obc-pump.md +76 -0
- package/llms/components/obc-radial-bar-chart.md +103 -0
- package/llms/components/obc-radio.md +82 -0
- package/llms/components/obc-rate-of-turn.md +95 -0
- package/llms/components/obc-readout-block.md +137 -0
- package/llms/components/obc-readout-list-item.md +142 -0
- package/llms/components/obc-readout-list.md +85 -0
- package/llms/components/obc-readout.md +169 -0
- package/llms/components/obc-resistor.md +64 -0
- package/llms/components/obc-rich-button.md +92 -0
- package/llms/components/obc-roll-indicator.md +38 -0
- package/llms/components/obc-roll.md +56 -0
- package/llms/components/obc-rot-indicator.md +32 -0
- package/llms/components/obc-rot-linear.md +68 -0
- package/llms/components/obc-rot-sector.md +125 -0
- package/llms/components/obc-router.md +64 -0
- package/llms/components/obc-rudder-indicator.md +54 -0
- package/llms/components/obc-rudder.md +112 -0
- package/llms/components/obc-ruler-pointer.md +57 -0
- package/llms/components/obc-scrollbar.md +57 -0
- package/llms/components/obc-sequence-card.md +119 -0
- package/llms/components/obc-sequence-connector.md +70 -0
- package/llms/components/obc-sequence-item.md +64 -0
- package/llms/components/obc-sequence-loading-spinner.md +70 -0
- package/llms/components/obc-sequence-modal.md +89 -0
- package/llms/components/obc-sequence-step.md +48 -0
- package/llms/components/obc-sequence-toolbar.md +108 -0
- package/llms/components/obc-slide-button.md +111 -0
- package/llms/components/obc-slider-double.md +137 -0
- package/llms/components/obc-slider.md +143 -0
- package/llms/components/obc-source.md +64 -0
- package/llms/components/obc-speed-arrows.md +39 -0
- package/llms/components/obc-speed-directions.md +66 -0
- package/llms/components/obc-speed-gauge.md +124 -0
- package/llms/components/obc-speed-indicator.md +37 -0
- package/llms/components/obc-split-button.md +144 -0
- package/llms/components/obc-start-stop-switch.md +126 -0
- package/llms/components/obc-status-indicator.md +30 -0
- package/llms/components/obc-stepper-box.md +90 -0
- package/llms/components/obc-surge-sway-yaw.md +95 -0
- package/llms/components/obc-switch.md +69 -0
- package/llms/components/obc-system-button.md +112 -0
- package/llms/components/obc-system-menu.md +67 -0
- package/llms/components/obc-tab-item.md +161 -0
- package/llms/components/obc-tab-row.md +151 -0
- package/llms/components/obc-tabbed-card.md +148 -0
- package/llms/components/obc-table-header-item.md +42 -0
- package/llms/components/obc-table.md +124 -0
- package/llms/components/obc-tag.md +41 -0
- package/llms/components/obc-text-input-field.md +94 -0
- package/llms/components/obc-textarea-field.md +186 -0
- package/llms/components/obc-textbox.md +80 -0
- package/llms/components/obc-three-way-line.md +29 -0
- package/llms/components/obc-thruster.md +64 -0
- package/llms/components/obc-title-container.md +81 -0
- package/llms/components/obc-toggle-button-group.md +184 -0
- package/llms/components/obc-toggle-button-option.md +126 -0
- package/llms/components/obc-toggle-button-three-state.md +38 -0
- package/llms/components/obc-toggle-button-vertical-group.md +142 -0
- package/llms/components/obc-toggle-button-vertical-option.md +110 -0
- package/llms/components/obc-toggle-switch.md +126 -0
- package/llms/components/obc-toggletip.md +135 -0
- package/llms/components/obc-tooltip.md +106 -0
- package/llms/components/obc-top-bar.md +194 -0
- package/llms/components/obc-top-view-propulsion.md +84 -0
- package/llms/components/obc-topbar-message-item.md +150 -0
- package/llms/components/obc-transformer.md +64 -0
- package/llms/components/obc-transmitter-button.md +101 -0
- package/llms/components/obc-transmitter-stack.md +79 -0
- package/llms/components/obc-transmitter.md +114 -0
- package/llms/components/obc-tree-navigation-group.md +69 -0
- package/llms/components/obc-tree-navigation-item.md +110 -0
- package/llms/components/obc-tree-navigation.md +73 -0
- package/llms/components/obc-tunnel-thruster.md +59 -0
- package/llms/components/obc-user-button.md +107 -0
- package/llms/components/obc-user-menu.md +154 -0
- package/llms/components/obc-valve-analog-three-way-icon.md +69 -0
- package/llms/components/obc-valve-analog-two-way-icon.md +39 -0
- package/llms/components/obc-velocity-projection-plot.md +34 -0
- package/llms/components/obc-vendor-button.md +63 -0
- package/llms/components/obc-vertical-line.md +33 -0
- package/llms/components/obc-watch-flat.md +54 -0
- package/llms/components/obc-watch.md +206 -0
- package/llms/components/obc-wind-indicator.md +52 -0
- package/llms/components/obc-wind-propulsion.md +92 -0
- package/llms/components/obc-wind.md +46 -0
- package/llms/docs/ar-poi-projection.md +36 -0
- package/llms/docs/automation-sequence-step-diagram-playground.md +13 -0
- package/llms/docs/building-blocks-advice.md +31 -0
- package/llms/docs/building-blocks-external-scale.md +138 -0
- package/llms/docs/building-blocks-setpoint.md +119 -0
- package/llms/docs/introduction-advice-system.md +161 -0
- package/llms/docs/introduction-getting-started.md +94 -0
- package/llms/docs/introduction-introduction.md +27 -0
- package/llms/docs/introduction-join-the-project.md +11 -0
- package/llms/docs/introduction-migration-guide-2-0-to-2-1.md +126 -0
- package/llms/docs/introduction-migration-guide-2-1-to-2-2.md +106 -0
- package/llms/docs/introduction-migration-guide.md +1063 -0
- package/llms/docs/palettes-categorical-colour.md +9 -0
- package/llms/llms-full.txt +28380 -0
- package/llms/llms.txt +368 -0
- package/package.json +12 -2
- package/script/cem-plugins/lifecycle.d.mts +6 -0
- package/script/cem-plugins/lifecycle.mjs +48 -0
- package/script/cem-plugins.test.ts +52 -1
- package/script/generate-llms-txt.ts +34 -0
- package/script/llms/channel.test.ts +69 -0
- package/script/llms/channel.ts +63 -0
- package/script/llms/generate.test.ts +143 -0
- package/script/llms/generate.ts +229 -0
- package/script/llms/manifest.test.ts +160 -0
- package/script/llms/manifest.ts +109 -0
- package/script/llms/markdown.test.ts +22 -0
- package/script/llms/markdown.ts +37 -0
- package/script/llms/mdx.test.ts +172 -0
- package/script/llms/mdx.ts +171 -0
- package/script/llms/render-component.test.ts +290 -0
- package/script/llms/render-component.ts +208 -0
- package/script/llms/render-guides.test.ts +105 -0
- package/script/llms/render-guides.ts +51 -0
- package/script/llms/render-llms-txt.test.ts +222 -0
- package/script/llms/render-llms-txt.ts +185 -0
- package/script/llms/sources.test.ts +118 -0
- package/script/llms/sources.ts +89 -0
- package/script/llms/stories.test.ts +193 -0
- package/script/llms/stories.ts +256 -0
- package/script/llms/types.ts +95 -0
- package/script/prepare-full-bundle.ts +1 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* llms.txt generator, the command
|
|
3
|
+
*
|
|
4
|
+
* Writes the agent-facing docs into `llms/` (gitignored), which
|
|
5
|
+
* `postbuild-storybook` copies into `storybook-static` next to the manifest,
|
|
6
|
+
* so the Storybook root serves them. Runs at the end of `npm run analyze`;
|
|
7
|
+
* `--channel next|latest` picks the hosts the links use (`LLMS_CHANNEL`,
|
|
8
|
+
* then `GITHUB_REF_NAME`, when the flag is absent).
|
|
9
|
+
*/
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import {resolveChannel} from './llms/channel.js';
|
|
12
|
+
import {generate} from './llms/generate.js';
|
|
13
|
+
|
|
14
|
+
const PACKAGE_ROOT = path.resolve(import.meta.dirname, '..');
|
|
15
|
+
|
|
16
|
+
const flag = process.argv.indexOf('--channel');
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
console.log(
|
|
20
|
+
generate({
|
|
21
|
+
packageRoot: PACKAGE_ROOT,
|
|
22
|
+
repoRoot: path.resolve(PACKAGE_ROOT, '../..'),
|
|
23
|
+
out: path.join(PACKAGE_ROOT, 'llms'),
|
|
24
|
+
channel: resolveChannel(
|
|
25
|
+
flag === -1 ? undefined : process.argv[flag + 1],
|
|
26
|
+
process.env
|
|
27
|
+
),
|
|
28
|
+
warn: (msg) => console.warn(msg),
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.error((e as Error).message);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {describe, expect, it} from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
CORE_PACKAGE,
|
|
4
|
+
rawUrl,
|
|
5
|
+
resolveChannel,
|
|
6
|
+
siteUrl,
|
|
7
|
+
unpkgUrl,
|
|
8
|
+
} from './channel.js';
|
|
9
|
+
|
|
10
|
+
describe('resolveChannel', () => {
|
|
11
|
+
it('flag wins over env', () => {
|
|
12
|
+
expect(
|
|
13
|
+
resolveChannel('latest', {
|
|
14
|
+
LLMS_CHANNEL: 'next',
|
|
15
|
+
GITHUB_REF_NAME: 'develop',
|
|
16
|
+
}).name
|
|
17
|
+
).toBe('latest');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('LLMS_CHANNEL wins over GITHUB_REF_NAME', () => {
|
|
21
|
+
expect(
|
|
22
|
+
resolveChannel(undefined, {
|
|
23
|
+
LLMS_CHANNEL: 'latest',
|
|
24
|
+
GITHUB_REF_NAME: 'develop',
|
|
25
|
+
}).name
|
|
26
|
+
).toBe('latest');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('stable ref means latest', () => {
|
|
30
|
+
expect(resolveChannel(undefined, {GITHUB_REF_NAME: 'stable'})).toEqual({
|
|
31
|
+
name: 'latest',
|
|
32
|
+
site: 'https://openbridge-storybook.web.app',
|
|
33
|
+
npmTag: 'latest',
|
|
34
|
+
gitRef: 'stable',
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('defaults to next', () => {
|
|
39
|
+
expect(resolveChannel(undefined, {})).toEqual({
|
|
40
|
+
name: 'next',
|
|
41
|
+
site: 'https://openbridge-next-storybook.web.app',
|
|
42
|
+
npmTag: 'next',
|
|
43
|
+
gitRef: 'develop',
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('rejects an unknown channel', () => {
|
|
48
|
+
expect(() => resolveChannel('beta', {})).toThrow(/next|latest/);
|
|
49
|
+
expect(() => resolveChannel(undefined, {LLMS_CHANNEL: 'beta'})).toThrow(
|
|
50
|
+
/next|latest/
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('urls', () => {
|
|
56
|
+
const ch = resolveChannel('next', {});
|
|
57
|
+
|
|
58
|
+
it('builds the three url shapes', () => {
|
|
59
|
+
expect(rawUrl(ch, 'docs/graph.md')).toBe(
|
|
60
|
+
'https://raw.githubusercontent.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/develop/docs/graph.md'
|
|
61
|
+
);
|
|
62
|
+
expect(unpkgUrl(ch, CORE_PACKAGE, 'README.md')).toBe(
|
|
63
|
+
'https://unpkg.com/@oicl/openbridge-webcomponents@next/README.md'
|
|
64
|
+
);
|
|
65
|
+
expect(siteUrl(ch, '/llms.txt')).toBe(
|
|
66
|
+
'https://openbridge-next-storybook.web.app/llms.txt'
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Release channel of the generated docs
|
|
3
|
+
*
|
|
4
|
+
* `next` is the develop line, `latest` the stable one; every absolute URL in
|
|
5
|
+
* the output follows it, so a stable deploy links the stable Storybook, the
|
|
6
|
+
* `latest` npm tag and the `stable` git ref.
|
|
7
|
+
*/
|
|
8
|
+
export interface Channel {
|
|
9
|
+
name: 'next' | 'latest';
|
|
10
|
+
site: string;
|
|
11
|
+
npmTag: 'next' | 'latest';
|
|
12
|
+
gitRef: 'develop' | 'stable';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const REPO = 'Ocean-Industries-Concept-Lab/openbridge-webcomponents';
|
|
16
|
+
export const CORE_PACKAGE = '@oicl/openbridge-webcomponents';
|
|
17
|
+
export const WRAPPER_PACKAGES = [
|
|
18
|
+
'@oicl/openbridge-webcomponents-react',
|
|
19
|
+
'@oicl/openbridge-webcomponents-vue',
|
|
20
|
+
'@oicl/openbridge-webcomponents-ng',
|
|
21
|
+
'@oicl/openbridge-webcomponents-svelte',
|
|
22
|
+
] as const;
|
|
23
|
+
|
|
24
|
+
const CHANNELS: Record<Channel['name'], Channel> = {
|
|
25
|
+
next: {
|
|
26
|
+
name: 'next',
|
|
27
|
+
site: 'https://openbridge-next-storybook.web.app',
|
|
28
|
+
npmTag: 'next',
|
|
29
|
+
gitRef: 'develop',
|
|
30
|
+
},
|
|
31
|
+
latest: {
|
|
32
|
+
name: 'latest',
|
|
33
|
+
site: 'https://openbridge-storybook.web.app',
|
|
34
|
+
npmTag: 'latest',
|
|
35
|
+
gitRef: 'stable',
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export function resolveChannel(
|
|
40
|
+
flag: string | undefined,
|
|
41
|
+
env: NodeJS.ProcessEnv
|
|
42
|
+
): Channel {
|
|
43
|
+
const name =
|
|
44
|
+
flag ??
|
|
45
|
+
env.LLMS_CHANNEL ??
|
|
46
|
+
(env.GITHUB_REF_NAME === 'stable' ? 'latest' : 'next');
|
|
47
|
+
if (name !== 'next' && name !== 'latest') {
|
|
48
|
+
throw new Error(`llms.txt: channel must be next or latest, got ${name}`);
|
|
49
|
+
}
|
|
50
|
+
return CHANNELS[name];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function rawUrl(ch: Channel, repoPath: string): string {
|
|
54
|
+
return `https://raw.githubusercontent.com/${REPO}/${ch.gitRef}/${repoPath}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function unpkgUrl(ch: Channel, pkg: string, file: string): string {
|
|
58
|
+
return `https://unpkg.com/${pkg}@${ch.npmTag}/${file}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function siteUrl(ch: Channel, sitePath: string): string {
|
|
62
|
+
return `${ch.site}${sitePath}`;
|
|
63
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
|
5
|
+
import {resolveChannel} from './channel.js';
|
|
6
|
+
import {generate} from './generate.js';
|
|
7
|
+
|
|
8
|
+
let root: string;
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
root = fs.mkdtempSync(path.join(os.tmpdir(), 'llms-gen-'));
|
|
11
|
+
});
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
fs.rmSync(root, {recursive: true, force: true});
|
|
14
|
+
});
|
|
15
|
+
const write = (rel: string, text: string) => {
|
|
16
|
+
const file = path.join(root, rel);
|
|
17
|
+
fs.mkdirSync(path.dirname(file), {recursive: true});
|
|
18
|
+
fs.writeFileSync(file, text);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** A package root with a manifest, one guide and one stories file, and nothing optional: no README, no docs/agents. */
|
|
22
|
+
function minimalPackage() {
|
|
23
|
+
write(
|
|
24
|
+
'pkg/custom-elements.json',
|
|
25
|
+
JSON.stringify({
|
|
26
|
+
modules: [
|
|
27
|
+
{
|
|
28
|
+
path: 'src/components/a/a.ts',
|
|
29
|
+
declarations: [
|
|
30
|
+
{
|
|
31
|
+
kind: 'class',
|
|
32
|
+
name: 'ObcA',
|
|
33
|
+
tagName: 'obc-a',
|
|
34
|
+
description: '`<obc-a>` – An A.',
|
|
35
|
+
lifecycle: 'stable',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
write(
|
|
43
|
+
'pkg/package.json',
|
|
44
|
+
JSON.stringify({name: '@x/y', version: '1.0.0', description: 'Y.'})
|
|
45
|
+
);
|
|
46
|
+
write(
|
|
47
|
+
'pkg/docs/A.mdx',
|
|
48
|
+
`import {Meta} from '@storybook/addon-docs/blocks';\n\n<Meta title="Introduction/A" />\n\n# A page`
|
|
49
|
+
);
|
|
50
|
+
write(
|
|
51
|
+
'pkg/src/components/a/a.stories.ts',
|
|
52
|
+
"export default {title: 'UI/A', component: 'obc-a'};\nexport const Default = {};\nexport const Named = {name: 'Dense (compact)'};"
|
|
53
|
+
);
|
|
54
|
+
fs.mkdirSync(path.join(root, 'repo'));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
describe('generate', () => {
|
|
58
|
+
it('writes every output from a minimal package and warns about the missing optional inputs', () => {
|
|
59
|
+
minimalPackage();
|
|
60
|
+
const warn = vi.fn();
|
|
61
|
+
const out = path.join(root, 'pkg/llms');
|
|
62
|
+
const report = generate({
|
|
63
|
+
packageRoot: path.join(root, 'pkg'),
|
|
64
|
+
repoRoot: path.join(root, 'repo'),
|
|
65
|
+
out,
|
|
66
|
+
channel: resolveChannel('next', {}),
|
|
67
|
+
warn,
|
|
68
|
+
});
|
|
69
|
+
expect(fs.readdirSync(out).sort()).toEqual([
|
|
70
|
+
'components',
|
|
71
|
+
'docs',
|
|
72
|
+
'llms-full.txt',
|
|
73
|
+
'llms.txt',
|
|
74
|
+
]);
|
|
75
|
+
expect(fs.readFileSync(path.join(out, 'llms.txt'), 'utf8')).toContain(
|
|
76
|
+
'components/obc-a.md'
|
|
77
|
+
);
|
|
78
|
+
expect(fs.existsSync(path.join(out, 'components/obc-a.md'))).toBe(true);
|
|
79
|
+
expect(fs.existsSync(path.join(out, 'docs/introduction-a.md'))).toBe(true);
|
|
80
|
+
expect(
|
|
81
|
+
fs
|
|
82
|
+
.readFileSync(path.join(out, 'llms-full.txt'), 'utf8')
|
|
83
|
+
.startsWith('# A page')
|
|
84
|
+
).toBe(true);
|
|
85
|
+
expect(report).toContain('1 components');
|
|
86
|
+
expect(warn).toHaveBeenCalledWith(expect.stringContaining('README.md'));
|
|
87
|
+
expect(warn).toHaveBeenCalledWith(expect.stringContaining('docs/agents'));
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('links a guide from a component page when a raw partial names the tag', () => {
|
|
91
|
+
minimalPackage();
|
|
92
|
+
write(
|
|
93
|
+
'pkg/docs/B.mdx',
|
|
94
|
+
`import list from './b/list.md?raw';\n\n<Meta title="Introduction/B" />\n\n<Markdown>{list}</Markdown>`
|
|
95
|
+
);
|
|
96
|
+
write('pkg/docs/b/list.md', '| `obc-a` |\n|---|');
|
|
97
|
+
generate({
|
|
98
|
+
packageRoot: path.join(root, 'pkg'),
|
|
99
|
+
repoRoot: path.join(root, 'repo'),
|
|
100
|
+
out: path.join(root, 'pkg/llms'),
|
|
101
|
+
channel: resolveChannel('next', {}),
|
|
102
|
+
warn: () => {},
|
|
103
|
+
});
|
|
104
|
+
const page = fs.readFileSync(
|
|
105
|
+
path.join(root, 'pkg/llms/components/obc-a.md'),
|
|
106
|
+
'utf8'
|
|
107
|
+
);
|
|
108
|
+
expect(page).toContain(
|
|
109
|
+
'- [B](https://openbridge-next-storybook.web.app/docs/introduction-b.md)'
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('links a story by the id Storybook derives from its export name', () => {
|
|
114
|
+
minimalPackage();
|
|
115
|
+
generate({
|
|
116
|
+
packageRoot: path.join(root, 'pkg'),
|
|
117
|
+
repoRoot: path.join(root, 'repo'),
|
|
118
|
+
out: path.join(root, 'pkg/llms'),
|
|
119
|
+
channel: resolveChannel('next', {}),
|
|
120
|
+
warn: () => {},
|
|
121
|
+
});
|
|
122
|
+
const page = fs.readFileSync(
|
|
123
|
+
path.join(root, 'pkg/llms/components/obc-a.md'),
|
|
124
|
+
'utf8'
|
|
125
|
+
);
|
|
126
|
+
expect(page).toContain(
|
|
127
|
+
'- [Dense (compact)](https://openbridge-next-storybook.web.app/?path=/story/ui-a--named)'
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('fails on a missing manifest', () => {
|
|
132
|
+
fs.mkdirSync(path.join(root, 'pkg'));
|
|
133
|
+
expect(() =>
|
|
134
|
+
generate({
|
|
135
|
+
packageRoot: path.join(root, 'pkg'),
|
|
136
|
+
repoRoot: root,
|
|
137
|
+
out: path.join(root, 'out'),
|
|
138
|
+
channel: resolveChannel('next', {}),
|
|
139
|
+
warn: () => {},
|
|
140
|
+
})
|
|
141
|
+
).toThrow(/npm run analyze/);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {sanitize} from 'storybook/internal/csf';
|
|
4
|
+
import {rawUrl, siteUrl, type Channel} from './channel.js';
|
|
5
|
+
import {componentEntries, readManifest} from './manifest.js';
|
|
6
|
+
import {mdxToMarkdown} from './mdx.js';
|
|
7
|
+
import {renderComponentPage} from './render-component.js';
|
|
8
|
+
import {
|
|
9
|
+
isModuleGuide,
|
|
10
|
+
renderLlmsFull,
|
|
11
|
+
renderStoriesGuide,
|
|
12
|
+
} from './render-guides.js';
|
|
13
|
+
import {gapReport, renderLlmsTxt} from './render-llms-txt.js';
|
|
14
|
+
import {agentDocs, mdxGuides, packageMeta, type Guide} from './sources.js';
|
|
15
|
+
import {
|
|
16
|
+
storiesIndex,
|
|
17
|
+
storyPageUrl,
|
|
18
|
+
type DocsRef,
|
|
19
|
+
type StoriesInfo,
|
|
20
|
+
} from './stories.js';
|
|
21
|
+
import type {ComponentEntry, Manifest} from './types.js';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The llms.txt generator
|
|
25
|
+
*
|
|
26
|
+
* Writes `llms.txt`, a markdown page per component under `components/`, one
|
|
27
|
+
* per guide under `docs/`, and `llms-full.txt` into `out`, from the manifest,
|
|
28
|
+
* `docs/*.mdx`, the stories, `docs/agents` frontmatter and `package.json`.
|
|
29
|
+
* The README and `docs/agents` are optional inputs: the full-bundle package
|
|
30
|
+
* runs the same `prepack` chain from a copy that has neither.
|
|
31
|
+
*/
|
|
32
|
+
export interface GenerateOptions {
|
|
33
|
+
packageRoot: string;
|
|
34
|
+
repoRoot: string;
|
|
35
|
+
out: string;
|
|
36
|
+
channel: Channel;
|
|
37
|
+
warn: (msg: string) => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const PACKAGE_DIR = 'packages/openbridge-webcomponents';
|
|
41
|
+
const CHANGELOG_TITLE = 'Introduction/Changelog';
|
|
42
|
+
|
|
43
|
+
/** The Introduction page reads these from `.storybook/channels.ts`; the generator knows the channel. */
|
|
44
|
+
function mdxVars(channel: Channel): Record<string, string | boolean> {
|
|
45
|
+
return {
|
|
46
|
+
isStable: channel.name === 'latest',
|
|
47
|
+
isDevelop: channel.name !== 'latest',
|
|
48
|
+
STORYBOOK_STABLE_URL: 'https://openbridge-storybook.web.app',
|
|
49
|
+
STORYBOOK_DEVELOP_URL: 'https://openbridge-next-storybook.web.app',
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** `<Canvas of={Ns.Export}>`: the stories file the MDX imported, by its path without extension. */
|
|
54
|
+
function storyLinkFor(
|
|
55
|
+
stories: StoriesInfo[],
|
|
56
|
+
channel: Channel,
|
|
57
|
+
mdxFile: string
|
|
58
|
+
) {
|
|
59
|
+
return (importPath: string, exportName: string): string | undefined => {
|
|
60
|
+
const target = path
|
|
61
|
+
.resolve(path.dirname(mdxFile), importPath)
|
|
62
|
+
.replace(/\.ts$/, '');
|
|
63
|
+
const info = stories.find((s) => s.file.replace(/\.ts$/, '') === target);
|
|
64
|
+
const story = info?.stories.find((s) => s.exportName === exportName);
|
|
65
|
+
if (!info?.title || !story) return undefined;
|
|
66
|
+
return `[Story: ${info.title} / ${story.name}](${storyPageUrl(channel, info.title, story.exportName)})`;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** `moduleDocs()` / `classDocs()` in a stories file, resolved against the manifest like `.storybook/manifest-docs.ts` does. */
|
|
71
|
+
function manifestDocs(manifest: Manifest) {
|
|
72
|
+
return (ref: DocsRef): string | undefined =>
|
|
73
|
+
ref.kind === 'moduleDocs'
|
|
74
|
+
? manifest.modules.find((m) => m.path.endsWith(ref.arg))?.description
|
|
75
|
+
: manifest.modules
|
|
76
|
+
.flatMap((m) => m.declarations ?? [])
|
|
77
|
+
.find((d) => d.name === ref.arg)?.description;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** A stories file that documents a module is a guide too; its source feeds the See-also matching. */
|
|
81
|
+
function moduleGuide(info: StoriesInfo): Guide {
|
|
82
|
+
return {
|
|
83
|
+
title: info.title!,
|
|
84
|
+
file: info.file,
|
|
85
|
+
slug: sanitize(info.title!),
|
|
86
|
+
optional: false,
|
|
87
|
+
source: fs.readFileSync(info.file, 'utf8'),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Guides that name the component's tag or import its stories module. */
|
|
92
|
+
function guidesMentioning(
|
|
93
|
+
entry: ComponentEntry,
|
|
94
|
+
guides: Guide[],
|
|
95
|
+
pages: Map<Guide, string>
|
|
96
|
+
): Guide[] {
|
|
97
|
+
const tag = new RegExp(`${entry.tag}(?![\\w-])`);
|
|
98
|
+
const storiesModule = entry.modulePath
|
|
99
|
+
.replace(/^src\//, '')
|
|
100
|
+
.replace(/\.ts$/, '.stories');
|
|
101
|
+
// The rendered page holds what the `?raw` partials name; the source holds the story imports.
|
|
102
|
+
return guides.filter(
|
|
103
|
+
(g) =>
|
|
104
|
+
tag.test(g.source) ||
|
|
105
|
+
tag.test(pages.get(g) ?? '') ||
|
|
106
|
+
g.source.includes(storiesModule)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function optionalFile(
|
|
111
|
+
file: string,
|
|
112
|
+
warn: (msg: string) => void
|
|
113
|
+
): string | undefined {
|
|
114
|
+
if (fs.existsSync(file)) return fs.readFileSync(file, 'utf8');
|
|
115
|
+
warn(`llms.txt: ${file} is missing; left out`);
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Writes the output directory and returns the gap report. */
|
|
120
|
+
export function generate(options: GenerateOptions): string {
|
|
121
|
+
const {packageRoot, repoRoot, out, channel, warn} = options;
|
|
122
|
+
const manifest = readManifest(path.join(packageRoot, 'custom-elements.json'));
|
|
123
|
+
const entries = componentEntries(manifest, warn);
|
|
124
|
+
const stories = storiesIndex(path.join(packageRoot, 'src'), warn);
|
|
125
|
+
const moduleGuides = stories
|
|
126
|
+
.filter(isModuleGuide)
|
|
127
|
+
.map(moduleGuide)
|
|
128
|
+
.sort((a, b) => a.title.localeCompare(b.title));
|
|
129
|
+
const guides = [
|
|
130
|
+
...mdxGuides(path.join(packageRoot, 'docs'), warn),
|
|
131
|
+
...moduleGuides,
|
|
132
|
+
];
|
|
133
|
+
const guideHref = (g: Guide) =>
|
|
134
|
+
g.title === CHANGELOG_TITLE
|
|
135
|
+
? rawUrl(channel, `${PACKAGE_DIR}/CHANGELOG.md`)
|
|
136
|
+
: siteUrl(channel, `/docs/${g.slug}.md`);
|
|
137
|
+
const componentHref = (e: ComponentEntry) =>
|
|
138
|
+
siteUrl(channel, `/components/${e.tag}.md`);
|
|
139
|
+
|
|
140
|
+
const resolveDocs = manifestDocs(manifest);
|
|
141
|
+
// A Storybook docs route inside a guide points at a generated page when one exists.
|
|
142
|
+
const docsRoute = (id: string): string | undefined => {
|
|
143
|
+
const guide = guides.find((g) => g.slug === id);
|
|
144
|
+
if (guide) return guideHref(guide);
|
|
145
|
+
const tag = stories.find(
|
|
146
|
+
(s) => s.title && sanitize(s.title) === id
|
|
147
|
+
)?.componentTag;
|
|
148
|
+
const entry = tag && entries.find((e) => e.tag === tag);
|
|
149
|
+
return entry ? componentHref(entry) : undefined;
|
|
150
|
+
};
|
|
151
|
+
const guidePages = new Map<Guide, string>();
|
|
152
|
+
for (const guide of guides) {
|
|
153
|
+
if (guide.title === CHANGELOG_TITLE) continue;
|
|
154
|
+
const info = stories.find((s) => s.file === guide.file);
|
|
155
|
+
const page = info
|
|
156
|
+
? renderStoriesGuide(info, channel, resolveDocs)
|
|
157
|
+
: `${mdxToMarkdown(guide.source, {
|
|
158
|
+
readRaw: (p) =>
|
|
159
|
+
fs.readFileSync(
|
|
160
|
+
path.resolve(path.dirname(guide.file), p.replace(/\?raw$/, '')),
|
|
161
|
+
'utf8'
|
|
162
|
+
),
|
|
163
|
+
storyLink: storyLinkFor(stories, channel, guide.file),
|
|
164
|
+
docsRoute,
|
|
165
|
+
site: channel.site,
|
|
166
|
+
vars: mdxVars(channel),
|
|
167
|
+
warn,
|
|
168
|
+
})}\n`;
|
|
169
|
+
guidePages.set(guide, page);
|
|
170
|
+
}
|
|
171
|
+
const componentPages = new Map<ComponentEntry, string>(
|
|
172
|
+
entries.map((entry) => [
|
|
173
|
+
entry,
|
|
174
|
+
renderComponentPage({
|
|
175
|
+
entry,
|
|
176
|
+
channel,
|
|
177
|
+
stories,
|
|
178
|
+
seeAlso: guidesMentioning(entry, guides, guidePages).map((g) => ({
|
|
179
|
+
title: g.title.replace(/^Introduction\//, ''),
|
|
180
|
+
href: guideHref(g),
|
|
181
|
+
})),
|
|
182
|
+
resolveDocs,
|
|
183
|
+
}),
|
|
184
|
+
])
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const llmsTxt = renderLlmsTxt({
|
|
188
|
+
pkg: packageMeta(path.join(packageRoot, 'package.json')),
|
|
189
|
+
channel,
|
|
190
|
+
entries,
|
|
191
|
+
guides,
|
|
192
|
+
agentDocs: agentDocs(path.join(repoRoot, 'docs/agents'), warn),
|
|
193
|
+
componentHref,
|
|
194
|
+
guideHref,
|
|
195
|
+
extraReference: [
|
|
196
|
+
{
|
|
197
|
+
name: 'llms-full.txt',
|
|
198
|
+
href: siteUrl(channel, '/llms-full.txt'),
|
|
199
|
+
note: 'the README, every guide and every component page in one file',
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
});
|
|
203
|
+
const readme = optionalFile(path.join(packageRoot, 'README.md'), warn);
|
|
204
|
+
const orderedGuides = [
|
|
205
|
+
...guides.filter((g) => !g.optional),
|
|
206
|
+
...guides.filter((g) => g.optional),
|
|
207
|
+
];
|
|
208
|
+
const llmsFull = renderLlmsFull([
|
|
209
|
+
...(readme ? [{title: 'README', markdown: readme}] : []),
|
|
210
|
+
...orderedGuides.flatMap((g) => {
|
|
211
|
+
const markdown = guidePages.get(g);
|
|
212
|
+
return markdown ? [{title: g.title, markdown}] : [];
|
|
213
|
+
}),
|
|
214
|
+
...entries.map((e) => ({title: e.tag, markdown: componentPages.get(e)!})),
|
|
215
|
+
]);
|
|
216
|
+
|
|
217
|
+
fs.rmSync(out, {recursive: true, force: true});
|
|
218
|
+
fs.mkdirSync(path.join(out, 'docs'), {recursive: true});
|
|
219
|
+
fs.mkdirSync(path.join(out, 'components'));
|
|
220
|
+
fs.writeFileSync(path.join(out, 'llms.txt'), llmsTxt);
|
|
221
|
+
fs.writeFileSync(path.join(out, 'llms-full.txt'), llmsFull);
|
|
222
|
+
for (const [guide, page] of guidePages) {
|
|
223
|
+
fs.writeFileSync(path.join(out, 'docs', `${guide.slug}.md`), page);
|
|
224
|
+
}
|
|
225
|
+
for (const [entry, page] of componentPages) {
|
|
226
|
+
fs.writeFileSync(path.join(out, 'components', `${entry.tag}.md`), page);
|
|
227
|
+
}
|
|
228
|
+
return gapReport(entries);
|
|
229
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import {describe, expect, it, vi} from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
componentEntries,
|
|
4
|
+
familyOf,
|
|
5
|
+
firstSentence,
|
|
6
|
+
summaryOf,
|
|
7
|
+
type Manifest,
|
|
8
|
+
} from './manifest.js';
|
|
9
|
+
|
|
10
|
+
describe('summaryOf', () => {
|
|
11
|
+
it('strips the tag prefix and the dash', () => {
|
|
12
|
+
expect(
|
|
13
|
+
summaryOf('`<obc-compass>` – Full compass with arrows.\n\n## Features')
|
|
14
|
+
).toBe('Full compass with arrows.');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('accepts the bare-backtick tag form and a hyphen', () => {
|
|
18
|
+
expect(summaryOf('`obc-x` - Does a thing.')).toBe('Does a thing.');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('joins a wrapped first sentence', () => {
|
|
22
|
+
expect(
|
|
23
|
+
summaryOf(
|
|
24
|
+
'`<obc-valve>` – three-way control valve for process\ndiagrams, with a continuous opening. Second sentence.'
|
|
25
|
+
)
|
|
26
|
+
).toBe(
|
|
27
|
+
'three-way control valve for process diagrams, with a continuous opening.'
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('keeps a first line without the tag', () => {
|
|
32
|
+
expect(summaryOf('Vertical SVG bar + external scale.')).toBe(
|
|
33
|
+
'Vertical SVG bar + external scale.'
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('does not cut at an abbreviation', () => {
|
|
38
|
+
expect(summaryOf('Shows e.g. the value. Then more.')).toBe(
|
|
39
|
+
'Shows e.g. the value.'
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it.each([
|
|
44
|
+
'### Overview\n\nText.',
|
|
45
|
+
'**TODO(designer)**: open',
|
|
46
|
+
'TODO(designer): open',
|
|
47
|
+
'@property x - y',
|
|
48
|
+
'```ts\ncode\n```',
|
|
49
|
+
])('treats %j as missing', (d) => {
|
|
50
|
+
expect(summaryOf(d)).toBeUndefined();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('is undefined for an empty description', () => {
|
|
54
|
+
expect(summaryOf(undefined)).toBeUndefined();
|
|
55
|
+
expect(summaryOf('')).toBeUndefined();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('escapes markdown-significant characters', () => {
|
|
59
|
+
expect(summaryOf('`<obc-x>` – A [b] | c.')).toBe('A \\[b\\] \\| c.');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('firstSentence', () => {
|
|
64
|
+
it('cuts before an uppercase or backtick start of the next sentence', () => {
|
|
65
|
+
expect(firstSentence('One. Two.')).toBe('One.');
|
|
66
|
+
expect(firstSentence('One. `two`.')).toBe('One.');
|
|
67
|
+
expect(firstSentence('v1.5 m. more')).toBe('v1.5 m. more');
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('familyOf', () => {
|
|
72
|
+
it.each([
|
|
73
|
+
['src/components/button/button.ts', 'components'],
|
|
74
|
+
['src/navigation-instruments/compass/compass.ts', 'navigation-instruments'],
|
|
75
|
+
['src/bars-graphs/pie-chart/pie-chart.ts', 'bars-graphs'],
|
|
76
|
+
['src/ar/poi/poi.ts', 'ar'],
|
|
77
|
+
['src/pages/alert-detail-page/alert-detail-page.ts', 'pages'],
|
|
78
|
+
])('%s → %s', (p, f) => {
|
|
79
|
+
expect(familyOf(p)).toBe(f);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('is undefined outside the families', () => {
|
|
83
|
+
expect(familyOf('src/decorator.ts')).toBeUndefined();
|
|
84
|
+
expect(familyOf('src/palettes/x.ts')).toBeUndefined();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('componentEntries', () => {
|
|
89
|
+
const manifest: Manifest = {
|
|
90
|
+
modules: [
|
|
91
|
+
{
|
|
92
|
+
path: 'src/automation/pump/pump.ts',
|
|
93
|
+
declarations: [
|
|
94
|
+
{
|
|
95
|
+
kind: 'class',
|
|
96
|
+
name: 'ObcPump',
|
|
97
|
+
tagName: 'obc-pump',
|
|
98
|
+
lifecycle: 'beta',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
path: 'src/components/button/button.ts',
|
|
104
|
+
declarations: [
|
|
105
|
+
{
|
|
106
|
+
kind: 'class',
|
|
107
|
+
name: 'ObcButton',
|
|
108
|
+
tagName: 'obc-button',
|
|
109
|
+
description: '`<obc-button>` – A button.',
|
|
110
|
+
lifecycle: 'stable',
|
|
111
|
+
},
|
|
112
|
+
{kind: 'class', name: 'ButtonBase'},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
path: 'src/automation/line/line.ts',
|
|
117
|
+
declarations: [
|
|
118
|
+
{
|
|
119
|
+
kind: 'class',
|
|
120
|
+
name: 'ObcLine',
|
|
121
|
+
tagName: 'obc-line',
|
|
122
|
+
description: '`<obc-line>` – A line.',
|
|
123
|
+
lifecycle: 'deprecated',
|
|
124
|
+
deprecated: 'Use obc-corner-line instead. More text.',
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
path: 'src/palettes/x.ts',
|
|
130
|
+
declarations: [{kind: 'class', name: 'ObcOdd', tagName: 'obc-odd'}],
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
it('orders by family then tag and skips non-elements', () => {
|
|
136
|
+
const warn = vi.fn();
|
|
137
|
+
expect(componentEntries(manifest, warn).map((e) => e.tag)).toEqual([
|
|
138
|
+
'obc-button',
|
|
139
|
+
'obc-line',
|
|
140
|
+
'obc-pump',
|
|
141
|
+
]);
|
|
142
|
+
expect(warn).toHaveBeenCalledWith(expect.stringContaining('obc-odd'));
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('carries summary, lifecycle and the first sentence of a deprecation', () => {
|
|
146
|
+
const entries = componentEntries(manifest, () => {});
|
|
147
|
+
expect(entries.find((e) => e.tag === 'obc-line')).toMatchObject({
|
|
148
|
+
summary: 'A line.',
|
|
149
|
+
lifecycle: 'deprecated',
|
|
150
|
+
deprecatedNote: 'Use obc-corner-line instead.',
|
|
151
|
+
family: 'automation',
|
|
152
|
+
modulePath: 'src/automation/line/line.ts',
|
|
153
|
+
className: 'ObcLine',
|
|
154
|
+
});
|
|
155
|
+
const pump = entries.find((e) => e.tag === 'obc-pump')!;
|
|
156
|
+
expect(pump.summary).toBeUndefined();
|
|
157
|
+
expect(pump.description).toBe('');
|
|
158
|
+
expect(pump.deprecatedNote).toBeUndefined();
|
|
159
|
+
});
|
|
160
|
+
});
|