feat(gnoweb): README.md support for p/ & r/ packages
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.mdexists, it is rendered at the top of the directory listing (in thecontenttemaplte) README.mdis 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, withREADME.mdavailable 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._
🛠 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:
- Fix any issues flagged by automated checks.
- 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 CHANGEnotes. - Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
- 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 requestChanges 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 requestManual Checks
**IGNORE** the bot requirements for this PR (force green CI check)
If
🟢 Condition met └── 🟢 On every pull requestCan be checked by
- Any user with comment edit permission
Codecov Report
Attention: Patch coverage is 74.75728% with 26 lines in your changes missing coverage. Please review.
:loudspeaker: Thoughts on this report? Let us know!
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.
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.