python / python/cpython

IDLE: add an AST browser

オープン
#152,942 コメント 8 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

stdlib topic-IDLE type-feature
主要言語
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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

この issue では実装ファイルやテストが指定されていないため、まず関連する token browser の issue #152941 と、リンクされている PR gh-152947 を確認してください。IDLE の Tools メニューにある AST Browser が対象のソースをパースし、展開されたツリーを表示し、エディターとの選択を同期し、パースできないフラグメントについて構文エラーを報告できれば、作業は完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
desktop, devtools
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。