Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix discovery external docs URL #309

Merged
merged 2 commits into from
Jan 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion node/openrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ var sharedMetaRegisterer = &go_openrpc_reflect.MetaT{
return info
},
GetExternalDocsFn: func() (exdocs *meta_schema.ExternalDocumentationObject) {
return nil // FIXME
exdocs = &meta_schema.ExternalDocumentationObject{}
description := "ETC Labs Documentation"
exdocs.Description = (*meta_schema.ExternalDocumentationObjectDescription)(&description)
url := "https://etclabscore.github.io/core-geth/"
exdocs.Url = (*meta_schema.ExternalDocumentationObjectUrl)(&url)
return exdocs
},
}

Expand Down Expand Up @@ -182,6 +187,21 @@ func newOpenRPCDocument() *go_openrpc_reflect.Document {
return go_openrpc_reflect.EthereumReflector.GetContentDescriptorRequired(r, m, field)
}

appReflector.FnGetMethodExternalDocs = func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (*meta_schema.ExternalDocumentationObject, error) {
standard := go_openrpc_reflect.StandardReflector
got, err := standard.GetMethodExternalDocs(r, m, funcDecl)
if err != nil {
return nil, err
}
if got.Url == nil {
return got, nil
}
// Replace links to go-ethereum repo with current core-geth one
newLink := meta_schema.ExternalDocumentationObjectUrl(strings.Replace(string(*got.Url), "github.com/ethereum/go-ethereum", "github.com/etclabscore/core-geth", 1))
got.Url = &newLink
return got, nil
}

// Finally, register the configured reflector to the document.
d.WithReflector(appReflector)
return d
Expand Down