-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Make pragmas look clickable in docs #8176
Conversation
Sorry, can you give us some nice before-after screenshots? :-) |
Wouldn't it make more sense to add a dotted line beneath these? |
The line between the dots is better, but still too subtle. |
Yeah, I like this solution best. |
If we're going with this, I think it's important to address one thing: Clicking between the braces to reveal the pragmas signifies (to me at least) that one should click between the braces again to hide the pragmas. So the shown content should be clickable rather than the braces. It would be a little weird, though, and frankly I don’t think doing it this way is a great idea. The content shown is conceptually that--content, not navigation. However, I'm not sure a great alternative. Show content on hover-on and hide it in hover-off would work, but that's also a bit janky. |
Let's just use |
Nah, there is little need to hide the pragma after it has been shown. I say just keep the pragmas there with no option to hide them. |
Or that, ok. |
OK to change docgen.nim for this, or should be pure JS/CSS? |
We don't use JS when we can help it. |
config/nimdoc.cfg
Outdated
@@ -1330,15 +1330,23 @@ dt pre > span.Operator ~ span.Identifier { | |||
background-repeat: no-repeat; | |||
background-image: url("data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="); | |||
margin-bottom: -5px; } | |||
<<<<<<< HEAD |
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.
You committed some merge conflicts by mistake.
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.
Ah, dammit. My bad. Will fix now.
config/nimdoc.cfg
Outdated
} | ||
======= | ||
>>>>>>> Visual cues at hidden pragmas in docs. |
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.
See those "<<<<<<<" and ">>>>>>>".
compiler/docgen.nim
Outdated
## Remove leading whitespace and trailing newlines from every line | ||
result = "" | ||
for line in html.split("\n"): | ||
for i, c in line: |
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.
Two space indent
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.
Use splitLines
and strip
.
compiler/docgen.nim
Outdated
@@ -222,6 +222,10 @@ proc getPlainDocstring(n: PNode): string = | |||
result = getPlainDocstring(n.sons[i]) | |||
if result.len > 0: return | |||
|
|||
func htmlCollapse(html: string): string = |
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.
Don't use func
, it's too new. Also it's used nowhere else in docgen.nim
.
compiler/docgen.nim
Outdated
@@ -222,6 +222,10 @@ proc getPlainDocstring(n: PNode): string = | |||
result = getPlainDocstring(n.sons[i]) | |||
if result.len > 0: return | |||
|
|||
func htmlCollapse(html: string): string = | |||
## Strip whitespace and remove trailing newlines from every line | |||
return html.splitLines().mapIt(strip(it)).join("") |
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.
Why is this required anyway?
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.
This implementation has terrible performance. ;-)
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.
I wrote it so I could format the HTML later in the code. Since that HTML ends up inside of a <pre>
, it has to be collapsed.
The poor performance is from the string concatenation, yes? I should be using result.add
?
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.
Actually, a quick benchmark on my machine shows a ~1.6x speedup using result.add
, except when in -d:release
, in which case it's about the same or slower! So I'm not totally sure what optimizations you're looking for?
Ah, some styling that I thought was fixed is acting up again. Don't merge yet. |
It should be good now. Unfortunately, I only have Chrome on my dev laptop so I have only tested on Chrome. I figure the changes are simple enough that it shouldn't be a problem. I can rig something up to do cross-browser testing if you'd like, though. |
Update: apparently I also have Firefox 58.0 installed. It looks fine. |
Hopefully I found the right file!
In documentation, the clickable
{..}
pragmas currently don't look clickable. They look like normal code and, given that it's not unreasonable to think that{..}
is valid (if superfluous) code, that's what some users might think. I sure did.