Manual tools: fail on unexpected errors or warnings within caml_example#693
Manual tools: fail on unexpected errors or warnings within caml_example#693gasche merged 10 commits intoocaml:trunkfrom
Conversation
manual/tools/caml_tex2.ml
Outdated
|
|
||
| let status s = match catch_warning s, catch_error s with | ||
| | Some w, _ -> w | ||
| | _, Some e -> e |
There was a problem hiding this comment.
if you excuse my purely stylistic nitpicking comment, I would prefer the use of None, Some e here to express the ordering using precise patterns instead of just clause ordering. In my opinion this makes the code easier to read, and it also makes it robust to eventual (possibly mistaken) clause reordering.
There was a problem hiding this comment.
In the current implementation, the two clauses should be commutative since simultaneous multiple warnings and error are not handled.
Should they be handled? it would increase the complexity of the parsing for options and I am not sure how useful it would be. Maybe detecting the situation and raising an error would be worthwile?
Anyway I am perfectly fine with adding a None to choose an arbitrary ordering of these clauses.
There was a problem hiding this comment.
Ah, I read another instance of the same pattern below as implementing a priority order. Don't bother, then.
|
This is excellent work and a much-needed improvement, in particular if we want to get serious about documenting warnings and errors in the manual. However, I'm worried that the usefulness of this work could be limited by the fact that building the manual is not at all part of the OCaml development workflow, currently. This means that the statu quo of risking the release of inconsistent document is avoided, but what we get instead is Damien fighting for manual sanity around release time, with your occasional much-appreciated contributions catching some of the errors. I think that making a full manual build part of the common build (or test target) would be too time-consuming, but maybe we could include the production of the Here would be my proposal:
|
|
Rather than time, I fear that a full manual build would be more constraining in term of external dependencies: both latex and hevea are not exactly essential tools for building compilers. However, building both the ".tex" files from the ".etex" source files and the ocamldoc documentation for the standard library seems perfectly doable. I have added a makefile target
So the relative increase in time seems limited. |
|
I sent Octachron#1 as a proposed change on top of the current PR which builds only the |
I can think of at least two examples of manual build failure that would have been caught by building the standard library documentation:
So it can fail in useful way, but I agree that useful failures are probably very unfrequent and it might make sense to skip these files. Another point, going further in this direction, we could also only test the generation of the "caml_environment" latex code which would be even lighter. An argument in this direction is that it is the only part of the manual build process that can be broken by unrelated changes in the compiler whereas other part of the build process can only be broken by altering the manual itself or the standard |
This commit modifies the build process of the manual to make it fails in case of problems during the generation of the tex files from the etex sources files.
This commit modifies the manual tool caml_tex2 to catch the status of
the output and raises an error in case of unexpected error of warning
message. Expected errors or warnings must be now marked explicitly.
There are two options to mark these expected errors or warnings:
The first option is to use the new optional parameter of the
`caml_example` environment, e.g.
\begin{caml_example}[warning=3]
String.capitalize "a word";;
\end{caml_example}
or for an error:
\begin{caml_example}[error]
1 +. 3.;;
\end{caml_example}
The second option is to use `[@@expect ..]` attribute before `;;` to
override locally the global expected status output:
\begin{caml_example}
1 + 2 ;;
1 +. 3. [@@expect error];;
String.capitalize [@@expect warning 3];;
3 + 4 ;;
\end{caml_example}
Note that the two options can be combined together, e.g
\begin{caml_example}[error]
1 +. 3.;; (* an error is expected here *)
1. +. 3. [@@expect ok] ;;
1 + 3. ;; (* an error is still expected here *)
\end{caml_example}
We introduce a `pregen-etex` Makefile rule that only build the .etex files of the manual (whose OCaml examples may be tested and expected to produce certain outputs), without also building the standard-library documentation. This is faster than the previous `pregen` rule as ocamldoc on the standard library was the bottleneck. On my machine, `pregen-etex` completes in 1.5s-2s, while `pregen` completes in 6s-7s.
3635cd1 to
3f349ac
Compare
|
@gasche, I have merged your proposed changes, updated the root makefile and travis script. Moreover, I was quite unhappy with the error reporting; errors were lost in the middle of noise. |
|
Thanks for the additional work! I merged in trunk. |
Manual tools: fail on unexpected errors or warnings within caml_example
…ce_412_effects Add ability to discontinue with backtrace
This pull request proposes to modify the manual tools
caml_tex2to make it fails on unexpected errors or warnings within acaml_exampleenvironment. This change would make easier to notice new warnings or errors triggering on the code examples within the manual (like the few recent cases of deprecated warning or the quite hidden warningin
advexamples.etexcorrected within this PR). Combined with the new use of in-tree,this change would also make safer the potential use of the
caml_examplein the Langage extensions chapter.In more detail, the second commit of this pull request makes the following code
fail with
As explained by the error message above, if the error or warning was intended, it
is necessary to annotate the example either with an attribute:
or with a global latex environment option, e.g.
or for an intended warning
Both annotations can be combined if needed
(The existing source files for the manual has been added the needed annotations.)
Moreover, to make this change useful, the first commit in this PR alters the build process of the manual to make the compilation of the manual fails in case of problems when generating the latex files from the ".etex" source files. Without this modifications, the manual build process had a tendency to "silently" generate empty tex files and then go on with the build process. This should no longer be the case.