Skip to content

Commit 9b7dfec

Browse files
committed
chore: release v0.1.0 engine update and pypi workflow
1 parent c850d68 commit 9b7dfec

39 files changed

Lines changed: 1471 additions & 669 deletions

.github/workflows/publish-pypi.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build-n-publish:
10+
name: Build and publish Typedown to PyPI
11+
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write # Mandatory for trusted publishing
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v3
21+
with:
22+
enable-cache: true
23+
24+
- name: Set up Python
25+
run: uv python install
26+
27+
- name: Run Tests
28+
run: |
29+
uv sync
30+
uv run td test tests/integration/cases
31+
32+
- name: Build distribution
33+
run: uv build
34+
35+
- name: Publish to PyPI
36+
uses: pypa/gh-action-pypi-publish@release/v1
37+
with:
38+
skip-existing: true

DEMO_SCRIPT.md

Lines changed: 0 additions & 103 deletions
This file was deleted.

dev-docs/logs/2025-12-20.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# 2025-12-20 任务验收日志
2+
3+
## 验收对象
4+
5+
- `_strategy/todos/archive/03-核心重构-编译器驱动.md`
6+
- `_strategy/todos/04-llvm-架构迁移.md`
7+
8+
## 验收结果
9+
10+
### 任务 03: 核心重构 (编译器前端与链接器)
11+
12+
**状态**: ✅ 已完成 (已归档)
13+
14+
**验证项**:
15+
1. **Config**: `typedown/core/config.py` 已实现 `typedown.toml` 的 Schema 定义与加载逻辑。
16+
2. **Resolver**: `typedown/core/resolver.py` 已实现物理路径映射与自动探测。
17+
3. **Linker**: `typedown/core/compiler_context.py` 中的 `TypedownMetaFinder` 实现了基于 `sys.meta_path` 的 Import Hook。
18+
4. **CLI**: `typedown/commands/test.py` 已更新以使用新的编译器上下文。
19+
20+
### 任务 04: 迁移至 LLVM 编译器架构
21+
22+
**状态**: 🔄 进行中
23+
24+
**进度详情**:
25+
- [x] **1. 符号表构建 (Symbols)**: `MistuneParser` (`typedown/core/mistune_parser.py`) 正确提取 ImportStmt 并构建隔离命名空间。
26+
- [ ] **2. 实体校验 (Entities)**: **[待办]** 尚未实现基于 Entity 类型的 Pydantic 类动态匹配与校验逻辑。
27+
- [x] **3. 链接解析 (Linkage)**: `Evaluator` (`typedown/core/evaluator.py`) 与 `DependencyGraph` (`typedown/core/graph.py`) 已实现全局引用扫描与悬空引用检查。
28+
- [x] **4. 后端执行 (Pytest Backend)**: `typedown/commands/test.py` 实现了将 spec 块转化为临时 pytest 文件并注入 `compiler` fixture 的逻辑。
29+
30+
## 下一步计划
31+
32+
集中精力完成 **Task 04 Item 2: 实体校验 (Entities)**
33+
目标是实现 `Compiler._link``Compiler._validate` 阶段中对 `entity:<Type>` 的实例化与校验,确保所有定义的实体都符合其 `model` 定义的约束。

