图书馆
- 作者仓库星标 3,367
- 许可证 MIT
- 作者仓库 atopile
- 领域
- 通用
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 94 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @atopile · MIT
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- macOS · Linux · Windows
- 运行环境要求
- Node.js · 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)
# 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
1. **New Component**: Create a new file `MyComponent.py` in `src/faebryk/library/`. Inherit from `Node` (or a more specific base).
2. **Naming Convention**: Class names should match the file basename (usually).
3. **Regenerate `_F.py`**: run `python tools/library/gen_F.py` and commit the updated `src/faebryk/library/_F.py`.
### Testing
- Library tests live under `test/library/` (including `test/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_part` trait.
- **Parameters**: Use `F.Parameters` to define physical properties like `resistance`, `capacitance`, etc.
- **Documentation**: Add docstrings to components explaining their ports and parameters.
章节与文件索引
按说明文件中的顺序排列。
相关文件
家属(呼叫站点)
核心概念
开发流程
测试
文件/命令 -> library · src/faebryk/library/ · src/faebryk/library/_F.py · import faebryk.library._F as F · tools/library/gen_F.py · src/faebryk/library/*.py · _F.py · F.<Name>
内容校验值 -> c9619f7188a4
当前原文的自动摘译,尚未人工审校。
相关文件
外观(自动生成):
src/faebryk/library/_F.py急切地导入和重新导出import faebryk.library._F as F模式的库模块/类型。这个文件就生成了;不要手动编辑它。生成器:tools/library/gen_F.py扫描src/faebryk/library/*.py,检测文件是否包含同名类,并写入_F.py。家属(呼叫站点)
用户代码:atopile 项目大量从
faebryk.library._F(别名为F)导入。编译器:编译器将ato内置函数映射到这些类。核心概念
特征与组件:使用特征来表示行为(它可以做什么,如
can_bridge),使用组件来表示物理事物(它是什么,如Resistor)。导出模型:_F.py是生成的“桶”模块;导入它是故意方便的,但可能是重量级的。开发流程
新建组件:在
src/faebryk/library/中创建一个新文件MyComponent.py。继承自Node(或更具体的基础)。命名约定:类名应与文件基名匹配(通常)。重新生成_F.py:运行python tools/library/gen_F.py并提交更新的src/faebryk/library/_F.py。测试
库测试位于
test/library/(包括test/library/nodes/)下。新模块的良好冒烟测试是:ato dev test --llm test/library/test_instance_library_modules.py -q