Library 创建助手
- 作者仓库星标 3,367
- 许可证 MIT
- 作者仓库 atopile
Library Module
The library module (located in src/faebryk/library/) contains the collection of reusable components, traits, and interfaces that form the "standard library" of the hardware design language.
Quick Start
import faebryk.core.faebrykpy as fbrk
import faebryk.core.graph as graph
import faebryk.library._F as F
g = graph.GraphView.create()
tg = fbrk.TypeGraph.create(g=g)
resistor = F.Resistor.bind_typegraph(tg=tg).create_instance(g=g)
Relevant Files
- Facade (auto-generated):
src/faebryk/library/_F.py- Eagerly imports and re-exports library modules/types for the
import faebryk.library._F as Fpattern. - This file is generated; do not hand-edit it.
- Eagerly imports and re-exports library modules/types for the
- Generator:
tools/library/gen_F.py- Scans
src/faebryk/library/*.py, detects whether the file contains a same-named class, and writes_F.py. - Orders exports via a topological sort of
F.<Name>references to avoid import-order cycles.
- Scans
- Components:
src/faebryk/library/contains specific component definitions (e.g.Resistor.py,Capacitor.py,LED.py). - Traits/Interfaces: Also contains trait definitions (e.g.
can_bridge.py,is_power.py).
Dependants (Call Sites)
- User Code: atopile projects heavily import from
faebryk.library._F(aliased asF). - Compiler: The compiler maps
atobuilt-ins to these classes.
How to Work With / Develop / Test
Core Concepts
- Traits vs Components: Use Traits for behavior (what it can do like
can_bridge) and Components for physical things (what it is likeResistor). - Export model:
_F.pyis a generated “barrel” module; importing it is intentionally convenient but can be heavyweight.
Development Workflow
- New Component: Create a new file
MyComponent.pyinsrc/faebryk/library/. Inherit fromNode(or a more specific base). - Naming Convention: Class names should match the file basename (usually).
- Regenerate
_F.py: runpython tools/library/gen_F.pyand commit the updatedsrc/faebryk/library/_F.py.
Testing
- Library tests live under
test/library/(includingtest/library/nodes/). - A good smoke test for new modules is:
ato dev test --llm test/library/test_instance_library_modules.py -q
Best Practices
- Atomic Parts: Mark leaf components (specifically verified part numbers) with the
is_atomic_parttrait. - Parameters: Use
F.Parametersto define physical properties likeresistance,capacitance, etc. - Documentation: Add docstrings to components explaining their ports and parameters.
- 流狐分类
- 通用
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 94 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @atopile · MIT
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 需简单配置
- 是否需要外部 API Key
- 未发现要求
- 检测到的系统要求
- macOS · Linux · Windows
- 底层运行要求
- Node.js · Python
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 检测到的网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 Quick Start
Quick Start
Development Workflow
New Component: Create a new file MyComponent.py in src/faebryk/library/. Inherit from Node (or a more specific base). Naming Convention: Class names should match the file basename (usually). Regenerate F.py: run python tools/library/genF.py and commit the…
# Library Module
The `library` module (located in `src/faebryk/library/`) contains the collection of reusable components, traits, and interfaces that form the "standard library" of the hardware design language.
## Quick Start
```python
import faebryk.core.faebrykpy as fbrk
import faebryk.core.graph as graph
import faebryk.library._F as F
g = graph.GraphView.create()
tg = fbrk.TypeGraph.create(g=g)
resistor = F.Resistor.bind_typegraph(tg=tg).create_instance(g=g)
```
## Relevant Files
- **Facade (auto-generated)**: `src/faebryk/library/_F.py`
- Eagerly imports and re-exports library modules/types for the `import faebryk.library._F as F` pattern.
- This file is generated; do not hand-edit it.
- **Generator**: `tools/library/gen_F.py`
- Scans `src/faebryk/library/*.py`, detects whether the file contains a same-named class, and writes `_F.py`.
- Orders exports via a topological sort of `F.<Name>` references to avoid import-order cycles.
- **Components**: `src/faebryk/library/` contains specific component definitions (e.g. `Resistor.py`, `Capacitor.py`, `LED.py`).
- **Traits/Interfaces**: Also contains trait definitions (e.g. `can_bridge.py`, `is_power.py`).
## Dependants (Call Sites)
- **User Code**: atopile projects heavily import from `faebryk.library._F` (aliased as `F`).
- **Compiler**: The compiler maps `ato` built-ins to these classes.
## How to Work With / Develop / Test
### Core Concepts
- **Traits vs Components**: Use Traits for behavior (what it *can do* like `can_bridge`) and Components for physical things (what it *is* like `Resistor`).
- **Export model**: `_F.py` is a generated “barrel” module; importing it is intentionally convenient but can be heavyweight.
### Development Workflow
… 证据边界与执行链路
作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> Quick Start → Relevant Files → Dependants (Call Sites) → How to Work With / Develop / Test → Core Concepts → Development Workflow
要点 -> Facade (auto-generated) · Generator · Components · Traits/Interfaces · User Code · Compiler · Traits vs Components · Export model
文件/命令 -> library · src/faebryk/library/ · src/faebryk/library/F.py · import faebryk.library.F as F · tools/library/genF.py · src/faebryk/library/.py · F.py · F.<Name>
内容 SHA-256 -> c9619f7188a4
方法与流程
适用与边界
原文中的明确线索
library、src/faebryk/library/、src/faebryk/library/F.py、import faebryk.library.F as F、tools/library/genF.py、src/faebryk/library/.py、F.py、F.<Name>