@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,290 @@
|
|
|
1
|
+
import {describe, expect, it} from 'vitest';
|
|
2
|
+
import {resolveChannel} from './channel.js';
|
|
3
|
+
import {
|
|
4
|
+
escapeCell,
|
|
5
|
+
normalizeHeadings,
|
|
6
|
+
renderComponentPage,
|
|
7
|
+
storyItem,
|
|
8
|
+
} from './render-component.js';
|
|
9
|
+
import type {StoriesInfo} from './stories.js';
|
|
10
|
+
import type {ComponentEntry} from './types.js';
|
|
11
|
+
|
|
12
|
+
const channel = resolveChannel('next', {});
|
|
13
|
+
|
|
14
|
+
const entry: ComponentEntry = {
|
|
15
|
+
tag: 'obc-x',
|
|
16
|
+
className: 'ObcX',
|
|
17
|
+
modulePath: 'src/components/x/x.ts',
|
|
18
|
+
family: 'components',
|
|
19
|
+
summary: 'Shows X.',
|
|
20
|
+
lifecycle: 'beta',
|
|
21
|
+
deprecatedNote: undefined,
|
|
22
|
+
description:
|
|
23
|
+
'`<obc-x>` – Shows X.\n\n### Features\n\n- one\n\n### Usage Guidelines\n\nUse it.',
|
|
24
|
+
declaration: {
|
|
25
|
+
kind: 'class',
|
|
26
|
+
name: 'ObcX',
|
|
27
|
+
tagName: 'obc-x',
|
|
28
|
+
members: [
|
|
29
|
+
{
|
|
30
|
+
kind: 'field',
|
|
31
|
+
name: 'value',
|
|
32
|
+
type: {text: 'number'},
|
|
33
|
+
default: '0',
|
|
34
|
+
description: 'The value.',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
kind: 'field',
|
|
38
|
+
name: 'label',
|
|
39
|
+
type: {text: 'string'},
|
|
40
|
+
description: 'A | b',
|
|
41
|
+
inheritedFrom: {name: 'Base'},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
kind: 'field',
|
|
45
|
+
name: 'mode',
|
|
46
|
+
type: {text: 'Mode | undefined'},
|
|
47
|
+
default: "'a' | 'b'",
|
|
48
|
+
},
|
|
49
|
+
{kind: 'field', name: '_internal', type: {text: 'number'}},
|
|
50
|
+
{kind: 'field', name: 'hidden', privacy: 'private'},
|
|
51
|
+
{kind: 'field', name: 'styles', static: true},
|
|
52
|
+
{kind: 'method', name: 'focus'},
|
|
53
|
+
],
|
|
54
|
+
attributes: [{name: 'value', fieldName: 'value'}],
|
|
55
|
+
events: [
|
|
56
|
+
{
|
|
57
|
+
name: 'change',
|
|
58
|
+
type: {text: 'CustomEvent<{value: number}>'},
|
|
59
|
+
description: 'Fired on change.',
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
slots: [
|
|
63
|
+
{name: '', description: 'Default content.'},
|
|
64
|
+
{name: 'icon', description: 'An icon.'},
|
|
65
|
+
],
|
|
66
|
+
cssParts: [{name: 'wrapper', description: 'The box.'}],
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const stories: StoriesInfo[] = [
|
|
71
|
+
{
|
|
72
|
+
file: 'x.stories.ts',
|
|
73
|
+
title: 'UI/X',
|
|
74
|
+
componentTag: 'obc-x',
|
|
75
|
+
componentDocs: 'Extra story-file docs.',
|
|
76
|
+
docsPage: true,
|
|
77
|
+
stories: [
|
|
78
|
+
{exportName: 'Default', name: 'Default', doc: 'Shows the default.'},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
file: 'x-more.stories.ts',
|
|
83
|
+
title: 'UI/X More',
|
|
84
|
+
componentTag: 'obc-x',
|
|
85
|
+
componentDocs: undefined,
|
|
86
|
+
docsPage: true,
|
|
87
|
+
stories: [
|
|
88
|
+
{exportName: 'DenseLayout', name: 'Dense (compact)', doc: undefined},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
describe('renderComponentPage', () => {
|
|
94
|
+
const out = renderComponentPage({
|
|
95
|
+
entry,
|
|
96
|
+
channel,
|
|
97
|
+
stories,
|
|
98
|
+
seeAlso: [{title: 'Advice System', href: 'https://g/advice'}],
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('renders the header', () => {
|
|
102
|
+
expect(out.startsWith('# `<obc-x>`\n\nShows X.\n\n')).toBe(true);
|
|
103
|
+
expect(out).toContain(
|
|
104
|
+
'Lifecycle: beta. [Storybook](https://openbridge-next-storybook.web.app/?path=/docs/ui-x--docs) · [Source](https://raw.githubusercontent.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/develop/packages/openbridge-webcomponents/src/components/x/x.ts)'
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('normalises the description headings and appends the story-file docs', () => {
|
|
109
|
+
expect(out).toContain('\n## Features\n');
|
|
110
|
+
expect(out).toContain('\n## Usage Guidelines\n');
|
|
111
|
+
expect(out).toContain('Extra story-file docs.');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('renders the tables', () => {
|
|
115
|
+
expect(out).toContain(
|
|
116
|
+
'| Property | Attribute | Type | Default | Description |'
|
|
117
|
+
);
|
|
118
|
+
expect(out).toContain('| value | value | `number` | `0` | The value. |');
|
|
119
|
+
expect(out).toContain('| label | | `string` | | A \\| b |');
|
|
120
|
+
expect(out).toContain(
|
|
121
|
+
"| mode | | `Mode \\| undefined` | `'a' \\| 'b'` | |"
|
|
122
|
+
);
|
|
123
|
+
expect(out).not.toContain('_internal');
|
|
124
|
+
expect(out).not.toContain('| hidden');
|
|
125
|
+
expect(out).not.toContain('| styles');
|
|
126
|
+
expect(out).toContain(
|
|
127
|
+
'| change | `CustomEvent<{value: number}>` | Fired on change. |'
|
|
128
|
+
);
|
|
129
|
+
expect(out).toContain('| (default) | Default content. |');
|
|
130
|
+
expect(out).toContain('| icon | An icon. |');
|
|
131
|
+
expect(out).toContain('## CSS parts');
|
|
132
|
+
expect(out).toContain('| wrapper | The box. |');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('lists stories from every file declaring the tag', () => {
|
|
136
|
+
expect(out).toContain(
|
|
137
|
+
'- [Default](https://openbridge-next-storybook.web.app/?path=/story/ui-x--default): Shows the default.'
|
|
138
|
+
);
|
|
139
|
+
expect(out).toContain(
|
|
140
|
+
'- [Dense (compact)](https://openbridge-next-storybook.web.app/?path=/story/ui-x-more--dense-layout)\n'
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('keeps a story description whole, pipes as written', () => {
|
|
145
|
+
const page = renderComponentPage({
|
|
146
|
+
entry,
|
|
147
|
+
channel,
|
|
148
|
+
seeAlso: [],
|
|
149
|
+
stories: [
|
|
150
|
+
{
|
|
151
|
+
...stories[0],
|
|
152
|
+
stories: [
|
|
153
|
+
{
|
|
154
|
+
exportName: 'Fixed',
|
|
155
|
+
name: 'Fixed',
|
|
156
|
+
doc: 'Shrinks when `|value − setpoint|` is small,\nper the deadband.\n\n- **false**: reacts\n- **true**: scales\n\nBoth side by side.',
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
});
|
|
162
|
+
expect(page).toContain(
|
|
163
|
+
'- [Fixed](https://openbridge-next-storybook.web.app/?path=/story/ui-x--fixed): Shrinks when `|value − setpoint|` is small, per the deadband.\n\n - **false**: reacts\n - **true**: scales\n\n Both side by side.\n'
|
|
164
|
+
);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('links the first story when no stories file has a docs page', () => {
|
|
168
|
+
const noDocs = {...stories[0], docsPage: false};
|
|
169
|
+
expect(
|
|
170
|
+
renderComponentPage({entry, channel, seeAlso: [], stories: [noDocs]})
|
|
171
|
+
).toContain(
|
|
172
|
+
'Lifecycle: beta. [Storybook](https://openbridge-next-storybook.web.app/?path=/story/ui-x--default) · [Source]'
|
|
173
|
+
);
|
|
174
|
+
expect(
|
|
175
|
+
renderComponentPage({
|
|
176
|
+
entry,
|
|
177
|
+
channel,
|
|
178
|
+
seeAlso: [],
|
|
179
|
+
stories: [noDocs, stories[1]],
|
|
180
|
+
})
|
|
181
|
+
).toContain(
|
|
182
|
+
'Lifecycle: beta. [Storybook](https://openbridge-next-storybook.web.app/?path=/docs/ui-x-more--docs) · [Source]'
|
|
183
|
+
);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('renders see-also links', () => {
|
|
187
|
+
expect(out).toContain('## See also\n\n- [Advice System](https://g/advice)');
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('resolves a docs reference on a component stories file, once', () => {
|
|
191
|
+
const withRef: StoriesInfo[] = [
|
|
192
|
+
{...stories[0], componentDocs: {kind: 'classDocs', arg: 'ObcBase'}},
|
|
193
|
+
{...stories[1], componentDocs: {kind: 'moduleDocs', arg: 'x/x.ts'}},
|
|
194
|
+
];
|
|
195
|
+
const page = renderComponentPage({
|
|
196
|
+
entry,
|
|
197
|
+
channel,
|
|
198
|
+
stories: withRef,
|
|
199
|
+
seeAlso: [],
|
|
200
|
+
resolveDocs: (ref) =>
|
|
201
|
+
ref.kind === 'classDocs' ? 'Base class docs.' : entry.description,
|
|
202
|
+
});
|
|
203
|
+
expect(page).toContain('Base class docs.');
|
|
204
|
+
expect(page.match(/Shows X\./g)).toHaveLength(2);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('renders a bare declaration without throwing', () => {
|
|
208
|
+
const bare: ComponentEntry = {
|
|
209
|
+
...entry,
|
|
210
|
+
summary: undefined,
|
|
211
|
+
lifecycle: undefined,
|
|
212
|
+
description: '',
|
|
213
|
+
declaration: {kind: 'class', tagName: 'obc-x'},
|
|
214
|
+
};
|
|
215
|
+
const page = renderComponentPage({
|
|
216
|
+
entry: bare,
|
|
217
|
+
channel,
|
|
218
|
+
stories: [],
|
|
219
|
+
seeAlso: [],
|
|
220
|
+
});
|
|
221
|
+
expect(page).toContain('No summary yet.');
|
|
222
|
+
expect(page).toContain('Lifecycle: unknown.');
|
|
223
|
+
expect(page).not.toContain('[Storybook]');
|
|
224
|
+
expect(page).toContain('## Properties\n\nNone.');
|
|
225
|
+
expect(page).toContain('## Events\n\nNone.');
|
|
226
|
+
expect(page).toContain('## Slots\n\nNone.');
|
|
227
|
+
expect(page).not.toContain('## CSS parts');
|
|
228
|
+
expect(page).not.toContain('## Stories');
|
|
229
|
+
expect(page).not.toContain('## See also');
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
describe('storyItem', () => {
|
|
234
|
+
it('indents a description that opens with a list', () => {
|
|
235
|
+
expect(storyItem('L', 'u', '- First\n- Second\n\nMore.')).toBe(
|
|
236
|
+
'- [L](u)\n\n - First\n - Second\n\n More.'
|
|
237
|
+
);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('indents a fenced example line by line, blank lines included', () => {
|
|
241
|
+
expect(
|
|
242
|
+
storyItem('F', 'u', '```html\n<obc-x></obc-x>\n\n<obc-y></obc-y>\n```')
|
|
243
|
+
).toBe(
|
|
244
|
+
'- [F](u)\n\n ```html\n <obc-x></obc-x>\n\n <obc-y></obc-y>\n ```'
|
|
245
|
+
);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('ends the inline prose where a list starts without a blank line', () => {
|
|
249
|
+
expect(storyItem('M', 'u', 'Two modes:\n- a\n- b')).toBe(
|
|
250
|
+
'- [M](u): Two modes:\n\n - a\n - b'
|
|
251
|
+
);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
describe('normalizeHeadings', () => {
|
|
256
|
+
it('shifts every heading so the shallowest becomes ##, leaving code alone', () => {
|
|
257
|
+
expect(
|
|
258
|
+
normalizeHeadings(
|
|
259
|
+
'### Features\n\ntext\n\n#### Sub\n\n```md\n# in code\n```'
|
|
260
|
+
)
|
|
261
|
+
).toBe('## Features\n\ntext\n\n### Sub\n\n```md\n# in code\n```');
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('leaves tilde fences and longer backtick fences alone', () => {
|
|
265
|
+
expect(
|
|
266
|
+
normalizeHeadings(
|
|
267
|
+
'### Features\n\n~~~sh\n# comment\n~~~\n\n````md\n# four\n```\n# still code\n````'
|
|
268
|
+
)
|
|
269
|
+
).toBe(
|
|
270
|
+
'## Features\n\n~~~sh\n# comment\n~~~\n\n````md\n# four\n```\n# still code\n````'
|
|
271
|
+
);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('demotes an H1 to ##', () => {
|
|
275
|
+
expect(normalizeHeadings('# Title\n\n## Part')).toBe(
|
|
276
|
+
'## Title\n\n### Part'
|
|
277
|
+
);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it('returns text without headings unchanged', () => {
|
|
281
|
+
expect(normalizeHeadings('plain')).toBe('plain');
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
describe('escapeCell', () => {
|
|
286
|
+
it('escapes pipes and flattens newlines', () => {
|
|
287
|
+
expect(escapeCell('a | b\nc')).toBe('a \\| b c');
|
|
288
|
+
expect(escapeCell(undefined)).toBe('');
|
|
289
|
+
});
|
|
290
|
+
});
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import {rawUrl, type Channel} from './channel.js';
|
|
2
|
+
import {fenceState} from './markdown.js';
|
|
3
|
+
import {
|
|
4
|
+
storybookUrl,
|
|
5
|
+
storyPageUrl,
|
|
6
|
+
type DocsRef,
|
|
7
|
+
type StoriesInfo,
|
|
8
|
+
} from './stories.js';
|
|
9
|
+
import type {ComponentEntry, ManifestNamed} from './types.js';
|
|
10
|
+
|
|
11
|
+
export interface ComponentPageInput {
|
|
12
|
+
entry: ComponentEntry;
|
|
13
|
+
channel: Channel;
|
|
14
|
+
stories: StoriesInfo[];
|
|
15
|
+
seeAlso: {title: string; href: string}[];
|
|
16
|
+
resolveDocs?: (ref: DocsRef) => string | undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const PACKAGE_DIR = 'packages/openbridge-webcomponents';
|
|
20
|
+
|
|
21
|
+
/** One table cell: pipes escaped, newlines flattened, nothing for undefined. */
|
|
22
|
+
export function escapeCell(text: string | undefined): string {
|
|
23
|
+
return (text ?? '')
|
|
24
|
+
.replace(/\s*\n\s*/g, ' ')
|
|
25
|
+
.replace(/\|/g, '\\|')
|
|
26
|
+
.trim();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// A list, fence, quote, heading or table line: it keeps its own line.
|
|
30
|
+
const BLOCK_START = /^\s*([-*+]\s|\d+[.)]\s|`{3,}|~{3,}|>|#{1,6}\s|\|)/;
|
|
31
|
+
|
|
32
|
+
/** A story as a list item: its opening prose on the line, everything after it indented under it. */
|
|
33
|
+
export function storyItem(
|
|
34
|
+
name: string,
|
|
35
|
+
url: string,
|
|
36
|
+
doc: string | undefined
|
|
37
|
+
): string {
|
|
38
|
+
const link = `- [${name}](${url})`;
|
|
39
|
+
if (!doc) return link;
|
|
40
|
+
const lines = doc.split('\n');
|
|
41
|
+
let end = lines.findIndex((l) => !l.trim() || BLOCK_START.test(l));
|
|
42
|
+
if (end === -1) end = lines.length;
|
|
43
|
+
const prose = lines
|
|
44
|
+
.slice(0, end)
|
|
45
|
+
.map((l) => l.trim())
|
|
46
|
+
.join(' ');
|
|
47
|
+
const body = lines
|
|
48
|
+
.slice(end)
|
|
49
|
+
.map((l) => (l.trim() ? ` ${l}` : ''))
|
|
50
|
+
.join('\n')
|
|
51
|
+
.replace(/^\n+/, '');
|
|
52
|
+
return [prose ? `${link}: ${prose}` : link, body]
|
|
53
|
+
.filter(Boolean)
|
|
54
|
+
.join('\n\n');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// GFM splits a table cell on a pipe even inside a code span unless it is escaped.
|
|
58
|
+
const code = (text: string | undefined): string =>
|
|
59
|
+
text ? `\`${text.replace(/\n\s*/g, ' ').replace(/\|/g, '\\|')}\`` : '';
|
|
60
|
+
|
|
61
|
+
/** Shifts every heading outside fenced code so the shallowest one is `##`. */
|
|
62
|
+
export function normalizeHeadings(markdown: string): string {
|
|
63
|
+
const lines = markdown.split('\n');
|
|
64
|
+
let fence = fenceState();
|
|
65
|
+
let min = Infinity;
|
|
66
|
+
for (const line of lines) {
|
|
67
|
+
if (fence.update(line) || fence.inFence) continue;
|
|
68
|
+
const m = /^(#{1,6})\s/.exec(line);
|
|
69
|
+
if (m) min = Math.min(min, m[1].length);
|
|
70
|
+
}
|
|
71
|
+
if (min === Infinity || min === 2) return markdown;
|
|
72
|
+
const shift = 2 - min;
|
|
73
|
+
fence = fenceState();
|
|
74
|
+
return lines
|
|
75
|
+
.map((line) => {
|
|
76
|
+
if (fence.update(line) || fence.inFence) return line;
|
|
77
|
+
const m = /^(#{1,6})(\s.*)$/.exec(line);
|
|
78
|
+
return m ? '#'.repeat(m[1].length + shift) + m[2] : line;
|
|
79
|
+
})
|
|
80
|
+
.join('\n');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function table(header: string[], rows: string[][]): string[] {
|
|
84
|
+
if (rows.length === 0) return ['None.'];
|
|
85
|
+
return [
|
|
86
|
+
`| ${header.join(' | ')} |`,
|
|
87
|
+
`| ${header.map(() => '---').join(' | ')} |`,
|
|
88
|
+
...rows.map((r) => `| ${r.join(' | ')} |`),
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function named(items: ManifestNamed[]): string[][] {
|
|
93
|
+
return items.map((i) => [i.name || '(default)', escapeCell(i.description)]);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function renderComponentPage(input: ComponentPageInput): string {
|
|
97
|
+
const {entry, channel, stories, seeAlso, resolveDocs} = input;
|
|
98
|
+
const d = entry.declaration;
|
|
99
|
+
const own = stories.filter((s) => s.componentTag === entry.tag);
|
|
100
|
+
const linked =
|
|
101
|
+
own.find((s) => s.title && s.docsPage) ?? own.find((s) => s.title);
|
|
102
|
+
const storybook = linked && storybookUrl(channel, linked);
|
|
103
|
+
const out: string[] = [
|
|
104
|
+
`# \`<${entry.tag}>\``,
|
|
105
|
+
'',
|
|
106
|
+
entry.summary ?? 'No summary yet.',
|
|
107
|
+
'',
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
const links = [
|
|
111
|
+
storybook ? `[Storybook](${storybook})` : undefined,
|
|
112
|
+
`[Source](${rawUrl(channel, `${PACKAGE_DIR}/${entry.modulePath}`)})`,
|
|
113
|
+
].filter(Boolean);
|
|
114
|
+
out.push(
|
|
115
|
+
`Lifecycle: ${entry.lifecycle ?? 'unknown'}. ${links.join(' · ')}`,
|
|
116
|
+
''
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
if (entry.description) out.push(normalizeHeadings(entry.description), '');
|
|
120
|
+
for (const s of own) {
|
|
121
|
+
const docs =
|
|
122
|
+
typeof s.componentDocs === 'string'
|
|
123
|
+
? s.componentDocs
|
|
124
|
+
: s.componentDocs && resolveDocs?.(s.componentDocs);
|
|
125
|
+
// A moduleDocs() of the component's own module is the description again.
|
|
126
|
+
if (docs && docs.trim() !== entry.description.trim())
|
|
127
|
+
out.push(normalizeHeadings(docs), '');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const attributeOf = new Map(
|
|
131
|
+
(d.attributes ?? []).map((a) => [a.fieldName, a.name])
|
|
132
|
+
);
|
|
133
|
+
const fields = (d.members ?? []).filter(
|
|
134
|
+
(m) =>
|
|
135
|
+
m.kind === 'field' &&
|
|
136
|
+
!m.static &&
|
|
137
|
+
(m.privacy ?? 'public') === 'public' &&
|
|
138
|
+
!m.name.startsWith('_')
|
|
139
|
+
);
|
|
140
|
+
out.push(
|
|
141
|
+
'## Properties',
|
|
142
|
+
'',
|
|
143
|
+
...table(
|
|
144
|
+
['Property', 'Attribute', 'Type', 'Default', 'Description'],
|
|
145
|
+
fields.map((m) => [
|
|
146
|
+
m.name,
|
|
147
|
+
attributeOf.get(m.name) ?? '',
|
|
148
|
+
code(m.type?.text),
|
|
149
|
+
code(m.default),
|
|
150
|
+
escapeCell(m.description),
|
|
151
|
+
])
|
|
152
|
+
),
|
|
153
|
+
'',
|
|
154
|
+
'## Events',
|
|
155
|
+
'',
|
|
156
|
+
...table(
|
|
157
|
+
['Event', 'Type', 'Description'],
|
|
158
|
+
(d.events ?? []).map((e) => [
|
|
159
|
+
e.name,
|
|
160
|
+
code(e.type?.text),
|
|
161
|
+
escapeCell(e.description),
|
|
162
|
+
])
|
|
163
|
+
),
|
|
164
|
+
'',
|
|
165
|
+
'## Slots',
|
|
166
|
+
'',
|
|
167
|
+
...table(['Slot', 'Description'], named(d.slots ?? [])),
|
|
168
|
+
''
|
|
169
|
+
);
|
|
170
|
+
if (d.cssParts?.length) {
|
|
171
|
+
out.push(
|
|
172
|
+
'## CSS parts',
|
|
173
|
+
'',
|
|
174
|
+
...table(['Part', 'Description'], named(d.cssParts)),
|
|
175
|
+
''
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
if (d.cssProperties?.length) {
|
|
179
|
+
out.push(
|
|
180
|
+
'## CSS custom properties',
|
|
181
|
+
'',
|
|
182
|
+
...table(['Property', 'Description'], named(d.cssProperties)),
|
|
183
|
+
''
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const storyLines = own.flatMap((s) =>
|
|
188
|
+
s.title
|
|
189
|
+
? s.stories.map((st) =>
|
|
190
|
+
storyItem(
|
|
191
|
+
st.name,
|
|
192
|
+
storyPageUrl(channel, s.title!, st.exportName),
|
|
193
|
+
st.doc
|
|
194
|
+
)
|
|
195
|
+
)
|
|
196
|
+
: []
|
|
197
|
+
);
|
|
198
|
+
if (storyLines.length) out.push('## Stories', '', ...storyLines, '');
|
|
199
|
+
if (seeAlso.length) {
|
|
200
|
+
out.push(
|
|
201
|
+
'## See also',
|
|
202
|
+
'',
|
|
203
|
+
...seeAlso.map((s) => `- [${s.title}](${s.href})`),
|
|
204
|
+
''
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
return out.join('\n').replace(/\n+$/, '\n');
|
|
208
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {describe, expect, it} from 'vitest';
|
|
2
|
+
import {resolveChannel} from './channel.js';
|
|
3
|
+
import {
|
|
4
|
+
isModuleGuide,
|
|
5
|
+
renderLlmsFull,
|
|
6
|
+
renderStoriesGuide,
|
|
7
|
+
} from './render-guides.js';
|
|
8
|
+
import type {StoriesInfo} from './stories.js';
|
|
9
|
+
|
|
10
|
+
const channel = resolveChannel('next', {});
|
|
11
|
+
const base: StoriesInfo = {
|
|
12
|
+
file: 'setpoint.stories.ts',
|
|
13
|
+
title: 'Building Blocks/Setpoint',
|
|
14
|
+
componentTag: undefined,
|
|
15
|
+
componentDocs: '# Setpoint\n\nThe marker.',
|
|
16
|
+
docsPage: true,
|
|
17
|
+
stories: [
|
|
18
|
+
{
|
|
19
|
+
exportName: 'NotEqual',
|
|
20
|
+
name: 'NotEqual (Input ≠ Output)',
|
|
21
|
+
doc: 'Full size.',
|
|
22
|
+
},
|
|
23
|
+
{exportName: 'Flow', name: 'Flow', doc: undefined},
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
describe('isModuleGuide', () => {
|
|
28
|
+
it('is a guide only with a title, no component and some docs', () => {
|
|
29
|
+
expect(isModuleGuide(base)).toBe(true);
|
|
30
|
+
expect(isModuleGuide({...base, componentTag: 'obc-x'})).toBe(false);
|
|
31
|
+
expect(isModuleGuide({...base, componentDocs: undefined})).toBe(false);
|
|
32
|
+
expect(isModuleGuide({...base, title: undefined})).toBe(false);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('renderStoriesGuide', () => {
|
|
37
|
+
it('renders the title, the docs and the stories', () => {
|
|
38
|
+
const out = renderStoriesGuide(base, channel, () => undefined);
|
|
39
|
+
expect(out.startsWith('# Setpoint\n\n')).toBe(true);
|
|
40
|
+
expect(out).toContain(
|
|
41
|
+
'[Storybook](https://openbridge-next-storybook.web.app/?path=/docs/building-blocks-setpoint--docs)'
|
|
42
|
+
);
|
|
43
|
+
expect(out).toContain('\n## Setpoint\n\nThe marker.');
|
|
44
|
+
expect(out).toContain(
|
|
45
|
+
'- [NotEqual (Input ≠ Output)](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-setpoint--not-equal): Full size.'
|
|
46
|
+
);
|
|
47
|
+
expect(out).toContain(
|
|
48
|
+
'- [Flow](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-setpoint--flow)\n'
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('keeps a story description whole', () => {
|
|
53
|
+
const out = renderStoriesGuide(
|
|
54
|
+
{...base, stories: [{exportName: 'Flow', name: 'Flow', doc: 'A.\n\nB.'}]},
|
|
55
|
+
channel,
|
|
56
|
+
() => undefined
|
|
57
|
+
);
|
|
58
|
+
expect(out).toContain(
|
|
59
|
+
'- [Flow](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-setpoint--flow): A.\n\n B.\n'
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('links the first story when the file has no docs page', () => {
|
|
64
|
+
const out = renderStoriesGuide(
|
|
65
|
+
{...base, docsPage: false},
|
|
66
|
+
channel,
|
|
67
|
+
() => undefined
|
|
68
|
+
);
|
|
69
|
+
expect(out).toContain(
|
|
70
|
+
'[Storybook](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-setpoint--not-equal)'
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('resolves a moduleDocs reference through the callback', () => {
|
|
75
|
+
const info: StoriesInfo = {
|
|
76
|
+
...base,
|
|
77
|
+
componentDocs: {kind: 'moduleDocs', arg: 'x/y.ts'},
|
|
78
|
+
};
|
|
79
|
+
const out = renderStoriesGuide(info, channel, (ref) =>
|
|
80
|
+
ref.arg === 'x/y.ts' ? 'Module text.' : undefined
|
|
81
|
+
);
|
|
82
|
+
expect(out).toContain('Module text.');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('strips the Introduction prefix from the title', () => {
|
|
86
|
+
expect(
|
|
87
|
+
renderStoriesGuide(
|
|
88
|
+
{...base, title: 'Introduction/Thing'},
|
|
89
|
+
channel,
|
|
90
|
+
() => undefined
|
|
91
|
+
).startsWith('# Thing\n')
|
|
92
|
+
).toBe(true);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('renderLlmsFull', () => {
|
|
97
|
+
it('joins the parts with a rule between them', () => {
|
|
98
|
+
expect(
|
|
99
|
+
renderLlmsFull([
|
|
100
|
+
{title: 'a', markdown: '# A\n\nx\n'},
|
|
101
|
+
{title: 'b', markdown: '# B'},
|
|
102
|
+
])
|
|
103
|
+
).toBe('# A\n\nx\n\n---\n\n# B\n');
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type {Channel} from './channel.js';
|
|
2
|
+
import {normalizeHeadings, storyItem} from './render-component.js';
|
|
3
|
+
import {
|
|
4
|
+
storybookUrl,
|
|
5
|
+
storyPageUrl,
|
|
6
|
+
type DocsRef,
|
|
7
|
+
type StoriesInfo,
|
|
8
|
+
} from './stories.js';
|
|
9
|
+
|
|
10
|
+
/** A stories file that documents a module rather than one element (Setpoint, External Scale, Advice). */
|
|
11
|
+
export function isModuleGuide(info: StoriesInfo): boolean {
|
|
12
|
+
return (
|
|
13
|
+
info.title !== undefined &&
|
|
14
|
+
info.componentTag === undefined &&
|
|
15
|
+
info.componentDocs !== undefined
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function renderStoriesGuide(
|
|
20
|
+
info: StoriesInfo,
|
|
21
|
+
channel: Channel,
|
|
22
|
+
resolveDocs: (ref: DocsRef) => string | undefined
|
|
23
|
+
): string {
|
|
24
|
+
const title = info.title!;
|
|
25
|
+
const docs =
|
|
26
|
+
typeof info.componentDocs === 'string'
|
|
27
|
+
? info.componentDocs
|
|
28
|
+
: info.componentDocs && resolveDocs(info.componentDocs);
|
|
29
|
+
const storybook = storybookUrl(channel, info);
|
|
30
|
+
const out = [`# ${title.split('/').pop()}`, ''];
|
|
31
|
+
if (storybook) out.push(`[Storybook](${storybook})`, '');
|
|
32
|
+
if (docs) out.push(normalizeHeadings(docs.trim()), '');
|
|
33
|
+
if (info.stories.length) {
|
|
34
|
+
out.push(
|
|
35
|
+
'## Stories',
|
|
36
|
+
'',
|
|
37
|
+
...info.stories.map((st) =>
|
|
38
|
+
storyItem(st.name, storyPageUrl(channel, title, st.exportName), st.doc)
|
|
39
|
+
),
|
|
40
|
+
''
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return out.join('\n').replace(/\n+$/, '\n');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** `llms-full.txt`: the README, every guide and every component page, in llms.txt order. */
|
|
47
|
+
export function renderLlmsFull(
|
|
48
|
+
parts: {title: string; markdown: string}[]
|
|
49
|
+
): string {
|
|
50
|
+
return `${parts.map((p) => p.markdown.replace(/\n+$/, '')).join('\n\n---\n\n')}\n`;
|
|
51
|
+
}
|