-
Notifications
You must be signed in to change notification settings - Fork 105
docs: add TI parts engine platform config guide #697
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
Open
techmannih
wants to merge
4
commits into
main
Choose a base branch
from
docs/ti-parts-engine-platform-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
109 changes: 109 additions & 0 deletions
109
docs/guides/running-tscircuit/using-ti-parts-engine.mdx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| --- | ||
| title: Using ti-parts-engine | ||
| description: Configure TI-backed part lookup and explicit `ti:` footprints through a custom platform config | ||
| sidebar_position: 5 | ||
| --- | ||
|
|
||
| `@tscircuit/ti-parts-engine` helps you provide TI-backed behavior through a | ||
| custom platform configuration in local development workflows. | ||
|
|
||
| This guide assumes `@tscircuit/ti-parts-engine` is available in your local | ||
| development environment. | ||
|
|
||
| ## Use TI as a Custom Parts Engine | ||
|
|
||
| If your local tooling loads a JS/TS platform config module, you can keep the TI | ||
| parts engine in a `tscircuit.config.ts`-style file: | ||
|
|
||
| ```ts | ||
| import { createTiPartsEngine } from "@tscircuit/ti-parts-engine" | ||
|
|
||
| export default { | ||
| platformConfig: { | ||
| partsEngine: createTiPartsEngine({ | ||
| // local CLI/dev usage only | ||
| partnerToken: process.env.PARTNER_TOKEN!, | ||
| }), | ||
| }, | ||
| } | ||
| ``` | ||
|
|
||
| This wires TI-backed automatic part lookup through `platform.partsEngine`. | ||
|
|
||
| :::info | ||
| Keep `PARTNER_TOKEN` in local development tooling only. Do not expose it to | ||
| browser clients or commit it to your repository. | ||
| ::: | ||
|
|
||
| ## Use Explicit `ti:` Footprint Strings | ||
|
|
||
| If you want to use explicit footprint strings such as | ||
| `footprint="ti:MSP430"`, you also need a TI footprint library mapping. The | ||
| easiest way to wire both pieces together is `createTiPlatformConfig(...)`: | ||
|
|
||
| ```ts | ||
| import { createTiPlatformConfig } from "@tscircuit/ti-parts-engine" | ||
|
|
||
| export default { | ||
| platformConfig: createTiPlatformConfig({ | ||
| partnerToken: process.env.PARTNER_TOKEN!, | ||
| }), | ||
| } | ||
| ``` | ||
|
|
||
| This configures: | ||
|
|
||
| - `partsEngine` for TI-backed part lookup | ||
| - `footprintLibraryMap.ti` for explicit `ti:` footprint strings | ||
|
|
||
| If you only provide `createTiPartsEngine(...)`, automatic TI part lookup works, | ||
| but the `ti:` footprint prefix is not added by itself. | ||
|
|
||
| ## Example User Project Files | ||
|
|
||
| If your local tooling supports a JS/TS platform config module, a minimal TI | ||
| footprint project can look like this: | ||
|
|
||
| `index.circuit.tsx` | ||
|
|
||
| ```tsx | ||
| export default () => ( | ||
| <board width="20mm" height="20mm"> | ||
| <chip name="U1" footprint="ti:MSP430" /> | ||
| </board> | ||
| ) | ||
| ``` | ||
|
|
||
| `tscircuit.config.ts` | ||
|
|
||
| ```ts | ||
| import { createTiPlatformConfig } from "@tscircuit/ti-parts-engine" | ||
|
|
||
| export default { | ||
| platformConfig: createTiPlatformConfig({ | ||
| // local CLI/dev usage only | ||
| partnerToken: process.env.PARTNER_TOKEN!, | ||
| }), | ||
| } | ||
| ``` | ||
|
|
||
| This is a local CLI/dev style workflow. Do not expose a real `PARTNER_TOKEN` | ||
| to browser clients. | ||
|
|
||
| ## Programmatic Usage | ||
|
|
||
| You can also pass the same `createTiPlatformConfig(...)` result directly when | ||
| creating a runner or root circuit: | ||
|
|
||
| ```ts | ||
| import { RootCircuit } from "@tscircuit/core" | ||
|
|
||
| const circuit = new RootCircuit({ | ||
| platform: createTiPlatformConfig({ | ||
| partnerToken: process.env.PARTNER_TOKEN!, | ||
| }), | ||
| }) | ||
| ``` | ||
|
|
||
| For more background on platform customization, see | ||
| [Platform Configuration](./platform-configuration). |
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
Oops, something went wrong.
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.
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’m not sure we should call out TI specifically in the general platform configuration guide