diff --git a/api/docgen-openrpc/cmd/docgen_openrpc.go b/api/docgen-openrpc/cmd/docgen_openrpc.go index b1322257c..b2eb31057 100644 --- a/api/docgen-openrpc/cmd/docgen_openrpc.go +++ b/api/docgen-openrpc/cmd/docgen_openrpc.go @@ -7,6 +7,8 @@ import ( "log" "os" + "github.com/filecoin-project/lotus/api/docgen" + "github.com/filecoin-project/lotus/api/apistruct" docgen_openrpc "github.com/filecoin-project/lotus/api/docgen-openrpc" ) @@ -29,7 +31,9 @@ Use: */ 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] { case "FullNode": diff --git a/api/docgen-openrpc/openrpc.go b/api/docgen-openrpc/openrpc.go index e2cd9ce53..271b43ac6 100644 --- a/api/docgen-openrpc/openrpc.go +++ b/api/docgen-openrpc/openrpc.go @@ -4,7 +4,6 @@ import ( "encoding/json" "go/ast" "net" - "os" "reflect" "github.com/alecthomas/jsonschema" @@ -15,16 +14,6 @@ import ( 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. type schemaDictEntry struct { example interface{} @@ -94,7 +83,7 @@ func OpenRPCSchemaTypeMapper(ty reflect.Type) *jsonschema.Type { } // 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{} // Register "Meta" document fields.