pyproject.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ version = "0.1.0"
44
description = "Progressive Formalization for Markdown using Pydantic and Pytest"
55
readme = "README.md"
66
requires-python = ">=3.10"
7+
license = "MIT"
8+
keywords = ["markdown", "pydantic", "formalization", "documentation", "spec", "data-entry"]
9+
classifiers = [
10+
"Development Status :: 3 - Alpha",
11+
"Intended Audience :: Developers",
12+
"License :: OSI Approved :: MIT License",
13+
"Programming Language :: Python :: 3",
14+
"Programming Language :: Python :: 3.10",
15+
"Programming Language :: Python :: 3.11",
16+
"Programming Language :: Python :: 3.12",
17+
"Topic :: Documentation",
18+
"Topic :: Software Development :: Libraries :: Python Modules",
19+
]
720
dependencies = [
821
"typer>=0.9.0",
922
"pydantic>=2.0.0",
@@ -13,8 +26,14 @@ dependencies = [
1326
"rich>=13.0.0",
1427
"tomli>=2.3.0",
1528
"mistune>=3.1.4",
29+
"pyyaml>=6.0.0",
1630
]
1731

32+
[project.urls]
33+
Homepage = "https://typedown.io"
34+
Repository = "https://github.com/IndenScale/Typedown"
35+
Documentation = "https://typedown.io/docs"
36+
1837
[project.optional-dependencies]
1938
server = [
2039
"pygls>=1.0.0",

specs/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
- [000-concept.md](meta/000-concept.md): Core concepts and philosophy.
66

77
## RFCs (Request for Comments)
8-
* [001-syntax.md](rfc/001-syntax.md): Basic syntax and extensions.
9-
* [002-evolution.md](rfc/002-evolution.md): Data evolution mechanisms.
10-
* [003-structure.md](rfc/003-structure.md): Project directory structure.
11-
* [004-import.md](rfc/004-import.md): Import and configuration inheritance.
12-
* [005-reference.md](rfc/005-reference.md): Reference and linking mechanisms.
13-
* [006-testing.md](rfc/006-testing.md): Testing and specification validation mechanisms.
8+
9+
- [001-syntax.md](rfc/001-syntax.md): Basic syntax and extensions.
10+
- [002-evolution.md](rfc/002-evolution.md): Data evolution mechanisms.
11+
- [003-structure.md](rfc/003-structure.md): Project directory structure.
12+
- [004-import.md](rfc/004-import.md): Import and configuration inheritance.
13+
- [005-reference.md](rfc/005-reference.md): Reference and linking mechanisms.
14+
- [006-testing.md](rfc/006-testing.md): Testing and specification validation mechanisms.
1415

1516
## Architecture
1617

17-
- [001-data-model.md](architecture/001-data-model.md): Internal compiler data models.
18+
- [001-ir.md](architecture/001-ir.md): Internal compiler representation (IR) and symbols.

specs/architecture/001-data-model.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

specs/architecture/001-ir.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Typedown Intermediate Representation (IR)
2+
3+
The Typedown IR is a set of structured data models representing the semantic content of a project after parsing and link-resolution. It is the language-neutral representation used between the **Frontend (Parser)** and the **Backend (Spec Runner/Validator)**.
4+
5+
## 1. Node Hierarchy
6+
7+
All IR nodes inherit from a base `Node` class.
8+
9+
### 1.1 Base Node
10+
11+
| Field | Type | Description |
12+
| :--------- | :------------------------- | :------------------------------------------------ |
13+
| `id` | `Optional[str]` | The unique identifier for this symbol. |
14+
| `location` | `Optional[SourceLocation]` | File path and line range for diagnostics and LSP. |
15+
16+
## 2. Semantic Nodes
17+
18+
### 2.1 EntityDef
19+
20+
Represents a data instance.
21+
22+
- **Payload**: `data: Dict[str, Any]` (The YAML-parsed content).
23+
- **Type**: `type_name: str`.
24+
25+
### 2.2 ModelDef
26+
27+
Represents a Pydantic/Python model block.
28+
29+
- **Payload**: `code: str`.
30+
31+
### 2.3 SpecDef
32+
33+
Represents a testing/validation block.
34+
35+
- **Payload**: `code: str` (Python) or `data: Dict` (YAML).
36+
- **Name**: `name: str`.
37+
38+
### 2.4 ImportStmt
39+
40+
Represents a virtual or physical import.
41+
42+
- **Source**: `source: str` (e.g., `@lib.math`).
43+
- **Names**: `List[str]` (Symbols imported).
44+
45+
## 3. Document
46+
47+
A `Document` is the root container for a single physical file.
48+
49+
- **Path**: `Path`.
50+
- **Collections**: `imports`, `models`, `entities`, `specs`, `references`.
51+
52+
## 4. Symbol Table
53+
54+
The **Compiler** maintains a global Symbol Table (Map of `ID -> Node`).
55+
56+
- All `EntityDef`, `ModelDef`, and `SpecDef` nodes with an `id` are registered here.
57+
- The `Evaluator` uses this table to resolve `[[ID]]` queries.

specs/rfc/001-syntax.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,41 @@ Typedown uses standard Markdown syntax and extends its functionality through spe
66

77
To support "Progressive Formalization," Typedown allows defining data models directly within Markdown documents. This is typically used during the initial or testing phases (Inception Phase).
88

9-
Use the `model` tag on code blocks. The content supports standard Python syntax but is enhanced with pre-loaded common type definitions.
9+
Use the `model` tag on code blocks. The content supports standard Python syntax. You can optionally provide an `id`.
1010

1111
````markdown
12-
```model
13-
# No need to manually import BaseModel, Field, List, etc.
14-
class Address(BaseModel):
15-
city: str
16-
zip_code: str
17-
12+
```model id=UserAccount
1813
class User(BaseModel):
1914
name: str
2015
age: int = Field(..., ge=0)
21-
role: str = "guest"
22-
address: Optional[Address] = None
2316
```
2417
````
2518

2619
### Features
2720

28-
1. **Multi-Class Definition**: You can define multiple related classes within a single `model` block.
29-
2. **Auto-imports**: To reduce boilerplate, the execution environment pre-loads the following symbols by default:
30-
- **Pydantic**: `BaseModel`, `Field`, `validator`, `model_validator`, `PrivateAttr`
31-
- **Typing**: `List`, `Dict`, `Optional`, `Union`, `Any`, `ClassVar`
32-
- **Enum**: `Enum`
33-
3. **Override Mechanism**: Classes defined here are automatically registered to the current document's context. If a name conflicts with an existing model, the new definition overrides the old one.
34-
35-
## 2. Entity Instantiation
21+
1. **Multi-Class Definition**: You can define multiple related classes within a single `model` block.
22+
2. **Auto-imports**: To reduce boilerplate, the execution environment pre-loads the following symbols by default:
23+
- **Pydantic**: `BaseModel`, `Field`, `validator`, `model_validator`, `PrivateAttr`
24+
- **Typing**: `List`, `Dict`, `Optional`, `Union`, `Any`, `ClassVar`
25+
- **Enum**: `Enum`
26+
3. **Override Mechanism**: Classes defined here are automatically registered to the current document's context. If a name conflicts with an existing model, the new definition overrides the old one.
3627

37-
Use the `entity:<ClassName>` tag on code blocks to declare an instance of that class (data).
28+
Use the `entity:<ClassName>` tag. You can specify an `id` in the header or within the body.
3829

3930
````markdown
40-
# This is an Entity code block, instantiating the User class above
31+
# ID specified in header
4132

42-
```entity:User
33+
```entity:User id=alice
4334
name: "Alice"
4435
age: 30
45-
role: "admin"
36+
```
37+
38+
# ID specified in body (YAML)
39+
40+
```entity:User
41+
id: "bob"
42+
name: "Bob"
43+
age: 25
4644
```
4745
````
4846

0 commit comments

Comments
 (0)