Skip to content

Extend extraction code into ecschema-metadata and core-frontend#8976

Open
hl662 wants to merge 12 commits intomasterfrom
nam/extrapolate-extract
Open

Extend extraction code into ecschema-metadata and core-frontend#8976
hl662 wants to merge 12 commits intomasterfrom
nam/extrapolate-extract

Conversation

@hl662
Copy link
Contributor

@hl662 hl662 commented Feb 10, 2026

This pull request introduces betools extract into ecschema-metadata and core-frontend, incorporating them into rush docs workflow.

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-code folder, 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-code

Documentation workflow improvements:

  • Added a section in CONTRIBUTING.md describing how to extract documentation code snippets from test files, including instructions for marking extraction regions, updating scripts, and referencing snippets in markdown documentation.
  • Updated package.json scripts in core/ecschema-metadata and core/frontend to include an extract script for snippet extraction and to chain extraction with documentation generation.

Test file and methodology updates:

  • Moved and refactored example test files (Ratio.test.ts, UnitConversion.test.ts) to src/test/example-code, updated them to use vitest assertions instead of chai
  • Moved RatioUnits.ecschema.xml for ratio formatting examples over to ecschema-metadata

Was able to verify by testing out a docs release off our testing environment, the extracted code showed up.

@hl662 hl662 marked this pull request as ready for review February 11, 2026 20:15
Copy link
Contributor

@ben-polinsky ben-polinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@aruniverse aruniverse requested a review from Copilot February 11, 2026 20:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 extract scripts and chained them into each package’s docs script; updated frontend test setup to copy schema JSON assets.
  • Migrated/refactored example-code tests into package-local src/test/example-code and updated assertions to vitest.
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants