Extend extraction code into ecschema-metadata and core-frontend#8976
Open
Extend extraction code into ecschema-metadata and core-frontend#8976
Conversation
aruniverse
reviewed
Feb 11, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Integrates betools extract into @itwin/ecschema-metadata and @itwin/core-frontend so documentation snippets can be sourced from package-local, runnable example tests and produced as part of rush docs.
Changes:
- Added
extractscripts and chained them into each package’sdocsscript; updated frontend test setup to copy schema JSON assets. - Migrated/refactored example-code tests into package-local
src/test/example-codeand updated assertions tovitest. - Updated documentation guidance (CONTRIBUTING) and a markdown page to present extracted snippets more cleanly.
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/quantity-formatting/usage/UnitConversion.md | Wraps included snippet in a collapsible <details> block. |
| core/frontend/src/test/example-code/quantity/Parsing.test.ts | Updates imports and switches assertions from chai to vitest. |
| core/frontend/src/test/example-code/quantity/Formatting.test.ts | Updates app startup approach and switches assertions to vitest. |
| core/frontend/src/test/example-code/quantity/FormatsProvider.test.ts | Changes schema loading approach (fetch JSON) and updates assertions to vitest. |
| core/frontend/package.json | Adds extract, adds schema copy step for tests, chains extract into docs, adds schema devDependencies. |
| core/ecschema-metadata/src/test/example-code/UnitConversion.test.ts | Refactors schema loading to local xml deserialization and switches assertions to vitest. |
| core/ecschema-metadata/src/test/example-code/Ratio.test.ts | Refactors schema loading to local xml deserialization and switches assertions to vitest. |
| core/ecschema-metadata/src/test/assets/RatioUnits.ecschema.xml | Adds schema asset used by ratio example tests. |
| core/ecschema-metadata/package.json | Adds extract and chains extract into docs. |
| common/config/rush/browser-approved-packages.json | Allows bentley schema packages in frontend category. |
| common/changes/@itwin/ecschema-metadata/nam-extrapolate-extract_2026-02-09-21-37.json | Adds rush change record (type none). |
| common/changes/@itwin/core-frontend/nam-extrapolate-extract_2026-02-11-15-05.json | Adds rush change record (type none). |
| CONTRIBUTING.md | Adds contributor documentation for snippet extraction workflow and updates TOC. |
Files not reviewed (1)
- common/config/rush/pnpm-lock.yaml: Language not supported
core/ecschema-metadata/src/test/example-code/UnitConversion.test.ts
Outdated
Show resolved
Hide resolved
core/frontend/src/test/example-code/quantity/Formatting.test.ts
Outdated
Show resolved
Hide resolved
eringram
approved these changes
Feb 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces
betools extractinto ecschema-metadata and core-frontend, incorporating them intorush docsworkflow.The goal is to have example code snippets meant for users to always be a part of actively maintained, tested code. This was difficult as previously the majority of example code snippets were housed in
example-codefolder, which mixes frontend and backend tests. However, many of these snippets aren't actually tested, only instead part of declared exported functions, as valid frontend tests would need a proper browser environment.One solution - Since each package has it's own test infrastructure set up, we can split the tests off into their respective packages, allowing verifiable tests that will always be run as part of our CI. Establish a standard that the extraction script only runs against files found within
test/example-codeDocumentation workflow improvements:
CONTRIBUTING.mddescribing how to extract documentation code snippets from test files, including instructions for marking extraction regions, updating scripts, and referencing snippets in markdown documentation.package.jsonscripts incore/ecschema-metadataandcore/frontendto include anextractscript for snippet extraction and to chain extraction with documentation generation.Test file and methodology updates:
Ratio.test.ts,UnitConversion.test.ts) tosrc/test/example-code, updated them to usevitestassertions instead ofchaiRatioUnits.ecschema.xmlfor ratio formatting examples over to ecschema-metadataWas able to verify by testing out a docs release off our testing environment, the extracted code showed up.