Skip to content
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

Add support for Reason doc generation #1117

Closed
rizo opened this issue Aug 9, 2018 · 16 comments · Fixed by #6010
Closed

Add support for Reason doc generation #1117

rizo opened this issue Aug 9, 2018 · 16 comments · Fixed by #6010
Assignees
Labels

Comments

@rizo
Copy link
Contributor

rizo commented Aug 9, 2018

(Continued from ocaml/odoc#156 (comment))

We recently introduced support for Reason syntax generation in odoc.

Specifically, the following option is now implemented:

$ odoc html [--syntax=<ml|re>]   (default=ml)

It would be great if dune had the ability to pass this option to odoc and thus allow users to generate either or both syntaxes.

A few options were discussed:

  1. Introduce different targets for each syntax: @doc and @reason-doc (suggested by @rgrinberg).
  2. Decide which syntax to generate based on the file extension (suggested by @diml).

The second option seems very natural and doesn't require user-facing changes but it also doesn't allow the generation of both syntaxes at the same time.

Note: The --lang option mentioned in this issues was renamed to --syntax.

@rizo
Copy link
Contributor Author

rizo commented Aug 9, 2018

My suggestion is to implement the first option, albeit with some minor changes:

$ dune build @doc-re  # Pass `--syntax=re` to odoc
$ dune build @doc-ml  # Pass `--syntax=ml` to odoc
$ dune build @doc     # Call both above targets

I understand this would change the meaning of the current @doc target. My motivation comes from the fact that we will want to introduce the ability to switch the syntax in the generated HTML, thus I believe this should be the default behaviour.

(CC @aantron @ryyppy)

@ghost
Copy link

ghost commented Aug 9, 2018

Does --lang=ml requires to have reason installed?

@rizo
Copy link
Contributor Author

rizo commented Aug 9, 2018

@diml No, and neither does --lang=re. This option only affects the HTML generation.

In general we will try to be careful with dependencies and will only introduce reason dependencies (like refmt) in a modular/optional way.

@ghost
Copy link

ghost commented Aug 9, 2018

Ah yes, I meant --lang=re. Do you have your own reason pretty-printer? (just curious)

@rizo
Copy link
Contributor Author

rizo commented Aug 9, 2018

@diml The Reason HTML generation is only done for signature items where pretty-printing is applied directly to odoc's internal model. So, yes, it's an ad-hoc AST pretty-printer. It's not ideal, but the same applies to the OCaml syntax.

This also means that examples in code blocks are not currently translated (but will be in the future).

@ryyppy did actually implemented code translation/formatting but it's currently commented out. For some context see Combining ocamlformat & refmt – OCaml Discuss.

Coming back to your previous questions: I'm not sure if --lang=re will in the future require the reason library. I'd prefer to keep it optional via a custom odoc tag or a ppx.

I think I understand your concern: are you worried about dune build @doc requiring reason as a dependency even for OCaml-only projects?

@aantron
Copy link
Collaborator

aantron commented Aug 9, 2018

The second option also makes it difficult to present OCaml-syntax projects for Reason people and vice versa. So, I prefer (some variant of) the first.

@ryyppy
Copy link
Member

ryyppy commented Aug 10, 2018

The second option seems very natural and doesn't require user-facing changes but it also doesn't allow the generation of both syntaxes at the same time.

I don't understand.. why isn't it possible to generate both version of the same time? I believe it's the contrary, with the first version you won't be able to mix ML / RE code. If I know the original file format, I can proactively build the contrary version as well?

also, @diml @aantron @rgrinberg, if we settle on a rough decision, I would like to take a stab at this and create a PR. We can figure out details on the way?

@rizo
Copy link
Contributor Author

rizo commented Aug 10, 2018

@ryyppy Technically you're right – both versions can be generated even with option 1. But in practice, in that case, the extension doesn't matter because odoc operates on cmti/cmi and not mli/rei files. With that approach dune would always generate both versions, which is less flexible.

Assuming that we won't introduce reason as a dependency, I believe this suggestion would work well.

FYI: We decided to rename the --lang flag to --syntax to be consistent with dune's naming.

@rizo
Copy link
Contributor Author

rizo commented Aug 10, 2018

As far as I understand, dune can already determine if reason installation is available. This would help with the unlikely event of odoc --syntax=re requiring something like refmt in the future. In that situation I imagine dune build @doc would only generate the OCaml version of the docs, and produce a warning informing that the Reason version couldn't be generated.

Does that sound sensible?

@aantron
Copy link
Collaborator

aantron commented Aug 10, 2018

@rizo Location information in each .cmti/.cmt contains the source filename and extension, so I imagine Dune could easily extract that. Not arguing for this, though :)

