Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

feat(gnoweb): add hyperlinks to importp/*andr/* in source code viewer#3759

Open
mous1985 wants to merge39 commits intognolang:master
base:master
Choose a base branch
Loading
frommous1985:linkimport

Conversation

mous1985
Copy link
Contributor

@mous1985mous1985 commentedFeb 15, 2025
edited
Loading

This PR adds hyperlinks topackage andrealm imported in the source code viewer ongnoweb.

Image
  • Context and Goal:
    When users view source code ongnoweb, they often need to explore dependencies and related code. the goal was to make this easier by making imports linkable for example, when you seeimport "gno.land/p/demo/avl", you should be able to click it to see that package's source code.

thanks to@gfanton for the help

alexiscolin reacted with thumbs up emoji
@github-actionsgithub-actionsbot added the 📦 ⛰️ gno.landIssues or PRs gno.land package related labelFeb 15, 2025
@Gno2D2Gno2D2 requested a review froma teamFebruary 15, 2025 13:00
@Gno2D2Gno2D2 added the review/triage-pendingPRs opened by external contributors that are waiting for the 1st review labelFeb 15, 2025
@Gno2D2
Copy link
Collaborator

Gno2D2 commentedFeb 15, 2025
edited
Loading

🛠 PR Checks Summary

AllAutomated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
  • The pull request description provides enough details (checked by@thehowl)
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 related to gnoweb must be reviewed by its codeowners
🟢 Pending initial approval by a review team member, or review from 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 includeBREAKING 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└── 🟢 And    ├── 🟢 The base branch matches this pattern: ^master$    └── 🟢 The pull request was created from a fork (head branch repo: mous1985/gno)

Then

🟢 Requirement satisfied└── 🟢 Maintainer can modify this pull request
Changes related to gnoweb must be reviewed by its codeowners

If

🟢 Condition met└── 🟢 And    ├── 🟢 The base branch matches this pattern: ^master$    └── 🟢 A changed file matches this pattern: ^gno.land/pkg/gnoweb/ (filename: gno.land/pkg/gnoweb/webclient_html.go)

Then

🟢 Requirement satisfied└── 🟢 Or    ├── 🟢 This user reviewed pull request: alexiscolin    └── 🟢 This user reviewed pull request: gfanton
Pending initial approval by a review team member, or review from tech-staff

If

🟢 Condition met└── 🟢 And    ├── 🟢 The base branch matches this pattern: ^master$    └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🟢 Requirement satisfied└── 🟢 If    ├── 🟢 Condition    │   └── 🟢 Or    │       ├── 🟢 At least 1 user(s) of the organization reviewed the pull request (with state "APPROVED")    │       ├── 🟢 At least 1 user(s) of the team tech-staff reviewed pull request    │       └── 🔴 This pull request is a draft    └── 🟢 Then        └── 🟢 Not (🔴 This label is applied to pull request: review/triage-pending)
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
The pull request description provides enough details

If

🟢 Condition met└── 🟢 And    ├── 🟢 Not (🔴 Pull request author is a member of the team: core-contributors)    └── 🟢 Not (🔴 Pull request author is user: dependabot[bot])

Can be checked by

  • team core-contributors

@mous1985mous1985 marked this pull request as draftFebruary 15, 2025 13:08
@Gno2D2Gno2D2 removed the review/triage-pendingPRs opened by external contributors that are waiting for the 1st review labelFeb 15, 2025
@gfanton
Copy link
Member

@mous1985 before any reviews, can you add tests, especially testing:

  • single one line importimport "abc.yx/a/b/c"
  • multi import:
import ("abc.yx/a/b/c""abc.yx/a/b/c""abc.yx/a/b/c")
  • named import:
import (                 hello"abc.yx/a/b/c")
  • empty named import:
import (                 _"abc.yx/a/b/c")

thanks

mous1985 reacted with thumbs up emoji

@github-actionsgithub-actionsbot added the 📦 🤖 gnovmIssues or PRs gnovm related labelFeb 17, 2025
@codecovCodecov
Copy link

codecovbot commentedFeb 17, 2025
edited
Loading

Codecov Report

Attention: Patch coverage is82.60870% with4 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
gno.land/pkg/gnoweb/webclient_html.go82.60%2 Missing and 2 partials⚠️

📢 Thoughts on this report?Let us know!

@alexiscolinalexiscolin self-requested a reviewFebruary 19, 2025 10:33
@@ -344,3 +344,12 @@
scrollbar-width: none;
}
}
/* Styling for import links */
.gno-import {
Copy link
Member

Choose a reason for hiding this comment

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

Could you please try to use Tailwind and its config theme instead of using a new classes, new colors etc?

Copy link
ContributorAuthor

@mous1985mous1985Feb 19, 2025
edited
Loading

Choose a reason for hiding this comment

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

fffb7f4
It's good if i use<a href="/%s$source">&#34;%s&#34;</a> the same color as the original import ?

Copy link
Member

@notJoonnotJoon left a comment

Choose a reason for hiding this comment

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

Looks good 👍 I've left a few points related to refactoring things

mous1985 reacted with heart emoji
Copy link
Member

@notJoonnotJoon left a comment

Choose a reason for hiding this comment

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

LGTM

remove:review/triage-pending flag

@notJoonnotJoon removed the review/triage-pendingPRs opened by external contributors that are waiting for the 1st review labelMar 7, 2025
Copy link
Member

@alexiscolinalexiscolin left a comment
edited
Loading

Choose a reason for hiding this comment

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

Nice feature 👍
Nit: Could using a regex help by robustly matching import tokens, so we are not relying on fixed strings and specific newline formatting? But maybe it's a picky safeguard against potential changes in output format.

leohhhn reacted with thumbs up emojimous1985 reacted with heart emoji
@Gno2D2Gno2D2 requested a review fromgfantonMarch 7, 2025 19:11
@mous1985
Copy link
ContributorAuthor

Nice feature 👍 Nit: Could using a regex help by robustly matching import tokens, so we are not relying on fixed strings and specific newline formatting? But maybe it's a picky safeguard against potential changes in output format.

3d25c38

return nil
formatted := buf.String()

// Process .gno files to add links
Copy link
Member

Choose a reason for hiding this comment

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

This is a hack

We have an extensible markdown engine, we should implement this as an extension there, unless you can show it's impossible

alexiscolin reacted with thumbs up emoji
Copy link
Member

@alexiscolinalexiscolinMar 13, 2025
edited
Loading

Choose a reason for hiding this comment

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

Using Chroma would be correct but also more robust, maintainable, and less dependent on final HTML structure.

Copy link
Member

@gfantongfantonMar 13, 2025
edited
Loading

Choose a reason for hiding this comment

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

@thehowl This feature is not related togoldmark, but rather tochroma, which is responsible for syntax highlighting.

I gave a quick look atchroma to explore integration possibilities. Unfortunately, extending it is bit challenging, but not impossible. It would require creating a new renderer and a new lexer forgno, supporting import as a specific token, and integrating it into the rendering system.

This PR is indeed a hacky solution; even if it can be negligible most of the time, usingre.ReplaceAllString to process the whole file can be a heavy task based on the file size andI wonder if it could not even be a potential DDoS vector if people create some on-purpose files containing ton of"gno.land/.*" string reference (probably still negligible). Also, it relies on Chroma syntax, which can change over time. But the main issue is that we will likely and quickly encounter other changes like this one, e.g., linking the source function to the documentation page, adding hover variable inspection, etc. We cannot apply this hack every time we want to integrate source extensions.

I'm unsure whether to wait for a proper Chroma extension or to merge this as a temporary solution. Another less risky option could be to implement this hack on the JS side temporarily, as it would be better for the client to handle this "heavy" task (cc@alexiscolin). However, since there is nothing urgent, I'm hesitant to rush into a hacky and temporary solution.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thanks for your feedback@thehowl@gfanton@alexiscolin

I'm currently exploring possible ways to solving this issue. the best solution in my opinion is to extendchroma forgno, and then there will be more possibilities to manipulate source code, what do you think about that ?

I can put this PR in draft and working on it if you want

Copy link
Member

Choose a reason for hiding this comment

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

I'm not worried on the regex/performance side; Go's regex engine is very good and runs inO(n). I'm just worried that this is too dependent on the syntax coming out of goldmark and is not robust.

Goldmark highlighting is added with an extension that does the following:

m.Renderer().AddOptions(renderer.WithNodeRenderers(util.Prioritized(NewHTMLRenderer(e.options...), 200),))

Can we not also add an extension on the renderer, that runs after the HTMLRenderer (which adds the syntax highlighting)?

Copy link
Member

Choose a reason for hiding this comment

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

goldmark useschroma under the hood to generate the highlight. So you cannot just extendgoldmark. You necessarily have to extendchroma first.

thehowl reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

Please, update chroma so that everything we do for "source code viewer" may also work for when we embed gno code in the render function, i.e.,

lorem ipsum```gnoimport "gno.land/p/demo/avl"// ...```foo bar

gfanton and mous1985 reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

my request isn't about this PR especially but about the current way gnoweb use chroma in two different manners. i think this can be tackled in a dedicated PR (cc@alexiscolin@gfanton)

Copy link
Member

Choose a reason for hiding this comment

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

Fine, we can go with the regex and then look to improve this on chroma eventually. We have tests so we should know if it breaks.

Let's address moul's feedback then we're good to go I'd say?

mous1985 and gfanton reacted with thumbs up emoji
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@moulmoulmoul left review comments

@thehowlthehowlthehowl left review comments

@odeke-emodeke-emodeke-em left review comments

@alexiscolinalexiscolinalexiscolin approved these changes

@notJoonnotJoonnotJoon approved these changes

@gfantongfantonAwaiting requested review from gfanton

At least 1 approving review is required to merge this pull request.

Assignees

@mous1985mous1985

Labels
📦 ⛰️ gno.landIssues or PRs gno.land package related📦 🤖 gnovmIssues or PRs gnovm related
Projects
Status: In Progress
Status: In Review
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

8 participants
@mous1985@Gno2D2@gfanton@moul@thehowl@odeke-em@alexiscolin@notJoon

[8]ページ先頭

©2009-2025 Movatter.jp