implementing-new-features
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNew Feature Implementation Guide
Streamlit新功能实现指南
Most features need implementation in three areas:
- Backend:
lib/streamlit/ - Frontend:
frontend/ - Protobufs:
proto/
New features should include:
- Python unit tests in
lib/tests - Vitest unit tests
- E2E Playwright tests in
e2e_playwright/
大多数功能需要在三个领域实现:
- 后端:
lib/streamlit/ - 前端:
frontend/ - Protobuf:
proto/
新功能应包含:
- 中的Python单元测试
lib/tests - Vitest单元测试
- 中的端到端Playwright测试
e2e_playwright/
Order of Implementation
实现顺序
-
Protobuf changes inthen run
proto/make protobuf- New elements: add to
proto/streamlit/proto/Element.proto
- New elements: add to
-
Backend in
lib/streamlit/- New elements: add to
lib/streamlit/__init__.py
- New elements: add to
-
Python unit tests in
lib/tests- Run:
uv run pytest lib/tests/streamlit/the_test_name.py - New elements: add to
lib/tests/streamlit/element_mocks.py
- Run:
-
Frontend in
frontend/- New elements: add to
frontend/lib/src/components/core/Block/ElementNodeRenderer.tsx
- New elements: add to
-
Vitest tests in
*.test.tsx- Run:
cd frontend && yarn vitest lib/src/components/elements/NewElement/NewElement.test.tsx
- Run:
-
E2E Playwright tests in
e2e_playwright/- Run:
make run-e2e-test e2e_playwright/name_of_the_test.py
- Run:
-
Autofix formatting and linting:
make autofix -
Verify the implementation:
make check
-
Protobuf修改在中进行,然后运行
proto/make protobuf- 新元素:添加到
proto/streamlit/proto/Element.proto
- 新元素:添加到
-
后端开发在中进行
lib/streamlit/- 新元素:添加到
lib/streamlit/__init__.py
- 新元素:添加到
-
Python单元测试在中编写
lib/tests- 运行命令:
uv run pytest lib/tests/streamlit/the_test_name.py - 新元素:添加到
lib/tests/streamlit/element_mocks.py
- 运行命令:
-
前端开发在中进行
frontend/- 新元素:添加到
frontend/lib/src/components/core/Block/ElementNodeRenderer.tsx
- 新元素:添加到
-
Vitest测试在文件中编写
*.test.tsx- 运行命令:
cd frontend && yarn vitest lib/src/components/elements/NewElement/NewElement.test.tsx
- 运行命令:
-
端到端Playwright测试在中编写
e2e_playwright/- 运行命令:
make run-e2e-test e2e_playwright/name_of_the_test.py
- 运行命令:
-
自动修复格式与代码规范:
make autofix -
验证实现:
make check