-
Notifications
You must be signed in to change notification settings - Fork 348
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
Improve usage documentation and break synopsis lines to fit terminal #4796
Conversation
New testbreak.c program used for exploring auto-breaking.
Does anyone find this test useful and have suggestions for improvements? @KristofKoch ? @joa-quim ? |
Did not play with this yet. |
Surely a beginners question – but how do I start the program? |
After building from this branch just type |
Mh, then I'm doing something wrong:
|
Remember the binary is in build/src which is probably not in your path. It is not a gmt module. |
OK, looks like nobody gave this a spin. Given we have a lot of hideously formatted usage messages like
and 150 of these, it seems something automatic and configurable is better than manual grunt work that has to be updated each time another option is added? Please give it a try and see if you think this is an improvement. Adding @GenericMappingTools/core now since I forgot. |
If this gets converted to a GMT_Wrap function, could it be implemented for users to define their preferred default message line length in ConfigUserAdvanced.cmake? |
Sure, if we decide that adding a new defaults like GMT_SYNOPSIS_WIDTH is too much tinkering then we can make that a CMake setting instead with our final default value [say 120]. |
Either way seems fine. Will gmt_usage_line work for the detailed option descriptions in addition to the synopsis or will that require a separate function? Also, did you base the example synopsis in testbreak.c on any particular GMT module? I am interested in comparing the testbreak output to the current GMT output. |
Looks like it was based on grdedit. This was only for the synopsis. The individual descriptions is tricker because some are done by a functino and others are inline. But perhaps that can still be handled and the break-function could be told to honor \n to break when we want to break, etc. |
Thanks for the explanation. This is nice, I think that giving the user the ability to define their preferred message length is a worthwhile improvement. When the ⏎ symbol is not used, I find it slightly more readable to use only three periods on the continued line, rather than two spaces and three periods.
It will still be necessary to define the preferred line length for the reformatted synopsis and long descriptions in the source code if GMT_Message() gets refactored to GMT_Wrap() in some places; it would be nice to close this issue at the same time by adding the decided convention to CODE_CONVENTIONS.md. I agree with @joa-quim's suggestion of 120-130 chars. |
Yes, I agree. 120-130 is probably good, but once we implement a parameter then we can play with it easier and get a sense for an optional one - perhaps we can even think of a way to determine the "best" length given the lines we have. As is my habit for silly things like this, I just coded away until it worked. Not much design planning, and it is possible there are corner cases I did not consider that won't be easy to shoehorn in etc. But the basics are there I think. If we could simply transfer all those GMT_Message lines to a single string, e.g.,
to
and then call |
Not exactly helping but I still can't get |
Looks like I forgot to give the magic information that you must enable this in your cmake/ConfigUserAdvanced.cmake:
otherwise it does not compile all the test*.c codes that only developers care about. Sorry about that. |
Also, after building this branch you can add it to your
where |
Ahhhh, with the magic information I got it to work. Thanks, @PaulWessel. And thank you @meghanrjones for the reminder. Unfortunately it doesn't break cleanly after 80 chars for me: |
True, it was written with the count as "guidance" and break on the next nearest opportunity. Breaking at exactly 80 means in the middle of arguments which I think is an affront to all human decency... |
The terminal window in the screenshot above is 80 chars wide. My understanding was that I give the terminal width and therefore the count acts as limit and not as guidance. Maybe break < 77 for the |
I can probably change the code to keep track of the last break point and when we exceed the count go there. |
@PaulWessel do you see a chance for the deluxe version? Get the current size of the terminal window and break accordingly? I'm not a C-programmer but maybe https://stackoverflow.com/questions/1022957/getting-terminal-width-in-c#1022961 is a starting point? If feasible this would end the discussion between the 80x24 supporters and the "I have a monster display and I want to use it" crowd as well without resorting to a fixed break count at build time or as a variable. |
We could try. First will need to see if @joa-quim can try the simple code in the link you provided and see if it even works for Window. It worked fine in macOS. |
While the ISO code for the fancy return did not work for @joa-quim, I would be astonished if there is not some other glyph that Windows has that we could pick if on Windows. |
OK, I think we want those extra lines as they clearly makes it easier to see the paragraphs. I have update the code for the common options and the three modules gmtsimplify, plot, and basemap. |
Nice, @PaulWessel! I really like it. While reading through the reformatted Try for yourself: I don't know about Windows. Maybe @joa-quim can paste And yes, I smell feature creep. It has nothing to do with "Explore how to break synopsis lines". Your thoughts? |
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.
Really happy with the new layout!
Hi @KristofKoch. @meghanrjones and I decided that even if we started now it would take some time to implement this new scheme across all modules without seriously delaying GMT 6.2.0. So I think we will continue work on this branch but not let is stop us from releasing 6.2.0. We sill start with RC1 soon but probably after our community meeting on Thursday. Thus. we can continue to experiment with bold/italics styles - it is an interesting suggestion and I guess there are escape sequences to do the switcharoo. Your examples above did not do anything for me though (macOS), so this depends on other things than UTF-8. |
I agree |
I agree not to delay 6.2 for this, @PaulWessel and @meghanrjones. The bold font doesn't work for you @PaulWessel? I'm on MacOS as well and it works for me in the default Terminal.app and in my usually used iTerm.app. |
Turns out it does not work when your Terminal's font was set to Courier Bold... |
We will merge this into master and prioritize updating the 150 modules for 6.3. All comment options have been updated already. I just now replaced OPTIONS: with OPTIONAL ARGUMENTS and added REQUIRED ARGUMENTS to the three modules I have worked on. Please have a final check - one question: I think we may want to change the indentation of the ...ARGUMENTS line since it is using a tab which is no longer used by the others. Perhaps 2 spaces will work here? |
Yes, I agree that it would look better aligned evenly with either 'usage' or the arguments, but not indented further than everything else. |
OK, done, will wait for internal tests to give green light, then merge. |
See #4762 for background. This PR adds a new testbreak.c program that can be used for exploring auto-breaking. Since it is not a GMT module, it gets built and placed in build/src so you need to run it from there. Its syntax is
testbreak [length [-]]
Here, length is the nominal width of the synopsis output [80]. If you give a length then you may also give an optional - to select @KristofKoch's fancy UTF-8 carriage-return symbol ⏎ for line continuation; otherwise you get @joa-quim's sad .....
Behavior: We try to make output records around the length. If adding the next word greatly exceeds length then we try to break it at a ] and append a "line to be continued" marker, and indent 2 spaces on the continuation line.
Examples:
testbreak
testbreak 100 -
The idea is that we would just make one lone text string at top of each usage() function then call this gmt_usage_line function to display according to our width rules. It could even be a GMT parameter [GMT_SYNOPSIS_WIDTH = 120].