-
ContextThe Koka book is so cool because hovering over types shows a tooltip with the type name. Clicking on the type name takes us to the definition of the type (in the standard library, etc). QuestionsI wonder where/how all this is implemented in Koka? Specific questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
:-) Thanks! Yeah, the Koka compiler generates a "range map" with type information etc for each compilation unit and this is used for example by the VSCode language server that @fwcd is working on (#100). But also it is used to generate the documentation for the standard libraries and documentation. The documentation uses Koka's "literal" mode with Anyway, the tooltips are pure css, the file /* popup boxes: for space we call this pp (for popup) and pc (for popup-content) */
a.pp {
position: relative;
text-decoration: none;
color: black;
}
.pc {
display: none;
}
a.pp:hover {
z-index: 100;
text-decoration: none;
}
a.pp:hover .pc, .tooltip {
display:block;
position:absolute;
top:1.5em;
left:2ex;
padding: 0.2ex 0.75ex 0.2ex 0.5ex;
border:1px solid black;
background: #fffdf0;
white-space: pre;
}
a.pp a.pp:hover .pc
{ top: 3em } |
Beta Was this translation helpful? Give feedback.
:-) Thanks! Yeah, the Koka compiler generates a "range map" with type information etc for each compilation unit and this is used for example by the VSCode language server that @fwcd is working on (#100). But also it is used to generate the documentation for the standard libraries and documentation. The documentation uses Koka's "literal" mode with
kk.md
files. You can find this in thedoc/spec
directory but it is all undocumented for now; theutil/docs
script generates it all (usestack exec koka -- util/docs
to run it).Anyway, the tooltips are pure css, the file
doc/koka.css
specifies this. Essentially there are link elements<a>
with a class.pp
(for popup) and inside the link elements…