-
Notifications
You must be signed in to change notification settings - Fork 393
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
feat: Add vm/qdoc with function comments #3459
base: master
Are you sure you want to change the base?
Conversation
🛠 PR Checks Summary🔴 Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
c2538d6
to
b295454
Compare
fc953be
to
a2a8856
Compare
type JSONDocumentation struct {
PkgPath string `json:"pkg_path"`
PackageLine string `json:...` // package io // import "io"
PackageDoc string // markdown of top-level package documentation
// https://pkg.go.dev/go/doc#Package.Markdown to render markdown
// These match each of the sections in a pkg.go.dev package documentationj
Values []JSONValue // constants and variables declared
Funcs []JSONFunc // ...
Types []JSONType // ...
}
type JSONFunc struct {
Name string
Signature string
Doc string // markdown
} cc @alexiscolin @Kouteki to draft an idea for what we want for the frontend. Ideally, we'd base it off a go package documentation (like |
8da68ae
to
52f5689
Compare
Hi @thehowl . Currently, gno doc creates a |
@jefft0 I'd say:
sounds good? |
Hi @thehowl . I'm making progress with your suggestion. I got blocked for a while because I didn't understand that |
52f5689
to
566aa77
Compare
Signed-off-by: Jeff Thompson <[email protected]>
…the documentable struct. Signed-off-by: Jeff Thompson <[email protected]>
566aa77
to
752c34b
Compare
Signed-off-by: Jeff Thompson <[email protected]>
752c34b
to
45a8c82
Compare
@thehowl, please see the updated PR description with example output. As you suggested above, I changed Right now, it adds all the functions, etc. for the package. If only one symbol is selected, I'm not sure how one would use vm/qdoc to return a |
957653c
to
9ced645
Compare
Signed-off-by: Jeff Thompson <[email protected]>
9ced645
to
cc96681
Compare
Signed-off-by: Jeff Thompson <[email protected]>
Signed-off-by: Jeff Thompson <[email protected]>
Ultimately, we want help_function.html to display the function comment next to the function name. Function information is passed in the Currently, |
Signed-off-by: Jeff Thompson <[email protected]>
…essage Signed-off-by: Jeff Thompson <[email protected]>
expectedErrorMatch string | ||
}{ | ||
// valid queries | ||
{input: []byte(`gno.land/r/hello`), expectedResult: `{"package_path":"gno.land/r/hello","package_line":"package hello // import \"hello\"","package_doc":"hello is a package for testing\n","values":[{"signature":"const ConstString = \"const string\"","doc":""},{"signature":"var PubString = \"public string\"","doc":""},{"signature":"var counter int = 42","doc":""},{"signature":"var myStructInst = myStruct{a: 1000}","doc":""},{"signature":"var pvString = \"private string\"","doc":""},{"signature":"var sl = []int{1, 2, 3, 4, 5}","doc":"sl is an int array\n"}],"funcs":[{"type":"","name":"Echo","signature":"func Echo(msg string) string","doc":""},{"type":"","name":"GetCounter","signature":"func GetCounter() int","doc":""},{"type":"","name":"Inc","signature":"func Inc() int","doc":""},{"type":"","name":"Panic","signature":"func Panic()","doc":"Panic is a func for testing\n"},{"type":"","name":"fn","signature":"func fn() func(string) string","doc":""},{"type":"","name":"pvEcho","signature":"func pvEcho(msg string) string","doc":""},{"type":"myStruct","name":"Foo","signature":"func (ms myStruct) Foo() string","doc":"Foo is a method for testing\n"}],"types":[{"name":"myStruct","signature":"type myStruct struct{ a int }","doc":"myStruct is a struct for testing\n"}]}`}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have maybe the result as a JSONDocumentation
to compare to? Easier to check and verify than this huge JSON blob.
jsonDoc.Funcs = append(jsonDoc.Funcs, &JSONFunc{ | ||
Name: fun.Name, | ||
Signature: buf.String(), | ||
Doc: string(pkg.Markdown(fun.Doc)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc: string(pkg.Markdown(fun.Doc)), | |
Doc: string(pkg.Markdown(fun.Doc)), | |
Params: []JSONField{...}, | |
Results: []JSONField{...}, |
JSONField is a simple struct{ Name string; Type string }
, breaking down the ast.Field
type
type JSONValue struct { | ||
Signature string `json:"signature"` | ||
Doc string `json:"doc"` // markdown | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type JSONValue struct { | |
Signature string `json:"signature"` | |
Doc string `json:"doc"` // markdown | |
} | |
type JSONValueDecl struct { | |
Signature string `json:"signature"` | |
Const bool `json:"const"` | |
Values []JSONValue `json:"values"` | |
Doc string `json:"doc"` // markdown | |
} | |
type JSONValue struct { | |
Name string `json:"name"` | |
Doc string `json:"doc"` | |
Type string `json:"type"` // often empty | |
} |
Signed-off-by: Jeff Thompson <[email protected]>
Addresses #522 (comment)
by adding a query for
vm/qdoc
that uses a similar code path togno doc
which includes comments.For example,
gnokey query vm/qdoc -data "gno.land/r/gnoland/valopers/v2" -remote tcp://127.0.0.1:26657
returns the following JSON doc for valopers.