-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Create help_section
macro and use it for numfmt
#3180
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
Conversation
it is going to include directly the content into the binary or read the file at runtime ? |
9c0d786
to
2d632d5
Compare
It reads the file at compile-time! |
This is what it looks like after using const ABOUT: &str = "Convert numbers from/to human-readable strings";
const LONG_HELP : & str = "UNIT options:\n none no auto-scaling is done; suffixes will trigger an error\n\n auto accept optional single/two letter suffix:\n\n 1K = 1000, 1Ki = 1024, 1M = 1000000, 1Mi = 1048576,\n\n si accept optional single letter suffix:\n\n 1K = 1000, 1M = 1000000, ...\n\n iec accept optional single letter suffix:\n\n 1K = 1024, 1M = 1048576, ...\n\n iec-i accept optional two-letter suffix:\n\n 1Ki = 1024, 1Mi = 1048576, ...\n\nFIELDS supports cut(1) style field ranges:\n N N\'th field, counted from 1\n N- from N\'th field, to end of line\n N-M from N\'th to M\'th field (inclusive)\n -M from first to M\'th field (inclusive)\n\n- all fields\nMultiple fields/ranges can be separated with commas" ;
const USAGE: &str = "{} [OPTION]... [NUMBER]..."; |
I like this idea, @rivy what do you think? |
I also like the idea. 👍🏻 Some random thoughts...
# <UTIL>
## about
...
## help
...
|
I'm not quite sure what you mean with this. Currently, you can add more markdown sections and they will just be ignored (the macro reads from the specified header until the next header). What information would you like to add?
I'll have to figure out how to open the right file, but I think that should be possible. I'll try to implement this. Another option that I just thought of, it could also be read from the README.md of the util. Although I'm not sure whether that's intuitive and it doesn't solve the issue you're describing. |
@rivy are you ok ? :) |
a5af146
to
26f3771
Compare
I have added a |
Oh also the files are now in the |
I life the idea. just a few questions:
|
It's fairly hard to test as a unit test, but I could add add some tests to check the specific output of
Yes, but ungracefully for now. It will spew an ugly
Ideally, yes, but there's no rush. I've written down some future ideas for documentation here: #3181
I've tried to add some comprehensive docstrings, but it would be nice to also put it in a more discoverable place maybe. Where would you like to see this documented? I'll get to these things sometime next week :) |
Sorry for the latency. I am happy to accept this change. |
I still wanted to address the things you mentioned earlier, but I've been very busy. I'll convert this to a draft until I've fixed those things up. |
ef8ed97
to
087a94b
Compare
OK, I wrote some unit tests for the parsing of the sections. Also, I made the filename an argument of the macro, so instead of
it is now
This makes it immediately obvious where the info is coming from. I've also added some more documentation. |
Excellent idea, thanks |
087a94b
to
828112f
Compare
ec72ff1
to
9f35f29
Compare
@tertsdiepraam sorry, i dropped the ball on this. Do you still want to land this? thanks |
9f35f29
to
ff2f8b5
Compare
@sylvestre I still think this is useful indeed. I'll also have some time to add this to more utils in the coming weeks (in other PRs) |
Sure |
I rebased it against main to see if it is still green |
uucore: make help_section and help_usage take an argument to select a file
244fb1d
to
a3a69cf
Compare
@sylvestre I think this is finally ready to be merged! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your call if you want this in 0.0.15 or not :)
Sure, let's sneak it in :) |
Experimental implementation of #2816
I wanted to test my idea from #2816 and gather some feedback on it, so here we are :)
The macro reads the
help.md
file at the root of the crate extracts the section that is specified as an argument (matching the section is not dependent on whitespace and case). The implementation is a bit convoluted because I didn't want to pull insyn
as a dependency, but I think it works.Thoughts?
For some context, my semi-long term goal for documentation is:
help.md
files in markdown.mdbook-man
.--help
.usage
,after_help
,about
set from thehelp.md
.