@ghost
Copy link

ghost commented Aug 13, 2018

My concern was indeed about introducing more dependencies than necessary for someone who would only want the OCaml syntax, and also about doing more work than necessary by default. For instance, I would imagine that OCaml developers only care about the OCaml syntax and that Reason developers only care about the Reason syntax, so it seems a bit odd to me to build both by default. The only case I can think of where one would want to build both is when publishing to a web-server. In some ways it feels like it should be a global user configuration parameter. In any case, I'm happy to leave all the design decisions to odoc maintainers.

BTW, with all the modern web technologies we have, I'm slightly surprised that such as choice has to be made at compile time instead of letting the reader decide :)

@ghost
Copy link

ghost commented Aug 13, 2018

@ryyppy, independently of the final choice, the core of the work will be to adapt the odoc rules so that multiple trees of html documentation can be generated in parallel. You could indeed start by looking at this.

@ryyppy
Copy link
Member

ryyppy commented Aug 13, 2018

@diml Will start the work now! Can you assign this issue to me?

@ghost ghost assigned ryyppy Aug 13, 2018
@ghost
Copy link

ghost commented Aug 13, 2018

Done

@ryyppy ryyppy mentioned this issue Oct 4, 2018
3 tasks
@ryyppy
Copy link
Member

ryyppy commented Jan 19, 2019

Short update for this: We realized that adding a parameter to the odoc stanza doesn't make a lot of sense, so we decided to introduce an environment variable ODOC_SYNTAX in the meantime instead (thanks @rizo).

See: ocaml/odoc#280

Also, the latest idea was to make odoc render Reason & OCaml by default, the syntax variable should then be used to opt out of this behavior and only render one language.

So we should document on how to configure the odoc syntax in dune.

@ghost
Copy link

ghost commented Jan 21, 2019

Ok. We should also make the rules in dune sensible to this variable, so that things are rebuilt when this variable changes.

@rgrinberg rgrinberg added the odoc label May 15, 2022
emillon added a commit to emillon/dune that referenced this issue Jul 26, 2022
This controls the syntax of the output.

Closes ocaml#1117

Signed-off-by: Etienne Millon <[email protected]>
emillon added a commit to emillon/dune that referenced this issue Aug 1, 2022
This controls the syntax of the output.

Closes ocaml#1117

Signed-off-by: Etienne Millon <[email protected]>
emillon added a commit to emillon/dune that referenced this issue Sep 6, 2022
This controls the syntax of the output.

Closes ocaml#1117

Signed-off-by: Etienne Millon <[email protected]>
@emillon emillon closed this as completed in 63a8b6e Sep 6, 2022
emillon added a commit to emillon/opam-repository that referenced this issue Oct 11, 2022
…ne-site, dune-rpc, dune-rpc-lwt, dune-private-libs, dune-glob, dune-configurator, dune-build-info, dune-action-plugin and chrome-trace (3.5.0~alpha1)

CHANGES:

