- Notifications
You must be signed in to change notification settings - Fork18.4k
Commita228e73
go/doc/example: Fix bug causing false negatives for Example playability.
Allows Examples with KeyValue expressions to be playable in godoc.During the traversal of the abstract syntax tree any KeyValueExpr Key.Name was incorrectly being added as an unresolved identifier.Since this identifier could not be provided the Example was marked as unplayable.This updates the AST traversal to skip Keys (but continue traversing the Values).Example of problematic AST now fixed (see L99 where "UpperBound" was being added as a missing identifier): 81 . . . . . . . . . Values: []ast.Expr (len = 1) { 82 . . . . . . . . . . 0: *ast.UnaryExpr { 83 . . . . . . . . . . . OpPos: 12:19 84 . . . . . . . . . . . Op: & 85 . . . . . . . . . . . X: *ast.CompositeLit { 86 . . . . . . . . . . . . Type: *ast.SelectorExpr { 87 . . . . . . . . . . . . . X: *ast.Ident { 88 . . . . . . . . . . . . . . NamePos: 12:20 89 . . . . . . . . . . . . . . Name: "t_proto" 90 . . . . . . . . . . . . . } 91 . . . . . . . . . . . . . Sel: *ast.Ident { 92 . . . . . . . . . . . . . . NamePos: 12:41 93 . . . . . . . . . . . . . . Name: "BConfig" 94 . . . . . . . . . . . . . } 95 . . . . . . . . . . . . } 96 . . . . . . . . . . . . Lbrace: 12:79 97 . . . . . . . . . . . . Elts: []ast.Expr (len = 2) { 98 . . . . . . . . . . . . . 0: *ast.KeyValueExpr { 99 . . . . . . . . . . . . . . Key: *ast.Ident {100 . . . . . . . . . . . . . . . NamePos: 13:3101 . . . . . . . . . . . . . . . Name: "UpperBound"102 . . . . . . . . . . . . . . }103 . . . . . . . . . . . . . . Colon: 13:13104 . . . . . . . . . . . . . . Value: *ast.CallExpr {105 . . . . . . . . . . . . . . . Fun: *ast.SelectorExpr {106 . . . . . . . . . . . . . . . . X: *ast.Ident {107 . . . . . . . . . . . . . . . . . NamePos: 13:15108 . . . . . . . . . . . . . . . . . Name: "proto"109 . . . . . . . . . . . . . . . . }110 . . . . . . . . . . . . . . . . Sel: *ast.Ident {111 . . . . . . . . . . . . . . . . . NamePos: 13:21112 . . . . . . . . . . . . . . . . . Name: "Float32"113 . . . . . . . . . . . . . . . . }R=adgCC=gobot, golang-dev, grihttps://golang.org/cl/85690451 parentb13eac8 commita228e73
2 files changed
+87
-0
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
166 | 166 |
| |
167 | 167 |
| |
168 | 168 |
| |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
169 | 176 |
| |
170 | 177 |
| |
171 | 178 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
| 21 | + | |
21 | 22 |
| |
22 | 23 |
| |
23 | 24 |
| |
| |||
35 | 36 |
| |
36 | 37 |
| |
37 | 38 |
| |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
38 | 71 |
| |
39 | 72 |
| |
40 | 73 |
| |
| |||
49 | 82 |
| |
50 | 83 |
| |
51 | 84 |
| |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
52 | 99 |
| |
53 | 100 |
| |
54 | 101 |
| |
| |||
78 | 125 |
| |
79 | 126 |
| |
80 | 127 |
| |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
81 | 161 |
| |
82 | 162 |
| |
83 | 163 |
| |
|
0 commit comments
Comments
(0)