Merge pull request #7851 from zl03jsj/fix/goc-gen-slice
fix: doc generation struct slice example value
This commit is contained in:
commit
0523c946f9
@ -1,6 +1,7 @@
|
|||||||
package docgen
|
package docgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"go/parser"
|
"go/parser"
|
||||||
@ -252,6 +253,7 @@ func init() {
|
|||||||
addExample(map[abi.SectorNumber]string{
|
addExample(map[abi.SectorNumber]string{
|
||||||
123: "can't acquire read lock",
|
123: "can't acquire read lock",
|
||||||
})
|
})
|
||||||
|
addExample(json.RawMessage(`"json raw message"`))
|
||||||
addExample(map[api.SectorState]int{
|
addExample(map[api.SectorState]int{
|
||||||
api.SectorState(sealing.Proving): 120,
|
api.SectorState(sealing.Proving): 120,
|
||||||
})
|
})
|
||||||
@ -348,7 +350,7 @@ func ExampleValue(method string, t, parent reflect.Type) interface{} {
|
|||||||
switch t.Kind() {
|
switch t.Kind() {
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
out := reflect.New(t).Elem()
|
out := reflect.New(t).Elem()
|
||||||
reflect.Append(out, reflect.ValueOf(ExampleValue(method, t.Elem(), t)))
|
out = reflect.Append(out, reflect.ValueOf(ExampleValue(method, t.Elem(), t)))
|
||||||
return out.Interface()
|
return out.Interface()
|
||||||
case reflect.Chan:
|
case reflect.Chan:
|
||||||
return ExampleValue(method, t.Elem(), nil)
|
return ExampleValue(method, t.Elem(), nil)
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -103,7 +103,9 @@ Response:
|
|||||||
"MemSwap": 42,
|
"MemSwap": 42,
|
||||||
"MemSwapUsed": 42,
|
"MemSwapUsed": 42,
|
||||||
"CPUs": 42,
|
"CPUs": 42,
|
||||||
"GPUs": null,
|
"GPUs": [
|
||||||
|
"string value"
|
||||||
|
],
|
||||||
"Resources": {
|
"Resources": {
|
||||||
"seal/v0/addpiece": {
|
"seal/v0/addpiece": {
|
||||||
"0": {
|
"0": {
|
||||||
@ -691,7 +693,18 @@ Perms: admin
|
|||||||
|
|
||||||
Inputs: `null`
|
Inputs: `null`
|
||||||
|
|
||||||
Response: `null`
|
Response:
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"ID": "76f1988b-ef30-4d7e-b3ec-9a627f4ba5a8",
|
||||||
|
"Weight": 42,
|
||||||
|
"LocalPath": "string value",
|
||||||
|
"CanSeal": true,
|
||||||
|
"CanStore": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
### Remove
|
### Remove
|
||||||
Storage / Other
|
Storage / Other
|
||||||
@ -749,7 +762,9 @@ Inputs:
|
|||||||
},
|
},
|
||||||
"ProofType": 8
|
"ProofType": 8
|
||||||
},
|
},
|
||||||
null,
|
[
|
||||||
|
1024
|
||||||
|
],
|
||||||
1024,
|
1024,
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
@ -784,7 +799,12 @@ Inputs:
|
|||||||
},
|
},
|
||||||
"ProofType": 8
|
"ProofType": 8
|
||||||
},
|
},
|
||||||
null
|
[
|
||||||
|
{
|
||||||
|
"Offset": 1024,
|
||||||
|
"Size": 1024
|
||||||
|
}
|
||||||
|
]
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -946,7 +966,9 @@ Inputs:
|
|||||||
{
|
{
|
||||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||||
},
|
},
|
||||||
null
|
[
|
||||||
|
"Ynl0ZSBhcnJheQ=="
|
||||||
|
]
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -979,7 +1001,12 @@ Inputs:
|
|||||||
},
|
},
|
||||||
"ProofType": 8
|
"ProofType": 8
|
||||||
},
|
},
|
||||||
null
|
[
|
||||||
|
{
|
||||||
|
"Offset": 1024,
|
||||||
|
"Size": 1024
|
||||||
|
}
|
||||||
|
]
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1012,7 +1039,14 @@ Inputs:
|
|||||||
},
|
},
|
||||||
"ProofType": 8
|
"ProofType": 8
|
||||||
},
|
},
|
||||||
null
|
[
|
||||||
|
{
|
||||||
|
"Size": 1032,
|
||||||
|
"PieceCID": {
|
||||||
|
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1045,9 +1079,16 @@ Inputs:
|
|||||||
},
|
},
|
||||||
"ProofType": 8
|
"ProofType": 8
|
||||||
},
|
},
|
||||||
null,
|
"Bw==",
|
||||||
null,
|
"Bw==",
|
||||||
null,
|
[
|
||||||
|
{
|
||||||
|
"Size": 1032,
|
||||||
|
"PieceCID": {
|
||||||
|
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
{
|
{
|
||||||
"Unsealed": {
|
"Unsealed": {
|
||||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||||
@ -1085,7 +1126,7 @@ Inputs:
|
|||||||
},
|
},
|
||||||
"ProofType": 8
|
"ProofType": 8
|
||||||
},
|
},
|
||||||
null
|
"Bw=="
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1115,8 +1156,15 @@ Inputs:
|
|||||||
},
|
},
|
||||||
"ProofType": 8
|
"ProofType": 8
|
||||||
},
|
},
|
||||||
null,
|
"Bw==",
|
||||||
null
|
[
|
||||||
|
{
|
||||||
|
"Size": 1032,
|
||||||
|
"PieceCID": {
|
||||||
|
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1146,7 +1194,7 @@ Inputs:
|
|||||||
},
|
},
|
||||||
"ProofType": 8
|
"ProofType": 8
|
||||||
},
|
},
|
||||||
null
|
"Bw=="
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1263,7 +1311,7 @@ Inputs:
|
|||||||
},
|
},
|
||||||
1040384,
|
1040384,
|
||||||
1024,
|
1024,
|
||||||
null,
|
"Bw==",
|
||||||
{
|
{
|
||||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user