python / python/cpython

IDLE: add an AST browser

Ouverte
#152,942 8 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

stdlib topic-IDLE type-feature
Langage dominant
Python
Étoiles
77.2k
Forks
35.9k
Métriques de merge des PR
Métriques de PR en attente

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par examiner l’issue compagnon du navigateur de tokens #152941 et la PR associée gh-152947, puisque cette issue ne nomme aucun fichier d’implémentation ni aucun test. Le travail est terminé lorsqu’un AST Browser du menu Tools d’IDLE analyse le code source concerné, affiche l’arbre développé, synchronise les sélections avec l’éditeur et signale les erreurs de syntaxe pour les fragments impossibles à analyser.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
desktop, devtools
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.