Repository navigation
Angular: Skip the runtime source decorator when the docgen server produces snippets - #35906
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe Angular docs configuration now selects static TypeScript snippets when the experimental docgen server feature is exactly ChangesAngular documentation snippet configuration
Merge Risk: ⚪ Minimal · up to This narrowly gates the runtime source decorator behind the experimental docgen-server flag, preserving existing behavior when the flag is off and preventing competing snippet producers when it is on; no actionable merge-blocking risk remains beyond normal checks and review. ✨ Finishing Touches📝 Generate docstrings
Comment |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 205 | 205 | 0 |
| Self size | 843 KB | 843 KB | 0 B |
| Dependency size | 86.39 MB | 86.53 MB | 🚨 +141 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 198 | 198 | 0 |
| Self size | 44 KB | 44 KB | 0 B |
| Dependency size | 84.86 MB | 85.00 MB | 🚨 +141 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
Check the diff here: storybookjs/storybook@f96ed20...add38a0 List of included PRs since previous version: - storybookjs/storybook#35922 (valentin/sb-1766-angular-docgen-documentation-pass) - storybookjs/storybook#35844 (s-robertson/u/srobertson/fix-react-component-meta-union-props) - storybookjs/storybook#35931 (valentin/sb-1847-componentid-collision-warning) - storybookjs/storybook#35923 (valentin/sb-1789-server-side-code-snippets-resolve-spreads-and-identifier) - storybookjs/storybook#35940 (valentin/sb-1789-review-fixes) - storybookjs/storybook#35900 (julien/vue-api-description) - storybookjs/storybook#35938 (fix-publish-ansi-parsing) - storybookjs/storybook#35929 (valentin/sb-1821-pin-oxc-resolver) - storybookjs/storybook#35936 (chore/changelog-v10.5.9) - storybookjs/storybook#35930 (valentin/sb-1789-review-fixes) - storybookjs/storybook#35921 (valentin/sb-1809-bug-angular-constructor-and-generic-function-inputs-lose-the) - storybookjs/storybook#35917 (norbert/fix-publish-staged-retries) - storybookjs/storybook#35896 (valentin/sb-1776-angular-docs-end-to-end) - storybookjs/storybook#35920 (julien/vue_server_docgen_options) - storybookjs/storybook#35907 (valentin/docgen-server-arg-types) - storybookjs/storybook#35886 (valentin/sb-1799-default-docgen-server-angular-vite) - storybookjs/storybook#35902 (fix/vue-snippet-runtimeoverride) - storybookjs/storybook#35825 (norbert/module-graph-skip-noop-mirror) - storybookjs/storybook#35629 (reuben/fix-pseudo-states-cssom-rewrites) - storybookjs/storybook#35915 (next-merge-prerelease) - storybookjs/storybook#35906 (valentin/angular-docs-decorator-gate) - storybookjs/storybook#35830 (version-non-patch-from-10.6.0-alpha.5) - storybookjs/storybook#35899 (valentin/angular-required-input-with-default) - storybookjs/storybook#35831 (norbert/spike-module-graph-hot-cold-split)
Follow-up to #35807.
What I did
With
experimentalDocgenServeron, Angular produces two different code snippets for the same story: the story-docs snippet the server builds (a TypeScript host component) and the HTML template the runtimesourceDecoratorcomputes in a post-render effect.Both are pushed to the manager over the same
SNIPPET_RENDEREDchannel event.The Source block is safe because it reads the story-docs service directly and prefers it, but the Code panel keeps whichever event arrives last, so what it shows depends on which emit wins the race - while the panel is labelled
tseither way.This gates the decorator on the feature flag, the way
@storybook/reactalready gatesjsxDecorator, so exactly one producer is registered.Before
After
The decision, in
code/frameworks/angular-vite/src/client/docs/config.ts:What no longer holds
With the docgen server on, the runtime template no longer reaches the Source block or the Code panel at all, under any timing.
For a story the analyzer produces no snippet for, both surfaces now fall back to raw CSF (
parameters.docs.source.originalSource, emitted by the samebeforeEachhook) instead of the runtime template.That is the same trade-off
@storybook/reactalready makes under this flag.With the flag off, nothing changes.
What a bad run looks like
Reverting the decorator gate while keeping the tests:
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
yarn task --task sandbox --start-from auto --template angular-vite/docgen-server-ts.storybook/preview.ts:@Componentclass binding the story's args), highlighted as TypeScript. It must never show the<storybook-button …>HTML template, and it must not flip between the two across reloads or navigation between stories.yarn task --task sandbox --start-from auto --template angular-vite/default-ts<storybook-button …>HTML template, highlighted as HTML, exactly as before this PR.Documentation
No documentation change: this is internal wiring behind the experimental
experimentalDocgenServerflag, and the user-facing behaviour it describes (server snippets replace the runtime template) is what was already documented.