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

feat: Add vm/qdoc with function comments #3459

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jefft0
Copy link
Contributor

@jefft0 jefft0 commented Jan 8, 2025

Addresses #522 (comment)
by adding a query for vm/qdoc that uses a similar code path to gno doc which includes comments.

For example, gnokey query vm/qdoc -data "gno.land/r/demo/boards.CreateRepost" -remote tcp://127.0.0.1:26657 returns

package boards // import "boards"

func CreateRepost(bid BoardID, postid PostID, title string, body string, dstBoardID BoardID) PostID
    If dstBoard is private, does not ping back. If board specified by bid is
    private, panics.

And gnokey query vm/qdoc -data "gno.land/r/demo/boards.Post" -remote tcp://127.0.0.1:26657 returns

package boards // import "boards"

type Post struct {
	// Has unexported fields.
}
    A Post is a "thread" or a "reply" depending on context. A thread is a Post
    of a Board that holds other replies.

func (post *Post) AddReply(creator std.Address, body string) *Post
func (post *Post) AddRepostTo(creator std.Address, title, body string, dst *Board) *Post
func (thread *Post) DeletePost(pid PostID)
func (post *Post) GetDeleteFormURL() string
func (post *Post) GetPostID() PostID
func (thread *Post) GetReply(pid PostID) *Post
func (post *Post) GetReplyFormURL() string
func (post *Post) GetRepostFormURL() string
func (post *Post) GetSummary() string
func (post *Post) GetURL() string
func (post *Post) HasPermission(addr std.Address, perm Permission) bool
func (post *Post) IsThread() bool
func (post *Post) RenderInner() string
func (post *Post) RenderPost(indent string, levels int) string
func (post *Post) RenderSummary() string
func (post *Post) Update(title string, body string)

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Jan 8, 2025
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Jan 8, 2025

🛠 PR Checks Summary

🔴 Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
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)
🔴 Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 The pull request was created from a fork (head branch repo: jefft0/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff

If

🟢 Condition met
└── 🟢 A changed file matches this pattern: ^docs/ (filename: docs/reference/rpc-endpoints.md)

Then

🔴 Requirement not satisfied
└── 🔴 And
    ├── 🔴 Or
    │   ├── 🔴 Pull request author is a member of the team: tech-staff
    │   └── 🔴 At least 1 user(s) of the team tech-staff approved pull request
    └── 🔴 Or
        ├── 🔴 Pull request author is a member of the team: devrels
        └── 🔴 At least 1 user(s) of the team devrels approved pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

@jefft0 jefft0 changed the title feat: In doc, add newPkgDataFromMemPkg feat: Add vm/qdoc with func comments Jan 8, 2025
Copy link

codecov bot commented Jan 8, 2025

Codecov Report

Attention: Patch coverage is 23.33333% with 46 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
gno.land/pkg/sdk/vm/keeper.go 0.00% 20 Missing ⚠️
gnovm/pkg/doc/doc.go 0.00% 12 Missing ⚠️
gno.land/pkg/sdk/vm/handler.go 0.00% 11 Missing ⚠️
gnovm/pkg/doc/pkg.go 82.35% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jefft0 jefft0 force-pushed the feat/wm-qdoc-with-comments branch 3 times, most recently from c2538d6 to b295454 Compare January 13, 2025 16:37
@github-actions github-actions bot added the 📦 ⛰️ gno.land Issues or PRs gno.land package related label Jan 13, 2025
@Gno2D2 Gno2D2 requested review from a team January 13, 2025 16:38
@jefft0 jefft0 changed the title feat: Add vm/qdoc with func comments feat: Add vm/qdoc with function comments Jan 14, 2025
@Kouteki Kouteki added the in focus Core team is prioritizing this work label Jan 15, 2025
@jefft0 jefft0 force-pushed the feat/wm-qdoc-with-comments branch 2 times, most recently from fc953be to a2a8856 Compare January 16, 2025 11:12
@@ -843,6 +844,31 @@ func (vm *VMKeeper) QueryFile(ctx sdk.Context, filepath string) (res string, err
}
}

var rePkgPathAndSymbol = regexp.MustCompile(`^(.+)\.([a-zA-Z0-9_]+)$`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var rePkgPathAndSymbol = regexp.MustCompile(`^(.+)\.([a-zA-Z0-9_]+)$`)
var rePkgPathAndSymbol = regexp.MustCompile(`^(.+)(:?\.([a-zA-Z0-9_]+))?$`)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @thehowl . I see what you're getting at. To match the input "gno.land/r/demo/boards.CreateRepost", we want the first group to be "gno.land/r/demo/boards" and the second group to be "CreateRepost" (or empty if the input doesn't have ".CreateRepost"). Instead, it just lets the second group be optional (empty) and puts the entire input into the first group. I'll try some other variations.

@Gno2D2 Gno2D2 requested a review from a team January 16, 2025 12:07
@thehowl
Copy link
Member

thehowl commented Jan 16, 2025

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 io), but also add boxes to retain the functionality of the help page on realm documentation (so we can compose easily gnokey commands from the gnoweb frontend).

Signed-off-by: Jeff Thompson <[email protected]>
@jefft0 jefft0 force-pushed the feat/wm-qdoc-with-comments branch from a2a8856 to 8da68ae Compare January 16, 2025 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in focus Core team is prioritizing this work 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants