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

chore(docs): reorganize docs folder, add 404 checker #2125

Open
wants to merge 42 commits into
base: master
Choose a base branch
from

Conversation

leohhhn
Copy link
Contributor

@leohhhn leohhhn commented May 16, 2024

Description

Continuing #1999

Renames the docs with numbers, adds a Go linter and makefile to run it to check for 404 or broken links.

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

moul and others added 6 commits April 29, 2024 17:57
Signed-off-by: moul <94029+moul@users.noreply.github.com>
# Conflicts:
#	docs/02-getting-started/03-local-setup/browsing-gno-source-code.md
#	docs/02-getting-started/03-local-setup/browsing-gnoland.md
#	docs/02-getting-started/03-local-setup/installation.md
#	docs/02-getting-started/03-local-setup/interacting-with-gnoland.md
#	docs/04-concepts/stdlibs/events.md
@leohhhn leohhhn changed the title chore: reorganize docs folder with numbered prefixes chore(docs): reorganize docs folder with numbered prefixes May 16, 2024
@leohhhn leohhhn marked this pull request as ready for review May 17, 2024 16:41
@leohhhn leohhhn requested review from a team and moul as code owners May 17, 2024 16:41
@leohhhn leohhhn changed the title chore(docs): reorganize docs folder with numbered prefixes chore(docs): reorganize docs folder, add 404 linter May 17, 2024
docs/Makefile Outdated

# Build the linter
build:
cd linter && go build -o ./build/linter
Copy link
Member

Choose a reason for hiding this comment

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

Cool that you added a linter. However, please move it to misc/docs-linter.

Keep this Makefile here.

Thank you.

Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to run it from the CI too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the linter: e7546dd

Adding the linter to the CI seems like it is out of scope for this PR - let's leave it for another one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the linter to the CI: 8fad8c9

Copy link
Member

@moul moul 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 to me.

There is a question on the hierarchy that we need to address later, but this system looks good for both humans and machines, whether on GitHub or from a Go script that would want to generate static pages.

@leohhhn leohhhn requested a review from a team as a code owner May 17, 2024 18:53
@leohhhn leohhhn removed the request for review from a team May 17, 2024 18:53
Copy link

codecov bot commented May 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.62%. Comparing base (a85b380) to head (c9f3fa0).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2125      +/-   ##
==========================================
- Coverage   54.64%   54.62%   -0.02%     
==========================================
  Files         578      578              
  Lines       77877    77877              
==========================================
- Hits        42554    42544      -10     
- Misses      32150    32160      +10     
  Partials     3173     3173              
Flag Coverage Δ
contribs/gnodev 24.24% <ø> (ø)
contribs/gnofaucet 14.46% <ø> (ø)
contribs/gnokeykc 0.00% <ø> (ø)
contribs/gnomd 0.00% <ø> (ø)
gno.land 61.65% <ø> (ø)
gnovm 60.00% <ø> (ø)
misc/autocounterd 0.00% <ø> (ø)
misc/genproto 0.00% <ø> (ø)
misc/genstd 73.90% <ø> (ø)
misc/goscan 0.00% <ø> (ø)
misc/logos 17.38% <ø> (-0.31%) ⬇️
misc/loop 0.00% <ø> (ø)
tm2 54.48% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

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

We need to resolve some things before we move forward, please address the comments


require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/peterbourgon/ff/v3 v3.4.0 // indirect
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to use this package for a single flag?
We can use the standard go flag library for the lint commands

Copy link
Contributor Author

@leohhhn leohhhn Jun 3, 2024

Choose a reason for hiding this comment

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

I am using our commands package (github.com/gnolang/gno/tm2/pkg/commands) and I think ff/v3 is a dependency on it. I would keep it in for consistency throughout the codebase and the possibility that we add more flags later, seems like there is no harm in this.

)

var (
ErrEmptyPath = errors.New("you need to pass in a path to scan")
Copy link
Member

Choose a reason for hiding this comment

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

Why is this exported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

commands.Metadata{
Name: "docs-linter",
ShortUsage: "docs-linter [flags]",
ShortHelp: "Finds broken 404 links in the .md files in the given folder & subfolders",
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this lint, not just find broken links?

Copy link
Contributor Author

@leohhhn leohhhn Jun 3, 2024

Choose a reason for hiding this comment

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

In this case, this "linter" is supposed to only check for 404s, as stated in the original PR. Do you think docs-404-checker would be a more appropriate name?

ShortHelp: "Finds broken 404 links in the .md files in the given folder & subfolders",
},
cfg,
func(ctx context.Context, args []string) error {
Copy link
Member

Choose a reason for hiding this comment

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

It's funny that the go linter was not run against this code

Copy link
Contributor Author

@leohhhn leohhhn Jun 3, 2024

Choose a reason for hiding this comment

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

I ran a linter and fixed the unused variables: fe69c6a

return err
}

fmt.Printf("Linting %s...\n", abs)
Copy link
Member

Choose a reason for hiding this comment

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

Why not use commands.IO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems to me that fmt is quite more simple and more known, and is a standard library, which is why I opted for it.

}
}

func removeDir(t *testing.T, dirPath string) func() {
Copy link
Member

Choose a reason for hiding this comment

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

Why not directly call this in the t.Cleanup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use the same functionality twice, so I've extracted it to a separate function. I think it makes the code more readable, and this is how I used to implement in in the past based on feedback from the team.

@@ -0,0 +1,107 @@
package main
Copy link
Member

Choose a reason for hiding this comment

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

These funcs should be in the same file as where they're called

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've moved all functions to the main.go file in this commit: 3172ee8

// Lock the mutex before appending to results
lock.Lock()
*results = append(*results, fmt.Sprintf("%s (found in file: %s)", url, filePath))
lock.Unlock()
Copy link
Member

Choose a reason for hiding this comment

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

You can put this in a defer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've moved the locks out of this function here: 3172ee8

}

// checkUrl checks if a URL is a 404
func checkUrl(lock *sync.Mutex, url string, filePath string, results *[]string) error {
Copy link
Member

Choose a reason for hiding this comment

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

Please rewrite this function so it doesn't modify the inputs 🙏

Copy link
Contributor Author

@leohhhn leohhhn Jun 3, 2024

Choose a reason for hiding this comment

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

I've purified the function to return an error based on the result, and then modify the array elsewhere: 3172ee8 (#2125)

)
}

func execLint(cfg *cfg, ctx context.Context) error {
Copy link
Member

Choose a reason for hiding this comment

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

If this is supposed to be a linting suite for the documentation, then the main run loop shouldn't need to run a single linter, but be able to run multiple ones

Please create some kind of pipeline system 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea with this was to only have a link 404 checker. Reference this comment

@leohhhn
Copy link
Contributor Author

leohhhn commented Jun 3, 2024

I will resolve the merge conflicts after we merge this for consistency

@leohhhn
Copy link
Contributor Author

leohhhn commented Jun 3, 2024

I've also added a CI workflow but I'm not fully sure I'm doing it right - any inputs would be appreciated.

@leohhhn leohhhn changed the title chore(docs): reorganize docs folder, add 404 linter chore(docs): reorganize docs folder, add 404 checker Jun 5, 2024
@leohhhn
Copy link
Contributor Author

leohhhn commented Jun 6, 2024

Staging is returning a 404:
http://staging.gno.land:26657/
http://rpc.staging.gno.land:26657/

@albttx can you check this out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Status: In Progress
Status: In Review
Development

Successfully merging this pull request may close these issues.

None yet

3 participants