openrpc: Don't use os.Args in init
This commit is contained in:
parent
421338b9f4
commit
b3774f8b87
@ -7,6 +7,8 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/api/docgen"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api/apistruct"
|
"github.com/filecoin-project/lotus/api/apistruct"
|
||||||
docgen_openrpc "github.com/filecoin-project/lotus/api/docgen-openrpc"
|
docgen_openrpc "github.com/filecoin-project/lotus/api/docgen-openrpc"
|
||||||
)
|
)
|
||||||
@ -29,7 +31,9 @@ Use:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
doc := docgen_openrpc.NewLotusOpenRPCDocument()
|
Comments, GroupDocs := docgen.ParseApiASTInfo(os.Args[1], os.Args[2], os.Args[3], os.Args[4])
|
||||||
|
|
||||||
|
doc := docgen_openrpc.NewLotusOpenRPCDocument(Comments, GroupDocs)
|
||||||
|
|
||||||
switch os.Args[2] {
|
switch os.Args[2] {
|
||||||
case "FullNode":
|
case "FullNode":
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/alecthomas/jsonschema"
|
"github.com/alecthomas/jsonschema"
|
||||||
@ -15,16 +14,6 @@ import (
|
|||||||
meta_schema "github.com/open-rpc/meta-schema"
|
meta_schema "github.com/open-rpc/meta-schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Comments holds API method comments collected by AST parsing.
|
|
||||||
var Comments map[string]string
|
|
||||||
|
|
||||||
// GroupDocs holds documentation for documentation groups.
|
|
||||||
var GroupDocs map[string]string
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
Comments, GroupDocs = docgen.ParseApiASTInfo(os.Args[1], os.Args[2], os.Args[3], os.Args[4])
|
|
||||||
}
|
|
||||||
|
|
||||||
// schemaDictEntry represents a type association passed to the jsonschema reflector.
|
// schemaDictEntry represents a type association passed to the jsonschema reflector.
|
||||||
type schemaDictEntry struct {
|
type schemaDictEntry struct {
|
||||||
example interface{}
|
example interface{}
|
||||||
@ -94,7 +83,7 @@ func OpenRPCSchemaTypeMapper(ty reflect.Type) *jsonschema.Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewLotusOpenRPCDocument defines application-specific documentation and configuration for its OpenRPC document.
|
// NewLotusOpenRPCDocument defines application-specific documentation and configuration for its OpenRPC document.
|
||||||
func NewLotusOpenRPCDocument() *go_openrpc_reflect.Document {
|
func NewLotusOpenRPCDocument(Comments, GroupDocs map[string]string) *go_openrpc_reflect.Document {
|
||||||
d := &go_openrpc_reflect.Document{}
|
d := &go_openrpc_reflect.Document{}
|
||||||
|
|
||||||
// Register "Meta" document fields.
|
// Register "Meta" document fields.
|
||||||
|
Loading…
Reference in New Issue
Block a user