use the caml_example environment in the Extensions manual#1209
use the caml_example environment in the Extensions manual#1209gasche merged 3 commits intoocaml:trunkfrom
caml_example environment in the Extensions manual#1209Conversation
|
For the first point, on the html side the On the second point, the generated html code looks fine, this is probably a matter of tuning the margin/padding in the manual css style. For 3, I think that wrapping the example in a module type definition before sending it to the toplevel might do the trick. |
manual/manual/refman/exten.etex
Outdated
| let a = A | ||
| let b n = assert (n > 0); B n | ||
| end | ||
| \end{caml_example} |
There was a problem hiding this comment.
May I suggest to add a star here \end{caml_example*} to not betray the illusion that caml_example is a latex environment? (pure nitpicking, I wholeheartedly admit)
manual/manual/refman/exten.etex
Outdated
| \end{verbatim} | ||
| \begin{caml_example*}{verbatim} | ||
| type t = [ `A of int | `B of bool ] | ||
| \end{caml_example} |
|
I dislike LaTeX programming, so I don't plan to work on it. On the other hand I'll try to propose a patch for the html/css part along the lines proposed. (I'm interested in feedback on what future we want for this PR. Should we wait for the display issues to be fixed before considering a merge? Should we complete the porting of the chapter? (I would at least support the second option.)) |
|
Completing the porting of the current section seems like a good idea: it increases the number of examples available for tuning the rendering afterwards. Moreover, since the fix for the rendering should be mostly independent from the manual changes, I don't see a lot of negatives with merging this PR before the rendering the fix. ((In term of negatives, I imagine that the rendering changes might require some micro-tuning of the manual examples)). |
|
Three months later, where are we on this GPR? |
|
I haven't worked on it since, and I would rather not merge the change before the rendering gets improved. On the other hand, it's a low-conflict PR so it can stay open for longer. Thanks for the WIP tag, it's appropriate. |
|
@gasche , is there any obstacle (except the current conflict) remaining before merging? |
|
I don't remember. I will fix the conflicts and rebase, and then maybe you could think about it, and if applicable accept and merge? |
|
I'm looking at it now and it turns out that #1702 would be useful to go further on this PR. |
|
I have rebased #1702 (and moved the change entry to trunk). |
caml_example environment in the Extensions manualcaml_example environment in the Extensions manual
|
I have rebased this PR, and added quite a few uses of caml_example. The remaining |
|
Re dots.: a lot of the manual examples look like @Octachron, as the manual/tools wizard, do you know if it would be possible to render this out of something like ? |
|
It sounds possible. However, in order to have a robust behavior with attributes, the best choice is probably to parse each phrase and extract the location of each ellipsis from the parse tree. |
|
This is what is done for expect-tests in testsuite/tools/expect_test.ml. While we are at it, another random feature request inspired by this PR: if I pass Edit (August 2018): the question above has been fixed by #1863. |
|
I just rebased this against #1765. |
| let _ = Hashtbl.add devices "SVG" (module SVG : DEVICE) | ||
|
|
||
| module PDF = struct let draw () = ()[@@ellipsis] end | ||
| let _ = Hashtbl.add devices "PDF" (module PDF: DEVICE) |
There was a problem hiding this comment.
@Octachron I think that you may find this block of code interesting.
The first ellipsis is used in place of a separate {caml_eval} block as I had in my previous version (before the last rebase), and it suggests that maybe longer-term we could think of using [@hide] attributes that are completely removed instead of a separate environment.
The second ellipsis has this form, instead of a signature-item attribute, because of the issue I reported in https://github.com/ocaml/ocaml/pull/1765/files#r186431706. I am trying to come with a fix for the issue, but maybe we could consider trying to get this PR merged before that -- it's been long enough in the baking.
There was a problem hiding this comment.
I agree that it would be nice to merge soon. I will do a full review by tomorrow.
that maybe longer-term we could think of using [@hide] attributes that are completely removed instead of a separate environment.
This is definitively doable. At the same time, I fear that mixing hidden and non-hidden code fragment too freely might be confusing for the reader.
There was a problem hiding this comment.
Thinking more about it, I think we should wait until we agree on what to do with #1765 before merging.
9cb4c0a to
64a0cf4
Compare
|
I just rebased this PR on top of #1903, and the ellipsis machinery now works correctly in all examples where it is used. @Octachron note that I added a patch, currently 48ea928, to simplify the location-handling in the ellipsis code, now that attributes carry their whole location. |
| let scale l = function | ||
| | Point p -> Point {p with x = l *. p.x; y = l *. p.y} | ||
| | .... | ||
| | Other -> Other |
There was a problem hiding this comment.
Was this change by choice or due to the lack of attribute on case? If it is the second, using
| Other[@ellipsis.start] -> Other[@ellipsis stop] would work after a small fix that I can send as a sub-PR.
There was a problem hiding this comment.
In that case I think that showing the full code is just as well. In your sub-PR, can you include a test somewhere? I should also add a regression test for val picture : picture -> unit[@@ellipsis] which I had a lot of trouble not to get rendered as val picture : picture -> ....
There was a problem hiding this comment.
I think I will make a test PR for ellipsis attributes in general.
manual/manual/refman/exten.etex
Outdated
| module type DEVICE = sig [@@@ellipsis] end | ||
| let devices : (string, (module DEVICE)) Hashtbl.t = Hashtbl.create 17 | ||
| type picture = unit[@ellipsis] | ||
| module type DEVICE = sig val draw : picture -> unit [@@ellipsis] end |
There was a problem hiding this comment.
I would propose to have a separate ellipsis [@@@ellipsis] to have
module type DEVICe = sig
val draw:picture -> unit
...
endrather than just sig ... end since it gives a clearer purpose to picture.
| caml-tex: $(CAMLTEX) | ||
| ../runtime/ocamlrun ../ocamlc -nostdlib -I ../stdlib $(LINKFLAGS) \ | ||
| -linkall -o $@ $(CAMLTEX) | ||
| -linkall -o $@ -no-alias-deps $(CAMLTEX) |
There was a problem hiding this comment.
I am curious, what is the story behind this -no-alias-deps?
There was a problem hiding this comment.
If you remove it, the build fails because Parsetree (to which an alias is introduced in #1903) has no .cmo to link against. This sounds strange, but module M = Foo is broken on all OCaml versions if Foo is mli-only and you don't use no-alias-deps.
64a0cf4 to
0c5e51f
Compare
|
I rebased on top of trunk, implementing @Octachron's recommendation (to show |
0c5e51f to
acc2c70
Compare
I wanted to test a caml_tex issue by creating a smaller .etex file than exten.etex, and got bitten by the fact that the Makefile hardcode the knowledge that only exten.etex uses caml_example.
acc2c70 to
3e588dc
Compare
Co-authored-by: Cuihtlauac ALVARADO <cuihtmlauac@tarides.com>
This PR, which continues work started in #939 as tracked in MPR#7551, has one well-defined commit that I believe is correct, but I marked it work-in-progress as:
{caml_example}{verbatim}environment (from MPR#7551: manual, make final ";;" potentially optional in caml_example #1194) that we may want to discuss and potentially fix before going furtherTo that end I uploaded a temporary rendering of the PR manual.
If you look at the Recursive modules section for example, you may notice that
#at the beginning of the code example does not look nice (we are supposed not to be in the toplevel)I think that it would be useful to think (cc @Octachron !) about fixing (1) and (2) before considering merging this or going further with the
caml_example-ization of this section.