gno icon indicating copy to clipboard operation
gno copied to clipboard

feat(gnoweb): README.md support for p/ & r/ packages

Open alexiscolin opened this issue 6 months ago • 2 comments

This PR implements README.md file support for both pures (p/) and realms (r/) in gno.land, addressing the requirements outlined in #4070.

Closes #4070

Features

For p/ packages:

  • If a README.md exists, it is rendered at the top of the directory listing (in the content temaplte)
  • README.md is moved to the first position in the file list
  • The rendered content uses the existing Goldmark infrastructure with Gno extensions

For r/ realms:

  • No Render() & no README.md: Display error page
  • Render() & no README.md: Works as before (existing behavior)
  • No Render() & README.md: Fallback to README.md rendering
  • Both present: Call Render() as primary, with README.md available in source view

Next iteration

This PR adds the first step to build the pkg.go template in gnoweb instead of the directory template and restructure the source template to be linked to it. This will improve and simplify the UX while giving more features/info to the users.

_Note: This PR replaces the previous PR #4101 with a much cleaner and more maintainable implementation. The current code reuses existing infrastructure and avoids code duplication, while providing a consistent user experience for displaying README.md files._

Capture d’écran 2025-06-22 à 13 18 45 Capture d’écran 2025-06-22 à 13 55 48

alexiscolin avatar Jun 22 '25 04:06 alexiscolin

🛠 PR Checks Summary

🔴 Changes related to gnoweb must be reviewed by its codeowners

Manual Checks (for Reviewers):
  • [x] 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 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 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
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: alexiscolin/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/app_test.go)

Then

🔴 Requirement not satisfied
└── 🔴 Or
    ├── 🔴 Or
    │   ├── 🔴 And
    │   │   ├── 🟢 Pull request author is user: alexiscolin
    │   │   └── 🔴 This user reviewed pull request: gfanton (with state "APPROVED")
    │   └── 🔴 And
    │       ├── 🔴 Pull request author is user: gfanton
    │       └── 🔴 This user reviewed pull request: alexiscolin (with state "APPROVED")
    └── 🔴 And
        ├── 🔴 Not (🟢 Pull request author is user: alexiscolin)
        ├── 🟢 Not (🔴 Pull request author is user: gfanton)
        └── 🔴 Or
            ├── 🔴 This user reviewed pull request: alexiscolin (with state "APPROVED")
            └── 🔴 This user reviewed pull request: gfanton (with state "APPROVED")

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
        └── 🟢 And
            ├── 🟢 Not (🔴 This label is applied to pull request: review/triage-pending)
            └── 🟢 At least 1 user(s) of the team tech-staff reviewed 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

Gno2D2 avatar Jun 22 '25 04:06 Gno2D2

Codecov Report

Attention: Patch coverage is 74.75728% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
gno.land/pkg/gnoweb/webclient_html.go 21.42% 10 Missing and 1 partial :warning:
gno.land/pkg/gnoweb/webclient_mock.go 26.66% 9 Missing and 2 partials :warning:
gno.land/pkg/gnoweb/handler.go 92.85% 3 Missing and 1 partial :warning:

:loudspeaker: Thoughts on this report? Let us know!

codecov[bot] avatar Jun 22 '25 04:06 codecov[bot]

That's good to go here, but it's definitely not the right direction.

The correct approach is not to display the README conditionally in various cases. Instead, it should always be shown at the top of the "doc page," similar to pkg.go.dev. The layout should include the README first, followed by the index of functions, methods, etc., then details for functions, and finally a list of files.

The r/ section should display this when we click on the doc tab, and the p/ section should have the doc tab as the default.

So, I'm okay with merging this because it improves the situation, but the direction is not right. Please keep an issue open regarding the direction.

moul avatar Jun 30 '25 15:06 moul

That's good to go here, but it's definitely not the right direction.

The correct approach is not to display the README conditionally in various cases. Instead, it should always be shown at the top of the "doc page," similar to pkg.go.dev. The layout should include the README first, followed by the index of functions, methods, etc., then details for functions, and finally a list of files.

The r/ section should display this when we click on the doc tab, and the p/ section should have the doc tab as the default.

So, I'm okay with merging this because it improves the situation, but the direction is not right. Please keep an issue open regarding the direction.

@moul This is only meant to be the first step toward completion of what you exposed (and is dully noted), as your initial issue didn’t cover the full scope we have now. I wanted to get it merged quickly since you asked for it ASAP.

alexiscolin avatar Jul 01 '25 06:07 alexiscolin