Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support for generating man pages and completions #475

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

Merged

Conversation

jcgruenhage
Copy link
Contributor

@jcgruenhage jcgruenhage commented Aug 31, 2024

Description

This adds a way to generate completions and man pages so that distro packagers can ship them.

Instead of doing it based on an env var, which others are doing in f.ex. https://codeberg.org/openpgp-card/openpgp-card-tools/src/branch/main/src/oct.rs#L34-L56, it would also be possible to add a subcommand or a special command line flag, like other are doing in f.ex. https://github.com/orhun/git-cliff/blob/v2.4.0/git-cliff/src/bin/mangen.rs

Related Issue

I have not opened an issue about this. The change is fairly trivial though. If I really need to open an issue, I can do that, but I don't really see the purpose of it.

Motivation and Context

I have written this patch while packaging static-web-server for Chimera Linux, and it was (rightfully) pointed out that this patch should go upstream: chimera-linux/cports#2818 (review).

How Has This Been Tested?

A slightly different version of this patch has been tested in the cports PR linked above.

Screenshots (if appropriate):

Shell Completions

Fish

image

Nushell

image

Man page

image

Copy link

semanticdiff-com bot commented Aug 31, 2024

Review changes with SemanticDiff.

Analyzed 3 of 7 files.

Overall, the semantic diff is 25% smaller than the GitHub diff.

Filename Status
Cargo.lock Unsupported file format
Cargo.toml Unsupported file format
✔️ src/settings/cli.rs 9.52% smaller
✔️ src/settings/mod.rs Analyzed
✔️ src/bin/server.rs 32.0% smaller
docs/mkdocs.yml Unsupported file format
docs/content/features/man-pages-completions.md Unsupported file format

@jcgruenhage jcgruenhage marked this pull request as ready for review August 31, 2024 07:46
@joseluisq joseluisq added enhancement New feature or request v2 v2 release labels Aug 31, 2024
@jcgruenhage jcgruenhage force-pushed the generate-man-and-completions branch from 27788de to d4c32bc Compare August 31, 2024 09:56
Copy link
Collaborator

@joseluisq joseluisq left a comment

Choose a reason for hiding this comment

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

I like the idea. I left a few suggestions and a question to get your input about.

@jcgruenhage jcgruenhage force-pushed the generate-man-and-completions branch 2 times, most recently from a180361 to 723ae59 Compare September 7, 2024 08:02
Copy link
Collaborator

@joseluisq joseluisq left a comment

Choose a reason for hiding this comment

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

It looks fine to me I just left a few minor improvements to do.

Just the last thing to do is create a feature page called man-pages-completions.md in /docs/content/features dir.
Then add a feature entry in the docs config file /docs/mkdocs.yml below the last entry.

Please mention in the docs how to use the new subcommand and what can be generated for the three cases.

After that, we should be able to merge.

@jcgruenhage jcgruenhage force-pushed the generate-man-and-completions branch from 723ae59 to 91e731c Compare September 8, 2024 09:12
@jcgruenhage
Copy link
Contributor Author

@joseluisq I think I've addressed all your feedback. Can you check again whether you're happy with this as it is?

@joseluisq joseluisq changed the title feat: generate man page and completions Support for generating man pages and completions Sep 8, 2024
@joseluisq
Copy link
Collaborator

I also fixed the log info.

$ .\static-web-server.exe generate .
2024-09-08T19:01:16.740824Z  INFO static_web_server::info: wrote completions to .\completions
2024-09-08T19:01:16.757544Z  INFO static_web_server::info: wrote man pages to .\man
/static-web-server generate --completions .`
2024-09-08T19:03:46.665862Z  INFO static_web_server::info: wrote completions to ./completions

Copy link
Collaborator

@joseluisq joseluisq left a comment

Choose a reason for hiding this comment

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

Thanks!

@joseluisq joseluisq merged commit d567b4e into static-web-server:master Sep 8, 2024
35 checks passed
@joseluisq joseluisq added this to the v2.33.0 milestone Sep 8, 2024
@jcgruenhage jcgruenhage deleted the generate-man-and-completions branch September 8, 2024 19:50
@joseluisq
Copy link
Collaborator

I have written this patch while packaging static-web-server for Chimera Linux, and it was (rightfully) pointed out that this patch should go upstream: chimera-linux/cports#2818 (review).

@jcgruenhage FYI if the package gets merged upstream then you probably want to include it in the SWS Installations page as other distros, just feel free to open a docs PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v2 v2 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants