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

Pass --warn-error to Odoc with (env ..) #3029

Merged
merged 2 commits into from
Feb 24, 2020

Conversation

Julow
Copy link
Contributor

@Julow Julow commented Jan 13, 2020

Alternative PR to #3018

This PR adds a way to pass --warn-error to Odoc by adding a field to the env stanza:

(env
 (<profile>
  (odoc
   (warnings fatal))))

Warnings can be set to fatal or nonfatal. They are nonfatal by default (for now).

Enabling this option and having an Odoc version that doesn't support it is an error. (no attempt is made to catch this)

@Julow Julow force-pushed the odoc_warn_error_env branch from 674c35b to 8e89a0c Compare January 13, 2020 18:26
@Julow Julow mentioned this pull request Jan 13, 2020
@ghost
Copy link

ghost commented Jan 15, 2020

Enabling this option and having an Odoc version that doesn't support it is an error. (no attempt is made to catch this)

Just update the odoc conflict in the dune-project file. No need to make life complicated :)

(cd _build/default/_doc/_html && %OPAM%/bin/odoc html --warn-error -I ../_odoc/pkg/bar -I ../../sub_env/lib/.bar.objs/byte -o . ../_odoc/pkg/bar/page-index.odoc)
(cd _build/default/_doc/_html && %OPAM%/bin/odoc html -I ../_odoc/pkg/bar -I ../../sub_env/lib/.bar.objs/byte -o . ../../sub_env/lib/.bar.objs/byte/bar.odoc)
(cd _build/default/_doc/_html && %OPAM%/bin/odoc html --warn-error -I ../_odoc/pkg/foo -I ../../lib/.foo.objs/byte -o . ../_odoc/pkg/foo/page-index.odoc)
(cd _build/default/_doc/_html && %OPAM%/bin/odoc html --warn-error -I ../_odoc/pkg/foo -I ../../lib/.foo.objs/byte -o . ../../lib/.foo.objs/byte/foo.odoc)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This output feels a bit too verbose. In order to convince ourselves that the test is passing, we have to go through it to check that --warn-error is correctly passed where it should. What about actually leaving an odoc error and checking that it is reported as an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generating a warning from the odoc html is not easy and Odoc is called from multiple independent paths in the source code and I wasn't convinced each paths had the correct environment.
Would it be better if I do both ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, by testing with an error in the source file, we are really testing the user-facing aspect of this PR, which is the most important.

If it's difficult to do that, we can keep the current way, but the output should be cleaned up more. Basically, a new reader should be able to look at the test and quickly understand what it is doing and whether it is passing or not. Otherwise, if some day this test breaks we might just accept the new output without realising the test is no longer passing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the tests to show the actual output. I agree it looks a bit better.

@Julow Julow force-pushed the odoc_warn_error_env branch 2 times, most recently from 869e469 to 5e70dd7 Compare January 15, 2020 16:15
@ghost
Copy link

ghost commented Jan 16, 2020

To fix the CI failure, look for odoc "odoc-simple" in test/blackbox-tests/gen_tests.ml and add a line odoc "odoc/warn-error".