- Sandbox running cinaps actions starting from cinaps 1.1 (ocaml/dune#6176, @rgrinberg)

- Add a `runtime_deps` field in the `cinaps` stanza to specify runtime
  dependencies for running the cinaps preprocessing action (ocaml/dune#6175, @rgrinberg)

- Shadow alias module `Foo__` when building a library `Foo` (ocaml/dune#6126, @rgrinberg)

- Extend dune describe to include the root path of the workspace and the
  relative path to the build directory. (ocaml/dune#6136, @reubenrowe)

- Allow dune describe workspace to accept directories as arguments.
  The provided directories restrict the worskpace description to those
  directories. (ocaml/dune#6107, fixes ocaml/dune#3893, @esope)

- Add a terminal persistence mode that attempts to clear the terminal history.
  It is enabled by setting terminal persistence to
  `clear-on-rebuild-and-flush-history` (ocaml/dune#6065, @rgrinberg)

- Disallow generating targets in sub direcories in inferred rules. The check to
  forbid this was accidentally done only for manually specified targets (ocaml/dune#6031,
  @rgrinberg)

- Do not ignore rules marked `(promote (until-clean))` when
  `--ignore-promoted-rules` (or `-p`) is passed. (ocaml/dune#6010, fixes ocaml/dune#4401, @emillon)

- Dune no longer considers .aux files as targets during Coq compilation. This
  means that .aux files are no longer cached. (ocaml/dune#6024, fixes ocaml/dune#6004, @Alizter)

- Cinaps actions are now sandboxed by default (ocaml/dune#6062, @rgrinberg)

- Allow rules producing directory targets to be not sandboxed (ocaml/dune#6056,
  @rgrinberg)

- Introduce a `dirs` field in the `install` stanza to install entire
  directories (ocaml/dune#5097, fixes ocaml/dune#5059, @rgrinberg)

- Menhir rules are now sandboxed by default (ocaml/dune#6076, @rgrinberg)

- Allow rules producing directory targets to create symlinks (ocaml/dune#6077, fixes
  ocaml/dune#5945, @rgrinberg)

- Inline tests are now sandboxed by default (ocaml/dune#6079, @rgrinberg)

- Fix build-info version when used with flambda (ocaml/dune#6089, fixes ocaml/dune#6075, @jberdine)

- Add an `(include <file>)` term to the `include_dirs` field for adding
  directories to the include paths sourced from a file. (ocaml/dune#6058, fixes ocaml/dune#3993,
  @gridbugs)

- Support `(extra_objects ...)` field in `(executable ...)` and `(library
  ...)` stanzas (ocaml/dune#6084, fixes ocaml/dune#4129, @gridbugs)

- Fix compilation of Dune under esy on Windows (ocaml/dune#6109, fixes ocaml/dune#6098, @nojb)

- Improve error message when parsing several licenses in `(license)` (ocaml/dune#6114,
  fixes ocaml/dune#6103, @emillon)

- odoc rules now about `ODOC_SYNTAX` and will rerun accordingly (ocaml/dune#6010, fixes
  ocaml/dune#1117, @emillon)

- dune install: copy files in an atomic way (ocaml/dune#6150, @emillon)

- Add `%{coq:...}` macro for accessing data about the configuration about Coq.
  For instance `%{coq:version}` (ocaml/dune#6049, @Alizter)

- update vendored copy of cmdliner to 1.1.1. This improves the built-in
  documentation for command groups such as `dune ocaml`. (ocaml/dune#6038, @emillon,
  ocaml/dune#6169, @shonfeder)

- The test suite for Coq now requires Coq >= 8.16 due to changes in the
  plugin loading mechanism upstream (which now uses findlib).

- Starting with Coq build language 0.6, theories can be built without importing
  Coq's standard library by including `(stdlib no)`.
  (ocaml/dune#6165 ocaml/dune#6164, fixes ocaml/dune#6163, @ejgallego @Alizter @LasseBlaauwbroek)

- on macOS, sign executables produced by artifact substitution (ocaml/dune#6137, fixes
  ocaml/dune#5650, @emillon)

- Added an (aliases ...) field to the (rules ...) stanza which allows the
  specification of multiple aliases per rule (ocaml/dune#6194, @Alizter)
emillon added a commit to emillon/opam-repository that referenced this issue Oct 19, 2022
…ne-site, dune-rpc, dune-rpc-lwt, dune-private-libs, dune-glob, dune-configurator, dune-build-info, dune-action-plugin and chrome-trace (3.5.0)

CHANGES:

- macOS: Handle unknown fsevents without crashing (ocaml/dune#6217, @rgrinberg)

- Enable file watching on MacOS SDK < 10.13. (ocaml/dune#6218, @rgrinberg)

- Sandbox running cinaps actions starting from cinaps 1.1 (ocaml/dune#6176, @rgrinberg)

- Add a `runtime_deps` field in the `cinaps` stanza to specify runtime
  dependencies for running the cinaps preprocessing action (ocaml/dune#6175, @rgrinberg)

- Shadow alias module `Foo__` when building a library `Foo` (ocaml/dune#6126, @rgrinberg)

- Extend dune describe to include the root path of the workspace and the
  relative path to the build directory. (ocaml/dune#6136, @reubenrowe)

- Allow dune describe workspace to accept directories as arguments.
  The provided directories restrict the worskpace description to those
  directories. (ocaml/dune#6107, fixes ocaml/dune#3893, @esope)

- Add a terminal persistence mode that attempts to clear the terminal history.
  It is enabled by setting terminal persistence to
  `clear-on-rebuild-and-flush-history` (ocaml/dune#6065, @rgrinberg)

- Disallow generating targets in sub direcories in inferred rules. The check to
  forbid this was accidentally done only for manually specified targets (ocaml/dune#6031,
  @rgrinberg)

- Do not ignore rules marked `(promote (until-clean))` when
  `--ignore-promoted-rules` (or `-p`) is passed. (ocaml/dune#6010, fixes ocaml/dune#4401, @emillon)

- Dune no longer considers .aux files as targets during Coq compilation. This
  means that .aux files are no longer cached. (ocaml/dune#6024, fixes ocaml/dune#6004, @Alizter)

- Cinaps actions are now sandboxed by default (ocaml/dune#6062, @rgrinberg)

- Allow rules producing directory targets to be not sandboxed (ocaml/dune#6056,
  @rgrinberg)

- Introduce a `dirs` field in the `install` stanza to install entire
  directories (ocaml/dune#5097, fixes ocaml/dune#5059, @rgrinberg)

- Menhir rules are now sandboxed by default (ocaml/dune#6076, @rgrinberg)

- Allow rules producing directory targets to create symlinks (ocaml/dune#6077, fixes
  ocaml/dune#5945, @rgrinberg)

- Inline tests are now sandboxed by default (ocaml/dune#6079, @rgrinberg)

- Fix build-info version when used with flambda (ocaml/dune#6089, fixes ocaml/dune#6075, @jberdine)

- Add an `(include <file>)` term to the `include_dirs` field for adding
  directories to the include paths sourced from a file. (ocaml/dune#6058, fixes ocaml/dune#3993,
  @gridbugs)

- Support `(extra_objects ...)` field in `(executable ...)` and `(library
  ...)` stanzas (ocaml/dune#6084, fixes ocaml/dune#4129, @gridbugs)

- Fix compilation of Dune under esy on Windows (ocaml/dune#6109, fixes ocaml/dune#6098, @nojb)

- Improve error message when parsing several licenses in `(license)` (ocaml/dune#6114,
  fixes ocaml/dune#6103, @emillon)

- odoc rules now about `ODOC_SYNTAX` and will rerun accordingly (ocaml/dune#6010, fixes
  ocaml/dune#1117, @emillon)

- dune install: copy files in an atomic way (ocaml/dune#6150, @emillon)

- Add `%{coq:...}` macro for accessing data about the configuration about Coq.
  For instance `%{coq:version}` (ocaml/dune#6049, @Alizter)

- update vendored copy of cmdliner to 1.1.1. This improves the built-in
  documentation for command groups such as `dune ocaml`. (ocaml/dune#6038, @emillon,
  ocaml/dune#6169, @shonfeder)

- The test suite for Coq now requires Coq >= 8.16 due to changes in the
  plugin loading mechanism upstream (which now uses `Findlib`).

- Starting with Coq build language 0.6, theories can be built without importing
  Coq's standard library by including `(stdlib no)`.
  (ocaml/dune#6165 ocaml/dune#6164, fixes ocaml/dune#6163, @ejgallego @Alizter @LasseBlaauwbroek)

- on macOS, sign executables produced by artifact substitution (ocaml/dune#6137, ocaml/dune#6231,
  fixes ocaml/dune#5650, fixes ocaml/dune#6226, @emillon)

- Added an (aliases ...) field to the (rules ...) stanza which allows the
  specification of multiple aliases per rule (ocaml/dune#6194, @Alizter)

- The `(coq.theory ...)` stanza will now ensure that for each declared `(plugin
 ...)`, the `META` file for it is built before calling `coqdep`. This enables
 the use of the new `Findlib`-based loading method in Coq 8.16; however as of
 Coq 8.16.0, Coq itself has some bugs preventing this to work yet. (ocaml/dune#6167 ,
 workarounds ocaml/dune#5767, @ejgallego)

- Allow include statement in install stanza (ocaml/dune#6139, fixes ocaml/dune#256, @gridbugs)

- Handle CSI n K code in ANSI escape codes from commands. (ocaml/dune#6214, fixes ocaml/dune#5528,
  @emillon)

- Add a new experimental feature `mode_specific_stubs` that allows the
  specification of different flags and sources for foreign stubs depending on
  the build mode (ocaml/dune#5649, @voodoos)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants