-
Notifications
You must be signed in to change notification settings - Fork 90
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
HTML: Match rendering of polymorphic variant with normal variants #971
Conversation
Signed-off-by: Paul-Elliot <[email protected]>
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.
Also, silly question sorry but related to Jon's issue: why do we <ol>
?
src/html_support_files/odoc.css
Outdated
.spec.type .poly-variant > code { | ||
min-width: 2ch; | ||
} | ||
.spec.type .poly-variant > code + code { | ||
min-width: calc(40% - 2ch - 0.6ex); | ||
/* In polymorphic variants, the | is not included in the first code block, so we | ||
need to accound for its size */ | ||
} | ||
|
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.
That seems fragile.
Why don't we just wrap the whole left/1st column and set the min-width
on that? (I assume it's for regularity with other type declarations ... but I also don't quite understand why |
is handled differently here then).
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.
Yes, this is fragile (and was already).
The reason the html generated in case of polymorphic variant is structured differently from the one for variants, is that it is already the case at the intermediate document representation.
I was afraid of changing the intermediate representation, as that would require me to check that it does not break anything in other backends. But maybe that is a better solution.
Let's add my own silly question: what else would you suggest to use ? |
let attrs = [ "def"; Url.Anchor.string_of_kind url.kind ] in | ||
let attrs = | ||
[ "def"; "poly-variant"; Url.Anchor.string_of_kind url.kind ] | ||
in |
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'm not sure exactly why you had to change the generator to fix this issue (odig
's stylesheet have no problem with this without that) but, why not…
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.
Thinking more about this I'm not sure it's really a good idea to add more to the markup to distinguish polymorphic variants from regular ones. I don't really see a good use case for it (except for people making stylesheets more complex than they could be).
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 think it is related with odoc doing something more complex, when the size of the comment is small, the comment is in the same line and takes 50% of the space, otherwise it takes more space and is wrapped below (see the screenshot or some file where it happens).
I don't know if that's worth the trouble, but I think that's the difference with odig
, which displays comments in a simpler way (from a quick look at the stylesheet, I might be wrong).
There might be a way to do it without, but since variant and fields had their classes, it felt natural to add one for polymorphic variants
I think you should add the example with a short comment and a long comment for the case to the ocamlary, it's useful for people developing stylesheets, since that's a case they will have to handle. Also it would be nice to provide a link to the |
👍
I would have thougth |
I'll do that
The html generator has to use |
If one believes in semantic markup (no one does :-) then I'd say at least for variants it's more "correct". There is a notion of order between case (but for polymorphic ones it won't match, the
As far as I see
I think it would be more natural not to distinguish variants and polymorphic variants. These are just list of cases, it's unlikely you want to style them differently. Adding one more class is just adding more selectors to handle and makes your stylesheets more complex, which, trust me, you definitively do not want. Basically I think Footnotes
|
17e133c
to
fa22aea
Compare
Thanks for the advice. So, I went with the even simpler approach of having only "long comments": This was also requested in #847 (comment), so at least it will please one person. Let me know what you think! I also added a link to the ocamlary module from the index page. |
If you need to keep the blocks it's certainly better the way you suggest.
Thanks! |
The same problem remains with extensions of extensible variants, so you would need to add more selectors for |
I cherry picked @wikku's commit that makes the generated html for polymorphic variants match the one for normal variants. I also added the So, the rendering of normal constructors, extension constructors and polymorphic variants should be exactly the same, and stay the same no matter how we modify the css. The rest of this PR is:
|
2ac9780
to
701f2e9
Compare
- Consider poly-variants as variants - Always go to line to display a doc-comment Signed-off-by: Paul-Elliot <[email protected]>
and add an example of comments associated to polymorphic variants Signed-off-by: Paul-Elliot <[email protected]>
For consistency with variants. In the HTML backend, this merges two <code> elements into one.
Signed-off-by: Paul-Elliot <[email protected]>
Signed-off-by: Paul-Elliot <[email protected]>
Signed-off-by: Paul-Elliot <[email protected]>
CHANGES: ### Added - Add support for external search engines (@panglesd, @EmileTrotignon, ocaml/odoc#972) This includes the generation of an index and the display of the results in the UI (HTML only). - Display 'private' keyword for private type extensions (@gpetiot, ocaml/odoc#1019) - Allow to omit parent type in constructor reference (@panglesd, @EmileTrotignon, ocaml/odoc#933) ### Fixed - Warn and exit when table(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Hint when list(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Fix crash on functors returning an alias (@Julow, ocaml/odoc#1046) - Fix rendering of polymorphic variants (@wikku, @panglesd, ocaml/odoc#971) - Add references to extension declarations (@gpetiot, @panglesd, ocaml/odoc#949) ### Changed - Style: Adjusted line height in the TOC to improve readability (@sorawee, ocaml/odoc#1045) - Style: Remove font fallback to Helvetica, Arial (@Julow, ocaml/odoc#1028) - Style: Preformatted elements fallback to UA monospace (@toastal, ocaml/odoc#967) - Style: Sidebar is now stuck to the left of the content instead of the left of the viewport (@EmileTrotignon, ocaml/odoc#999)
CHANGES: ### Added - Add support for external search engines (@panglesd, @EmileTrotignon, ocaml/odoc#972) This includes the generation of an index and the display of the results in the UI (HTML only). - Display 'private' keyword for private type extensions (@gpetiot, ocaml/odoc#1019) - Allow to omit parent type in constructor reference (@panglesd, @EmileTrotignon, ocaml/odoc#933) ### Fixed - Warn and exit when table(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Hint when list(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Fix crash on functors returning an alias (@Julow, ocaml/odoc#1046) - Fix rendering of polymorphic variants (@wikku, @panglesd, ocaml/odoc#971) - Add references to extension declarations (@gpetiot, @panglesd, ocaml/odoc#949) ### Changed - Style: Adjusted line height in the TOC to improve readability (@sorawee, ocaml/odoc#1045) - Style: Remove font fallback to Helvetica, Arial (@Julow, ocaml/odoc#1028) - Style: Preformatted elements fallback to UA monospace (@toastal, ocaml/odoc#967) - Style: Sidebar is now stuck to the left of the content instead of the left of the viewport (@EmileTrotignon, ocaml/odoc#999)
CHANGES: ### Added - Add support for external search engines (@panglesd, @EmileTrotignon, ocaml/odoc#972) This includes the generation of an index and the display of the results in the UI (HTML only). - Display 'private' keyword for private type extensions (@gpetiot, ocaml/odoc#1019) - Allow to omit parent type in constructor reference (@panglesd, @EmileTrotignon, ocaml/odoc#933) ### Fixed - Warn and exit when table(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Hint when list(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Fix crash on functors returning an alias (@Julow, ocaml/odoc#1046) - Fix rendering of polymorphic variants (@wikku, @panglesd, ocaml/odoc#971) - Add references to extension declarations (@gpetiot, @panglesd, ocaml/odoc#949) ### Changed - Style: Adjusted line height in the TOC to improve readability (@sorawee, ocaml/odoc#1045) - Style: Remove font fallback to Helvetica, Arial (@Julow, ocaml/odoc#1028) - Style: Preformatted elements fallback to UA monospace (@toastal, ocaml/odoc#967) - Style: Sidebar is now stuck to the left of the content instead of the left of the viewport (@EmileTrotignon, ocaml/odoc#999)
CHANGES: ### Added - Add support for external search engines (@panglesd, @EmileTrotignon, ocaml/odoc#972) This includes the generation of an index and the display of the results in the UI (HTML only). - Display 'private' keyword for private type extensions (@gpetiot, ocaml/odoc#1019) - Allow to omit parent type in constructor reference (@panglesd, @EmileTrotignon, ocaml/odoc#933) ### Fixed - Warn and exit when table(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Hint when list(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Fix crash on functors returning an alias (@Julow, ocaml/odoc#1046) - Fix rendering of polymorphic variants (@wikku, @panglesd, ocaml/odoc#971) - Add references to extension declarations (@gpetiot, @panglesd, ocaml/odoc#949) ### Changed - Style: Adjusted line height in the TOC to improve readability (@sorawee, ocaml/odoc#1045) - Style: Remove font fallback to Helvetica, Arial (@Julow, ocaml/odoc#1028) - Style: Preformatted elements fallback to UA monospace (@toastal, ocaml/odoc#967) - Style: Sidebar is now stuck to the left of the content instead of the left of the viewport (@EmileTrotignon, ocaml/odoc#999)
CHANGES: ### Added - Add support for external search engines (@panglesd, @EmileTrotignon, ocaml/odoc#972) This includes the generation of an index and the display of the results in the UI (HTML only). - Display 'private' keyword for private type extensions (@gpetiot, ocaml/odoc#1019) - Allow to omit parent type in constructor reference (@panglesd, @EmileTrotignon, ocaml/odoc#933) ### Fixed - Warn and exit when table(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Hint when list(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Fix crash on functors returning an alias (@Julow, ocaml/odoc#1046) - Fix rendering of polymorphic variants (@wikku, @panglesd, ocaml/odoc#971) - Add references to extension declarations (@gpetiot, @panglesd, ocaml/odoc#949) ### Changed - Style: Adjusted line height in the TOC to improve readability (@sorawee, ocaml/odoc#1045) - Style: Remove font fallback to Helvetica, Arial (@Julow, ocaml/odoc#1028) - Style: Preformatted elements fallback to UA monospace (@toastal, ocaml/odoc#967) - Style: Sidebar is now stuck to the left of the content instead of the left of the viewport (@EmileTrotignon, ocaml/odoc#999)
Fix #970
Mostly CSS, I just needed to add one class.
Quite cumbersome due to the differences in document on how polymorphic variants and normal variants are turned into a document value. But modifying the CSS seemed still less work (and with less unexpected consequences in other backend) than modifying the document generator to "unify" normal and polymorphic variants.
Previous:
Now: