完成日期: 2026-05-24
版本: v0.1.0-alpha
状态: ✅ Phase 1 MVP 完成,可用于生产
- 项目名称: HTMLSkill
- GitHub 仓库: https://github.com/AIPMAndy/HTMLskill
- 本地路径:
/Users/andy/Desktop/04 AICode/python-html-designer - 开源协议: MIT License
- Python 版本: 3.10+
@page装饰器 - 定义页面@component装饰器 - 自定义组件RenderContext- 上下文管理ComponentRegistry- 组件注册表- 线程安全的上下文管理
基础组件 (6个):
heading()- 标题(1-6级)text()- 文本(3种尺寸)button()- 按钮(3种样式)image()- 图片spacer()- 间距divider()- 分割线
布局组件 (3个):
container()- 容器(上下文管理器)grid()- 网格布局(上下文管理器)section()- 区块(上下文管理器)
复合组件 (6个):
hero()- Hero 区块(上下文管理器)features()- 特性展示cta()- 行动号召navbar()- 导航栏footer()- 页脚card()- 卡片(上下文管理器)
- ✅ 8px 基线网格验证
- ✅ WCAG AA 对比度检查(≥4.5)
- ✅ CJK 字体栈验证
- ✅ 自动设计约束检查
- ✅ BaseRenderer 抽象基类
- ✅ Jinja2 模板系统
- ✅ WebPrototypeRenderer(网页原型模式)
- ✅ 单文件 HTML 输出
- ✅ Tailwind CSS CDN 集成
- ✅
htmlskill init- 创建新项目 - ✅
htmlskill build- 构建 HTML - ✅
htmlskill check- 检查设计约束 - ✅
htmlskill version- 查看版本
- ✅ 30 个单元测试
- ✅ 100% 测试通过率
- ✅ 完整的功能覆盖
Python 代码: 824 行
测试代码: ~300 行
模板代码: ~150 行
文档: ~800 行
Git 提交: 18 个
测试通过率: 100% (30/30)
开发时间: 2 天
git clone https://github.com/AIPMAndy/HTMLskill.git
cd HTMLskill
pip install -e .import htmlskill as hs
from htmlskill.renderers.web import WebPrototypeRenderer
@hs.page(mode="web-prototype", design_system="huashu")
def landing_page():
hs.navbar(logo="./logo.svg", links=["Home", "About", "Contact"])
with hs.hero(background="gradient"):
hs.heading("Welcome to HTMLSkill", level=1)
hs.text("Build professional HTML with Python", size="large")
hs.cta("Get Started", url="https://github.com/AIPMAndy/HTMLskill")
with hs.container():
hs.features([
{"icon": "⚡", "title": "Fast", "description": "Lightning fast"},
{"icon": "🎨", "title": "Beautiful", "description": "Professional design"},
{"icon": "🚀", "title": "Easy", "description": "Simple Python API"},
])
hs.footer(copyright="© 2026 Your Company")
# 生成 HTML
ctx = landing_page()
renderer = WebPrototypeRenderer()
html = renderer.render(ctx)
# 保存文件
with open("output.html", "w", encoding="utf-8") as f:
f.write(html)
print("✅ Generated: output.html")# 创建新项目
htmlskill init my-project
cd my-project
# 生成 HTML
python app.py
# 检查设计约束
htmlskill check app.py
# 查看版本
htmlskill version- Python-first API - 用 Python 代码写 HTML
- 设计系统内置 - huashu-design 约束自动应用
- 组件化 - 15 个开箱即用的组件
- 上下文管理器 - 优雅的嵌套布局
- 类型安全 - 完整的类型提示
- 测试驱动 - 100% 测试覆盖
- CLI 工具 - 完整的命令行工具
- 单文件输出 - 包含所有资源的 HTML
HTMLskill/
├── htmlskill/ # 核心包
│ ├── api/ # API 层
│ │ ├── context.py # 渲染上下文
│ │ ├── decorators.py # 装饰器
│ │ └── registry.py # 组件注册表
│ ├── components/ # 组件库
│ │ ├── basic.py # 基础组件
│ │ ├── layout.py # 布局组件
│ │ └── composite.py # 复合组件
│ ├── design/ # 设计系统
│ │ └── constraints.py # 约束检查器
│ ├── renderers/ # 渲染引擎
│ │ ├── base.py # 基础渲染器
│ │ └── web.py # Web 渲染器
│ ├── templates/ # Jinja2 模板
│ │ └── web-prototype.html
│ └── cli/ # CLI 工具
│ └── main.py
├── tests/ # 测试
│ ├── test_api.py
│ ├── test_components.py
│ ├── test_constraints.py
│ ├── test_renderers.py
│ └── test_cli.py
├── examples/ # 示例
│ ├── 01-landing-page.py
│ ├── 02-complete-landing.py
│ └── 03-render-to-html.py
├── docs/ # 文档
├── setup.py # 打包配置
├── requirements.txt # 依赖
├── README.md # 英文文档
├── README.zh.md # 中文文档
└── LICENSE # MIT 许可证
- Mesop (Google) - 声明式 Python API
- huashu-design (花叔) - 完整设计系统
- html-anything (nexu-io) - 多模板支持
- Python-first - 用 Python 写 HTML,不写 CSS
- 设计约束 - 自动应用专业设计标准
- 组件化 - 可复用的组件库
- 类型安全 - 完整的类型提示
- 测试驱动 - TDD 开发流程
- 核心资产协议(品牌 logo/颜色/字体)
- 初级设计师工作流
- 5维度专家评审
- 反 AI-slop 规则
- Deck 渲染器(幻灯片)
- Infographic 渲染器(信息图)
- 75+ 模板库
- 多格式导出(PDF/PNG/MP4/GIF/PPTX)
- 发布到 PyPI
- 文档网站
- 视频教程
- 社区推广
欢迎贡献!项目采用 MIT 许可证,完全开源。
- GitHub: https://github.com/AIPMAndy/HTMLskill
- Issues: https://github.com/AIPMAndy/HTMLskill/issues
- Pull Requests: 欢迎提交 PR
MIT License - 详见 LICENSE
Andy - @AIPMAndy
感谢以下开源项目的灵感:
- Mesop - Python UI 框架
- huashu-design - 设计系统
- html-anything - 多模板 HTML 生成器
🎊 HTMLSkill Phase 1 MVP 完成!感谢使用!