IDLE: add an AST browser
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Feature or enhancement
As a companion to the proposed token browser (#152941), visualizing the abstract syntax tree helps in learning how Python parses code and in understanding the structure that the compiler works from.
I propose an AST Browser added as an extension on the Tools menu (Shell and editor). It shows ast.parse of the current window as a hierarchical, fully expanded ttk.Treeview, each node labeled with its type and inline simple fields.
Interaction:
- Selecting a node highlights the corresponding source in the editor.
- The browser follows the editor: the editor selection (or cursor) selects the single smallest enclosing node.
- Scope is the editor selection if it parses, else the Shell's current input, else the whole window (a context-dependent fragment that does not parse reports the syntax error).
It shares the window skeleton and editor-sync mechanism with the token browser, so the two are best reviewed and landed together.
A PR will follow.
Linked PRs
- gh-152947
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先查看配套的 token browser issue #152941 和所链接的 PR gh-152947,因为此 issue 没有列出任何实现文件或测试。当 IDLE 的 Tools 菜单中的 AST Browser 能够解析适用的源代码、显示展开后的树、与编辑器同步选择,并报告无法解析片段的语法错误时,工作即完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- desktop, devtools
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100