I also prepared a PR to stop dune from printing command lines in tests (#3042). Once it's merged, you can rebase this PR and remove the | sed ... from the tests.

@ghost
Copy link

ghost commented Jan 16, 2020

To fix the CI failure, look for odoc "odoc-simple" in test/blackbox-tests/gen_tests.ml and add a line odoc "odoc/warn-error".

And then run make test again. Basically this will setup things so that the new test is considered as a test that has external dependencies (odoc in this case).

@ghost
Copy link

ghost commented Jan 16, 2020

Alright, #3042 has just been merged

@Julow Julow force-pushed the odoc_warn_error_env branch from 5ff7e32 to e74a23c Compare January 16, 2020 13:40
@Julow
Copy link
Contributor Author

Julow commented Jan 16, 2020

Just rebased and fixed the tests !

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ghost
Copy link

ghost commented Jan 16, 2020

Is the version of odoc that supports --warn-error released yet?

@Julow
Copy link
Contributor Author

Julow commented Jan 16, 2020

It's not yet

@ghost
Copy link

ghost commented Jan 20, 2020

Ok. Let's way for odoc to be released then, and then we can update the odoc version constraint in Dune and merge this PR.

| None ->
let open Odoc in
let default =
(* DUNE3: Enable for dev profile in the future *)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should apply only to the dev profile perhaps

@rgrinberg
Copy link
Member

It's a bit inconsistent that we have semantic fields for odoc but general <tool>_flags fields for menhir for example. Do you think it makes sense to add odoc_flags instead/in addition to this?

@rgrinberg
Copy link
Member

This also needs an appropriate change list entry and a mention in the documentation.

@Julow
Copy link
Contributor Author

Julow commented Jan 23, 2020

I added a bit of doc.

Adding odoc_flags is not easy because Dune calls several Odoc sub commands (html, compile and support-files). These commands have a few options in common but would all interfere with the options provided by Dune (eg. -I, -o) or need to be passed only on a specific unit (--hidden).
Also, I think other options may be useful to configure later but will require logic in Dune (eg. --syntax could be passed automatically, --theme-uri should add a dependency on a file).

@Julow Julow requested review from emillon and nojb as code owners January 23, 2020 11:08
@rgrinberg
Copy link
Member

I see. Thanks for the explanation.

@Julow Julow force-pushed the odoc_warn_error_env branch from f6637a4 to 1258af0 Compare January 23, 2020 12:39
``<optional-fields>`` are:

- ``(warn-error <bool>)`` turns warnings into errors, if set to ``true``.
This field is available since Dune 2.2 and requires Odoc 1.4.3.
Copy link
Collaborator

@emillon emillon Jan 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm not too sure about the warn-error key. It mimics the option in odoc and the ocaml compilers, but maybe that part does not have to be exposed as is.

What do you think about (warnings fatal) and (warnings nonfatal) (or maybe (warnings display)), which can be extended more easily to things like (warnings silenced) if we decide to extend the feature later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did that. I agree it looks better.

Copy link
Collaborator

@emillon emillon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly had a look at the doc, thanks!

@Julow Julow force-pushed the odoc_warn_error_env branch from 65889f5 to 70d7d45 Compare January 23, 2020 16:15
@Julow
Copy link
Contributor Author

Julow commented Feb 20, 2020

Sorry for the delay, Odoc 1.5.0 has been release 12 days ago.
I made some changes after the last review.

@ghost
Copy link

ghost commented Feb 20, 2020

Could you update the odoc constraint in the dune-project file and .travis-ci.sh script, regenerate the opam file and rebase?

Then this should be good to merge.

@Julow Julow force-pushed the odoc_warn_error_env branch 2 times, most recently from 197cffa to bf43f8c Compare February 21, 2020 09:56
@Julow Julow force-pushed the odoc_warn_error_env branch from bf43f8c to 58dd4d8 Compare February 21, 2020 10:07
@Julow
Copy link
Contributor Author

Julow commented Feb 21, 2020

I've update the PR, assuming the next release is 2.4.0

@rgrinberg
Copy link
Member

Could you rebase again? That should fix the CI failure.

@rgrinberg
Copy link
Member

I've rebased the PR

src/dune/odoc.ml Outdated
let lib =
let scope = Compilation_context.scope cctx in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted this change

@rgrinberg rgrinberg force-pushed the odoc_warn_error_env branch 2 times, most recently from b6a3df7 to 8597ad3 Compare February 24, 2020 14:24
Allow to set the warnings mode for odoc compilation.

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
Signed-off-by: Jules Aguillon <juloo.dsi@gmail.com>
@snowleopard snowleopard merged commit 0e40917 into ocaml:master Feb 24, 2020
rgrinberg added a commit to rgrinberg/opam-repository that referenced this pull request Mar 6, 2020
…lugin, dune-private-libs and dune-glob (2.4.0)

CHANGES:

- Add `mdx` extension and stanza version 0.1 (ocaml/dune#3094, @NathanReb)

- Allow to make Odoc warnings fatal. This is configured from the `(env ...)`
  stanza. (ocaml/dune#3029, @Julow)

- Fix separate compilation of JS when findlib is not installed. (ocaml/dune#3177, @nojb)

- Add a `dune describe` command to obtain the topology of a dune workspace, for
  projects such as ROTOR. (ocaml/dune#3128, @diml)

- Add `plugin` linking mode for executables and the `(embed_in_plugin_libraries
  ...)` field. (ocaml/dune#3141, @nojb)

- Add an `%{ext_plugin}` variable (ocaml/dune#3141, @nojb)

- Dune will no longer build shared objects for stubs if
  `supports_shared_libraries` is false (ocaml/dune#3225, fixes ocaml/dune#3222, @rgrinberg)

- Fix a memory leak in the file-watching mode (`dune build -w`)
  (ocaml/dune#3220, @snowleopard and @aalekseyev)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants