Skip to content

Commit 0d32f28

Browse files
committed
gh-151950: Fix unresolved AST references in docs
Signed-off-by: jx2lee <dev.jaejun.lee.1991@gmail.com>
1 parent b954645 commit 0d32f28

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎Doc/library/ast.rst‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ Node classes
4848
module and re-exported in :mod:`!ast`.
4949

5050
There is one class defined for each left-hand side symbol in the abstract
51-
grammar (for example, :class:`ast.stmt` or :class:`ast.expr`). In addition,
51+
grammar (for example, :class:`!ast.stmt` or :class:`!ast.expr`). In addition,
5252
there is one class defined for each constructor on the right-hand side; these
5353
classes inherit from the classes for the left-hand side trees. For example,
54-
:class:`ast.BinOp` inherits from :class:`ast.expr`. For production rules
54+
:class:`ast.BinOp` inherits from :class:`!ast.expr`. For production rules
5555
with alternatives (aka "sums"), the left-hand side class is abstract: only
5656
instances of specific constructor nodes are ever created.
5757

@@ -65,7 +65,7 @@ Node classes
6565

6666
Each instance of a concrete class has one attribute for each child node,
6767
of the type as defined in the grammar. For example, :class:`ast.BinOp`
68-
instances have an attribute :attr:`left` of type :class:`ast.expr`.
68+
instances have an attribute :attr:`!left` of type :class:`!ast.expr`.
6969

7070
If these attributes are marked as optional in the grammar (using a
7171
question mark), the value might be ``None``. If the attributes can have
@@ -104,10 +104,11 @@ Node classes
104104
one can get the source segment of a one-line expression node using
105105
``source_line[node.col_offset : node.end_col_offset]``.
106106

107-
The constructor of a class :class:`ast.T` parses its arguments as follows:
107+
The constructors of AST node classes parse their arguments as follows:
108108

109109
* If there are positional arguments, there must be as many as there are items
110-
in :attr:`T._fields`; they will be assigned as attributes of these names.
110+
in :attr:`!_fields`; they will be assigned to attributes with
111+
the corresponding names.
111112
* If there are keyword arguments, they will set the attributes of the same
112113
names to the given values.
113114

@@ -2223,8 +2224,8 @@ Async and await
22232224

22242225
.. note::
22252226
When a string is parsed by :func:`ast.parse`, operator nodes (subclasses
2226-
of :class:`ast.operator`, :class:`ast.unaryop`, :class:`ast.cmpop`,
2227-
:class:`ast.boolop` and :class:`ast.expr_context`) on the returned tree
2227+
of :class:`!ast.operator`, :class:`!ast.unaryop`, :class:`!ast.cmpop`,
2228+
:class:`!ast.boolop` and :class:`!ast.expr_context`) on the returned tree
22282229
will be singletons. Changes to one will be reflected in all other
22292230
occurrences of the same value (for example, :class:`ast.Add`).
22302231

0 commit comments

Comments
 (0)