-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Use soft linebreaks for constant doc styles #5657
Conversation
Could you show a screenshot before/after to explain visually what this does? Ty |
@bew sure! before:after: |
I think this is invalid. If |
Maybe we should fix the doc templates to use PRE instead for constant summaries, or some kind of inline block? Having a nicely formatted value is definitely nicer, but having CODE == PRE seems too much. |
From my understanding of it this commit just makes One important difference, however, is that using In any case, I'd suggest using .entry-const code {
white-space: pre-wrap;
} Ref: |
In the long term it may be ideal to use I say that we merge this CSS fix for now, until there's a valid reason to change what isn't broken. |
Am I missing something or isn't this just that we somewhere generate (from Markdown) a |
The styling works fully as intended, just that this constant's definition is too scary for docs. I expect numerous doc regressions if this is merged, because presumably this affects method parameters as well |
762a7ab
to
851c3b2
Compare
I've force-pushed changes with @gloverdonovan's suggestion. |
Since |
Maybe the title should be updated to reflect what this pull request actually does? |
@gloverdonovan I updated the PR title accordingly(?) |
@ysbaddaden @jhass @oprypin ready for another review |
Maybe constant values shouldn't be shown in the docs. |
Values would be fine, it's the chunks of source code that's the problem. |
What are values? You mean just show literals like numbers and strings? Maybe that's a good compromise. |
I see it as exacerbating the problem. Before, we have an unwanted chunk of code taking up 3 lines, and after, we have it taking up 8 lines. |
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.
Oh, actually, before this change, the chunk of code is also non-runnable (newlines are missing and not replaced by semicolons). So yeah, it's an improvement, although it kinda hides the root problem.
I think what @oprypin says is exactly the thing. There's a problem: constant values look ugly. So a fix is to make it beautiful. Another fix is to hide them, because they are irrelevant. I originally included values in constants because of enum members, to know their values (I don't know why, though). So instead of rushing and "fixing" this we are taking some time to discuss what's the real problem and what a good solution might be. |
@asterite I strongly disagree on the value of constants being irrelevant for API docs. They are certainly not always meaningful, but on many occassions it's super useful to know. Especially when it's just a plain literal: MAX_CODEPOINT = 0x10FFFF It wouldn't hurt to have some lines about the details alongside, but you shouldn't need to wrap that plain value in prose. If it's more complicated than that, for sure, there is no point in printing all this: STDERR = (IO::FileDescriptor.new(2, blocking: (LibC.isatty(2)) == 0)).tap do |f| f.flush_on_newline = true end Or the Readline example mentioned in the OP. In such cases, it is essential to have a doc string describing all the details about this constant, it's value and usage. Perhaps it would be nice to add the inferred type alongside the name, but nothing else. |
@asterite Before now there was no discussion about constants being irrelevant in docs. This PR fixes only the presentation layer (you have new lines - then show 'em!). ATM we have a mess - we see the values, yet we see them garbled. How bad is fixing this? |
From #6118 (comment) by @asterite:
Shall we use that approach, merge this and discuss future improvements in another issue/pr? |
Actually, what we can do is to change the doc generator to only show simple constants, like numbers, booleans, chars and strings. Everything else could be hidden. |
@asterite Personally I'd find it counter-intuitive and misleading. Anyhow, let's discuss this in a new issue/pr please. |
@Sija Do you find the value of We can always show a "show source" that leads to where the constant is defined, and there you can see the value. |
Personally I'd find it counter-intuitive and misleading. Anyhow, let's discuss this in a new issue/pr please. |
It's impossible (for me) to work out if this is the right change, it's just CSS so lets merge it and see if anything breaks with existing |
Fixes cases like
KeyBindingHandler
constant entry inReadline
docs.