-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add the ability to word-wrap or limit line length #364
Comments
This is needed by the Go SIG for their adoption of weaver. |
Thinking of using this: https://docs.rs/textwrap/latest/textwrap/ |
@jsuereth yes I had the same crate in mind. |
Alright - the prototype is looking ok, but we'll need to sort out word splits a bit. E.g. The current algorithm in my draft PR does this:
I believe I may just update the word-slicing logic to avoid seeing The other problematic situation - Markdown and word-wrap interactions:
@MrAlias From a go perspective, if you see markdown lists of this long variety, what would you want to see? Does go format markdown in comments? I'm going to investigate the library a bit more to see how we could deal with this scenario. |
+1 to not making this split 👍 |
Go does format these lists (https://tip.golang.org/doc/comment#lists). Unfortunately, it does not match exactly markdown list formatting rules. It requires a prefix space. We do utilize this in place (https://pkg.go.dev/go.opentelemetry.io/otel/metric#hdr-Instrument_Name), but for the semconv it is sort-of used just not rendered correctly: |
@MrAlias Could you verify this expected test output is my target for rendering Go? See: https://github.com/open-telemetry/weaver/blob/e54635b8aef2058ca3df207a3e86144fca636e9a/crates/weaver_forge/expected_output/comment_format/example.go |
Looks great! 🚀 |
Don't celebrate too early - Think it's going to take a while to get that output :) Going to have a think about how to use the markdown rendering + word-wrapping library together, it looks like we may be either doing our own thing or very clever point-fixes to word-splits :) |
We should be able to define the maximum line length for comments, for example. Several approaches are possible:
word_wrap
filter that would take a maximum number of characters per line as a parameter.indent
filter to specify a maximum number of characters per line, accounting for indentation.comment_formats
section to specify the preferred maximum line length for comments, per language.These options are not mutually exclusive. Personally, I would be inclined to start with 2 and 3.
The text was updated successfully, but these errors were encountered: