-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(public-docsite-v9): add llms docs #34838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
📊 Bundle size report✅ No changes found |
Pull request demo site: URL |
This is awesome! Can we apply the same pattern to composed stories as well? It would be really cool to get this done for charts and contrib as well. |
baseUrl: argv.baseUrl, | ||
summaryTitle: argv.summaryTitle, | ||
summaryDescription: argv.summaryDescription, | ||
refs: parseRefs(argv.refs), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this whole logic could be simplified as we can guarantee what yargs parse will provide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it works well with primitive types, but I had some issues with objects, that's why this is needed. argv.refs
has string|number[]
type
|
||
const stories: StorybookStoreItem[] = await page.evaluate(async () => { | ||
// @ts-expect-error - Storybook Client API is not typed | ||
await window.__STORYBOOK_CLIENT_API__.storyStore.cacheAllCSFFiles(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this wont work starting sb v8
we will need to add similar feature flagged behaviours like we did for storywright, which is also official public API
this returns different metadata as currently used private api so needs to be doublechecked if this is feasible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__STORYBOOK_PREVIEW__.extract()
doesn't provide all data we need, but we could use __STORYBOOK_PREVIEW__.storyStore
which is available for both SB 7 and 8+
https://fluentuipr.z22.web.core.windows.net/pull/34838/public-docsite-v9/storybook/llms.txt - v9 llms.txt Contrib isn't ready yet since it's not in the monorepo, and I'm still figuring out the optimal way to distribute the script if we'll decide to go with it. |
distribution: i don't see how this could possible work as SB addon or bundler plugin because how this works under the hood. it's very similar to what storywright does for obtaining screenshots, which is actually desired behaviour as it makes the tool atomic and re-usable. While the implementation is tightly coupled to our full source addon, it shouldn't coupled as a pre-requirement to have - thus having a graceful behaviour, if full source exists we process that code otherwise standard sb code.
storybook composition: this approach won't scale outside repo linked SB, thus the approach here should be that it's responsibility of linked(composed) SB to generate the markdown assets as part of their production builds |
Thanks for the feedback @Hotell!
That makes sense.
Agree, do you think it should live in the core monorepo or as a standalone repo?
That's exactly how it works atm, we use the |
…torybook documentation extraction
1b87b82
to
e9051fa
Compare
lets stick in core repo for now for logistic and distribution simplicity, in future it might make sense to create a new fluent-storybook-addons repo or something alike |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking great !
- added some commens/actionables ( mainly the SB api simplification / encapsulation )
A thing for thought:
- with this approach it's a black box that might come as a surprise what the deployed output will be. maybe we should consider actually storing the
.txt
generation in git and force to re-generate if content changes ( similarly like we have for JSXIntrinsicElement in react-utilities )
demandOption: true, | ||
describe: 'Relative path to the Storybook distribution folder', | ||
}) | ||
.option('baseUrl', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit confusing, I thought this is used to actually fetch metadata from that origin but its only purpose is text emit in the .txt
file
can we improve the docs or rename the property to something more meaningful ?
.option('baseUrl', { | ||
type: 'string', | ||
default: '/', | ||
describe: 'Base URL for the Storybook docs', | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.option('baseUrl', { | |
type: 'string', | |
default: '/', | |
describe: 'Base URL for the Storybook docs', | |
}) | |
.option('summaryBaseUrl', { | |
type: 'string', | |
default: '/', | |
describe: 'Storybook deployed URL for the summary docs', | |
}) |
## Requirements | ||
|
||
- Node.js 16+ | ||
- Storybook 7+ (supports both Storybook 7 and 8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the new approach should cover also v9 correct ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve tested this with v7 and v8 for Fluent core and extensions, and will check v9 next.
That's a valid point about controlling the output, but it would mean core devs need to build a full docsite locally with every component story update PR, right? |
Previous Behavior
New Behavior
This PR introduces a new CLI tool that extracts documentation from Storybook builds and converts it to LLM-friendly formats following the llmstxt.org specification. The tool processes Storybook production builds to generate comprehensive documentation in plain text format optimized for Large Language Models.
Key Features
Technical Implementation
page.route()
to serve Storybook files without needing a web server__STORYBOOK_PREVIEW__
) for metadatastoryStore
) and Storybook 8+ (storyStoreValue
)Output Structure
Usage Examples
Basic Usage:
With Configuration File:
Files Added
tools/storybook-llms-extractor/src/cli.ts
- CLI entry point and argument processingtools/storybook-llms-extractor/src/utils.ts
- Core extraction and conversion logictools/storybook-llms-extractor/src/types.ts
- TypeScript type definitionstools/storybook-llms-extractor/src/index.ts
- Package exportstools/storybook-llms-extractor/src/utils.spec.ts
- Unit teststools/storybook-llms-extractor/src/__fixtures__/
- Test fixturestools/storybook-llms-extractor/README.md
- Comprehensive documentation