Skip to content

Commit 2ceb261

Browse files
authored
docs: clean stale pages and update coding style (#1056)
1 parent f67d32a commit 2ceb261

8 files changed

Lines changed: 96 additions & 154 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Notes:
5858

5959
Primary docs:
6060
- `docs/source/dev_quickstart.rst`
61-
- `docs/source/coding_style.rst`
61+
- `docs/source/dev_best_practice.rst` (read on demand for coding style,
62+
UI design, runtime debugging, and recent engineering practices)
6263
- `docs/source/contributing.rst`
6364
- `docs/source/arch.rst`
6465

@@ -94,44 +95,3 @@ Responsive layout rule:
9495
- Let a page own its responsive reflow logic based on its own available width.
9596
- Avoid parent-coupled resize orchestration unless there is a proven structural
9697
need.
97-
98-
## 6) Workflow
99-
100-
Keep a lightweight todo list for the current task:
101-
- Update it before/after each meaningful step.
102-
- Mark items done as soon as they are completed.
103-
- Save it under `.tasks/` (for example, `.tasks/todo.md`).
104-
105-
Keep a short proposal note for design changes:
106-
- Capture the intended approach, tradeoffs, and assumptions.
107-
- Use it to confirm alignment before coding.
108-
- Save it under `.tasks/` (for example, `.tasks/proposal.md`).
109-
110-
Minimal templates:
111-
112-
Todo:
113-
- [ ] Step 1
114-
- [ ] Step 2
115-
116-
Proposal:
117-
- Approach: ...
118-
- Tradeoffs: ...
119-
- Assumptions: ...
120-
121-
## 7) Recent Engineering Notes
122-
123-
- Prefer semantic API names over scenario-specific ones:
124-
- Good: `show_cover_with_source(artwork, source, uid)`
125-
- Avoid: names that encode one caller context (for example `show_current_song_*`)
126-
- For cover/image loading, keep a clear boundary:
127-
- Data/adapter layer should convert `(url, source)` into `Media`.
128-
- Widget layer should consume `Media` directly (`show_cover_media`) whenever possible.
129-
- Avoid broad fallback branches that hide failures. If input contract is wrong,
130-
fail early with explicit type/shape checks.
131-
- Before removing helper functions, run an explicit usage check (`rg`) and keep
132-
shared helpers when they are still used in multiple GUI paths.
133-
- For GUI-heavy changes, run focused GUI/library test sets first; if full Qt/mpv
134-
pytest is unstable in local environment, report it explicitly in PR notes.
135-
- When creating/updating PR descriptions via `gh`, prefer `--body-file` or GraphQL
136-
`updatePullRequest` with a file-loaded body; avoid inline escaped `\n` strings
137-
that may show up literally in the PR description.

docs/source/coding_style.rst

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

docs/source/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ FeelUOwn 这个项目从 2015 年初开发到现在,已经 4 年有余,
5959
和大家同步并讨论,之后再动手开发。
6060

6161
如果需要进行修改代码(包括文档等),可以参考 :doc:`dev_quickstart` ,
62-
代码风格请参考 :doc:`coding_style` ,一些 FeelUOwn
62+
开发最佳实践请参考 :doc:`dev_best_practice` ,一些 FeelUOwn
6363
架构设计相关的决策,可以参考 :doc:`arch` 和 :doc:`api` 等文档。
6464

6565
最后值得一提的是,我们有一个开发者/用户交流群(邀请链接在 README_ 中),大家可以加入群里,

docs/source/dev_best_practice.rst

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
开发最佳实践
2+
============
3+
4+
5+
代码风格
6+
--------
7+
8+
注释
9+
~~~~
10+
11+
- 注释统一用英文(老的中文注释应该逐渐更改)
12+
- docstring 使用 `Sphinx docstring format`_
13+
- FIXME, TODO, and HELP
14+
15+
- FIXME: 开发者明确知道某个地方代码不优雅
16+
- HELP: 开发者写了一段自己不太理解,但是可以正确工作的代码
17+
- TODO: 一些可以以后完成的事情
18+
- 暂时不推荐使用 NOTE 标记
19+
20+
测试
21+
~~~~
22+
23+
- feeluown 包相关代码都应该添加相应测试。
24+
- GUI 改动优先运行 focused GUI/library 测试。如果本地环境中完整 Qt/mpv pytest
25+
不稳定,应在 PR 说明中明确记录。
26+
27+
错误处理
28+
~~~~~~~~
29+
30+
- Qt 中同步调用资源提供方接口时,都应该处理 Exception 异常,否则应用可能会 crash。
31+
- 避免用宽泛的 fallback 分支隐藏失败。如果输入契约不符合预期,应通过明确的
32+
类型或结构检查尽早失败。
33+
34+
特殊风格
35+
~~~~~~~~
36+
37+
- 标记了 alpha 的函数和类,它们的设计都是不确定的,外部应该尽少依赖。
38+
39+
40+
~~
41+
42+
- Qt Widget 的子类的 UI 相关设置初始化应该放在 ``_setup_ui`` 函数中。
43+
- 信号的 slot 方法应该设为 protected 方法。
44+
- 类的 public 方法放在类的前面,protected 和 private 方法放在类的最后面,
45+
``_setup_ui`` 函数除外。
46+
- QWidget 子类最好不要有 async 方法,因为目前无法很好的为它编写相关单元测试。
47+
48+
49+
UI 设计
50+
-------
51+
52+
- 设计 UI 时要考虑 Linux、Windows、macOS 的兼容性。颜色应尽量来自系统
53+
调色板,比如 ``QPalette`` 的 ``Window``、``Base``、``Text``、
54+
``WindowText``、``Highlight`` 等角色,而不是硬编码某一种颜色。
55+
56+
57+
运行时调试
58+
----------
59+
60+
- 可以用 ``fuo exec`` 连接正在运行的应用,执行 Python 代码来调试界面状态、
61+
构造测试场景或读取对象属性。启动应用时不要使用 ``-ns``,因为它表示
62+
no-server,``fuo exec`` 将无法连接到应用。
63+
- ``fuo exec`` 支持从 stdin 接收多行 Python 代码。调试复杂流程时优先使用
64+
这种方式,避免在 shell 参数中处理繁琐的引号和转义。示例::
65+
66+
# 在 tmux 中启动 GUI,并打开 server
67+
uv run fuo -vv
68+
69+
# 在另一个 shell 中注入多行 Python 代码
70+
uv run fuo exec <<'EOF'
71+
print(type(app).__name__)
72+
print(app.ui)
73+
EOF
74+
75+
76+
工程经验
77+
--------
78+
79+
- API 命名应优先表达语义,而不是绑定某个调用场景。例如
80+
``show_cover_with_source(artwork, source, uid)`` 比编码某个具体 caller
81+
上下文的名字更清晰。
82+
- 封面和图片加载应保持清晰边界:数据/适配层负责把 ``(url, source)`` 转换为
83+
``Media``,widget 层尽量直接消费 ``Media``。
84+
- 删除 helper 函数前,先用 ``rg`` 明确检查使用点。如果它仍被多个 GUI 路径共享,
85+
应保留这个 helper。
86+
- 通过 ``gh`` 创建或更新 PR 描述时,优先使用 ``--body-file``,或使用 GraphQL
87+
``updatePullRequest`` 并从文件读取正文;避免在命令行里内联转义 ``\n``,
88+
否则 PR 描述可能出现字面量 ``\n``。
89+
90+
91+
.. _Sphinx docstring format: https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html#the-sphinx-docstring-format

docs/source/faq.rst

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

docs/source/index.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ FeelUOwn 是一个用户友好、可玩性强的播放器
1919
quickstart
2020
features
2121
fuorc
22-
roadmap
23-
faq
2422

2523

2624
.. toctree::
@@ -35,5 +33,5 @@ FeelUOwn 是一个用户友好、可玩性强的播放器
3533
glossary
3634
research
3735
philosophy
38-
coding_style
36+
dev_best_practice
3937
contributing

docs/source/quickstart.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Ubuntu
7272
pipx inject feeluown pyopengl
7373

7474
# 运行 feeluown -h 来测试安装是否成功
75-
# 如果提示 Commmand Not Found,请查看文档「常见问题」部分
75+
# 如果提示 Command Not Found,请检查 pipx 的 PATH 配置
7676
feeluown -h
7777

7878
# 生成桌面图标

docs/source/roadmap.rst

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

0 commit comments

Comments
 (0)