openrpc: Don't use os.Args in init

This commit is contained in:
Łukasz Magiera 2021-03-23 18:11:52 +01:00
parent 421338b9f4
commit b3774f8b87
2 changed files with 6 additions and 13 deletions

View File

@ -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":

View File

@ -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.