@@ -131,6 +131,9 @@ class Expr extends Expr_, AstNode {
131131/** An attribute expression, such as `value.attr` */
132132class Attribute extends Attribute_ {
133133
134+ /* Special comment for documentation generation */
135+ /* syntax: Expr.name */
136+
134137 override Expr getASubExpression ( ) {
135138 result = this .getObject ( )
136139 }
@@ -160,6 +163,8 @@ class Attribute extends Attribute_ {
160163/** A subscript expression, such as `value[slice]` */
161164class Subscript extends Subscript_ {
162165
166+ /* syntax: Expr[Expr] */
167+
163168 override Expr getASubExpression ( ) {
164169 result = this .getIndex ( )
165170 or
@@ -176,6 +181,8 @@ class Subscript extends Subscript_ {
176181/** A call expression, such as `func(...)` */
177182class Call extends Call_ {
178183
184+ /* syntax: Expr(...) */
185+
179186 override Expr getASubExpression ( ) {
180187 result = this .getAPositionalArg ( ) or
181188 result = this .getAKeyword ( ) .getValue ( ) or
@@ -268,6 +275,8 @@ class Call extends Call_ {
268275/** A conditional expression such as, `body if test else orelse` */
269276class IfExp extends IfExp_ {
270277
278+ /* syntax: Expr if Expr else Expr */
279+
271280 override Expr getASubExpression ( ) {
272281 result = this .getTest ( ) or result = this .getBody ( ) or result = this .getOrelse ( )
273282 }
@@ -278,6 +287,8 @@ class IfExp extends IfExp_ {
278287/** A starred expression, such as the `*rest` in the assignment `first, *rest = seq` */
279288class Starred extends Starred_ {
280289
290+ /* syntax: *Expr */
291+
281292 override Expr getASubExpression ( ) {
282293 result = this .getValue ( )
283294 }
@@ -288,6 +299,8 @@ class Starred extends Starred_ {
288299/** A yield expression, such as `yield value` */
289300class Yield extends Yield_ {
290301
302+ /* syntax: yield Expr */
303+
291304 override Expr getASubExpression ( ) {
292305 result = this .getValue ( )
293306 }
@@ -301,6 +314,8 @@ class Yield extends Yield_ {
301314/** A yield expression, such as `yield from value` */
302315class YieldFrom extends YieldFrom_ {
303316
317+ /* syntax: yield from Expr */
318+
304319 override Expr getASubExpression ( ) {
305320 result = this .getValue ( )
306321 }
@@ -314,6 +329,8 @@ class YieldFrom extends YieldFrom_ {
314329/** A repr (backticks) expression, such as `` `value` `` */
315330class Repr extends Repr_ {
316331
332+ /* syntax: `Expr` */
333+
317334 override Expr getASubExpression ( ) {
318335 result = this .getValue ( )
319336 }
@@ -330,6 +347,8 @@ class Repr extends Repr_ {
330347 `"hello"` are treated as Bytes for Python2, but Unicode for Python3. */
331348class Bytes extends StrConst {
332349
350+ /* syntax: b"hello" */
351+
333352 Bytes ( ) {
334353 not this .isUnicode ( )
335354 }
@@ -355,6 +374,8 @@ class Bytes extends StrConst {
355374/** An ellipsis expression, such as `...` */
356375class Ellipsis extends Ellipsis_ {
357376
377+ /* syntax: ... */
378+
358379 override Expr getASubExpression ( ) {
359380 none ( )
360381 }
@@ -394,6 +415,8 @@ abstract class Num extends Num_, ImmutableLiteral {
394415/** An integer numeric constant, such as `7` or `0x9` */
395416class IntegerLiteral extends Num {
396417
418+ /* syntax: 4 */
419+
397420 IntegerLiteral ( ) {
398421 not this instanceof FloatLiteral and not this instanceof ImaginaryLiteral
399422 }
@@ -425,6 +448,8 @@ class IntegerLiteral extends Num {
425448/** A floating point numeric constant, such as `0.4` or `4e3` */
426449class FloatLiteral extends Num {
427450
451+ /* syntax: 4.2 */
452+
428453 FloatLiteral ( ) {
429454 not this instanceof ImaginaryLiteral and
430455 this .getN ( ) .regexpMatch ( ".*[.eE].*" )
@@ -456,6 +481,9 @@ class FloatLiteral extends Num {
456481class ImaginaryLiteral extends Num {
457482 private float value ;
458483
484+ /* Special comment for documentation generation */
485+ /* syntax: 1.0j */
486+
459487 ImaginaryLiteral ( ) {
460488 value = this .getN ( ) .regexpCapture ( "(.+)j.*" , 1 ) .toFloat ( )
461489 }
@@ -513,6 +541,9 @@ class NegativeIntegerLiteral extends ImmutableLiteral, UnaryExpr {
513541 "hello" are treated as Bytes for Python2, but Unicode for Python3. */
514542class Unicode extends StrConst {
515543
544+ /* Special comment for documentation generation */
545+ /* syntax: "hello" */
546+
516547 Unicode ( ) {
517548 this .isUnicode ( )
518549 }
@@ -541,6 +572,9 @@ class Unicode extends StrConst {
541572/** A dictionary expression, such as `{'key':'value'}` */
542573class Dict extends Dict_ {
543574
575+ /* Special comment for documentation generation */
576+ /* syntax: {Expr: Expr, ...} */
577+
544578 /** Gets the value of an item of this dict display */
545579 Expr getAValue ( ) {
546580 result = this .getAnItem ( ) .( DictDisplayItem ) .getValue ( )
@@ -566,6 +600,9 @@ class Dict extends Dict_ {
566600/** A list expression, such as `[ 1, 3, 5, 7, 9 ]` */
567601class List extends List_ {
568602
603+ /* Special comment for documentation generation */
604+ /* syntax: [Expr, ...] */
605+
569606 override Expr getASubExpression ( ) {
570607 result = this .getAnElt ( )
571608 }
@@ -575,6 +612,9 @@ class List extends List_ {
575612/** A set expression such as `{ 1, 3, 5, 7, 9 }` */
576613class Set extends Set_ {
577614
615+ /* Special comment for documentation generation */
616+ /* syntax: {Expr, ...} */
617+
578618 override Expr getASubExpression ( ) {
579619 result = this .getAnElt ( )
580620 }
@@ -601,6 +641,8 @@ class PlaceHolder extends PlaceHolder_ {
601641/** A tuple expression such as `( 1, 3, 5, 7, 9 )` */
602642class Tuple extends Tuple_ {
603643
644+ /* syntax: (Expr, ...) */
645+
604646 override Expr getASubExpression ( ) {
605647 result = this .getAnElt ( )
606648 }
@@ -612,6 +654,8 @@ class Tuple extends Tuple_ {
612654 */
613655class Name extends Name_ {
614656
657+ /* syntax: name */
658+
615659 string getId ( ) {
616660 result = this .getVariable ( ) .getId ( )
617661 }
@@ -705,6 +749,9 @@ class Slice extends Slice_ {
705749/** A string constant. */
706750class StrConst extends Str_ , ImmutableLiteral {
707751
752+ /* Special comment for documentation generation */
753+ /* syntax: "hello" */
754+
708755 predicate isUnicode ( ) {
709756 this .getPrefix ( ) .charAt ( _) = "u"
710757 or
@@ -790,6 +837,9 @@ abstract class BooleanLiteral extends NameConstant {
790837/** The boolean named constant `True` */
791838class True extends BooleanLiteral {
792839
840+ /* Special comment for documentation generation */
841+ /* syntax: True */
842+
793843 True ( ) {
794844 name_consts ( this , "True" )
795845 }
@@ -807,6 +857,9 @@ class True extends BooleanLiteral {
807857/** The boolean named constant `False` */
808858class False extends BooleanLiteral {
809859
860+ /* Special comment for documentation generation */
861+ /* syntax: False */
862+
810863 False ( ) {
811864 name_consts ( this , "False" )
812865 }
@@ -824,6 +877,9 @@ class False extends BooleanLiteral {
824877/** `None` */
825878class None extends NameConstant {
826879
880+ /* Special comment for documentation generation */
881+ /* syntax: None */
882+
827883 None ( ) {
828884 name_consts ( this , "None" )
829885 }
@@ -840,6 +896,9 @@ class None extends NameConstant {
840896/** An await expression such as `await coro`. */
841897class Await extends Await_ {
842898
899+ /* Special comment for documentation generation */
900+ /* syntax: await Expr */
901+
843902 override Expr getASubExpression ( ) {
844903 result = this .getValue ( )
845904 }
@@ -849,6 +908,8 @@ class Await extends Await_ {
849908/** A formatted string literal expression, such as `f'hello {world!s}'` */
850909class Fstring extends Fstring_ {
851910
911+ /* syntax: f"Yes!" */
912+
852913 override Expr getASubExpression ( ) {
853914 result = this .getAValue ( )
854915 }
0 commit comments