-
Notifications
You must be signed in to change notification settings - Fork 456
Odoc v3 rules #12995
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
base: main
Are you sure you want to change the base?
Odoc v3 rules #12995
Conversation
Signed-off-by: Paul-Elliot <peada@free.fr>
Signed-off-by: Paul-Elliot <peada@free.fr>
Signed-off-by: Paul-Elliot <peada@free.fr>
Remove the need to specify library dependencies. This is not anymore needed since ocaml/odoc#1343 Use `(documentation (depends ...))` for package dependencies. It's good for extensibility of per-package doc configuration. Signed-off-by: Paul-Elliot <peada@free.fr>
should not walk on each other's feet Signed-off-by: Paul-Elliot <peada@free.fr>
Signed-off-by: Paul-Elliot <peada@free.fr>
Signed-off-by: Paul-Elliot <peada@free.fr>
Signed-off-by: Paul-Elliot <peada@free.fr>
Signed-off-by: Paul-Elliot <peada@free.fr>
These rules are a new implementation of the rules for @doc and @doc-new. The code in this commit has been entirely generated by Claude Opus.
This has been completely superceded by the `@doc-full` alias
|
I have a blog post about the experience of writing this with Claude. |
|
Also, this PR is built on top of #11716 |
|
I'm just trying this out by vendoring a bunch of libraries, and I notice that the build environment for the docs needs all the dependency of an opam package. For example, I depend on angstrom in my build, but dune build @doc: (same for angstrom-lwt-unix and angstrom-unix, etc) |
|
Angstrom is a slightly odd library in that it installs some dummy libraries that have dependencies that aren't installed. Presumably at some point the opam packages were split into separate lwt/async packages to avoid the dependency problems, and these libraries have been left behind for backward compatibility: For the |
|
Makes sense! I'm also seeing some module references aren't being substituted in, but only in standalone mld files when I do the |
This PR contains a rewrite of the odoc rules in dune to unlock some of the features of odoc v3.
The focus so far has been to build a replacement the rules behind both
dune build @docanddune build @doc-newwhich were almost entirely separately implemented. Instead, this PR introduces a unified approach which satisfies the use cases of both of the previous targets. Of the new odoc v3 features, I've not yet implemented images and other artifacts nor source rendering.The code in this PR has been entirely generated by Claude Code. I did not write a single line of it, though I have spent a long time looking over it!
What's new for
dune build @doc?Building the alias
@docwill build the docs for the non-vendored packages found in the current dune project, as before. However, there are also some new additions:Errors
Errors are only reported for code in the current project. This should make it much easier to fix all documentation errors. For example, in dune as of this PR, running
dune build @docreports:In contrast, building this with the rules from dune 3.20 give 2 more unfixable warnings, and building
@doc-newgives about 500 lines of output telling you all the errors in all the packages that dune depends on!This should play nicely with the pre-existing option to enable warnings-as-errors in odoc, via an
envstanza indune:Sidebar
Documentation will be built by default with a global sidebar, which covers all of the packages present in your build tree. This can optionally be a per-package sidebar via an option in
dune-workspace:Hierarchical docs
Documentation pages (mld files) may be arranged into a tree structure. This builds upon work earlier in the year by @panglesd. The syntax is:
Links to ocaml.org
Where your documentation references modules, types, values, or anything else in libraries from your opam switch, these will now be correctly resolved, and in the HTML these will be turned into links to the relevant documentation on ocaml.org. Note that this is best effort and there are no guarantees that this will work correctly, as the docs on ocaml.org might be created with a different set of dependencies than are used in your project.
Extra package dependencies
If you wish to have your documentation link to modules or mlds in other packages, this is now possible via the new field in
dune-project:This, again, is building upon earlier work by @panglesd.
Changes
The alias
@doc-jsonnow builds json files in a separate path from the HTML:_build/default/_doc/_jsonNew aliases
@doc-fulland@doc-json-fullBuilding the new alias
@doc-fullwill build the documentation for all relevant packages and libraries. This includes all private libraries in the project, all libraries from the opam switch used by the local packages, and any extra packages that have been specified via the documentation dependencies field indune-project. This is the replacement for the@doc-newalias. The output will be found in_build/default/_doc/_html_fullThere is also a new target
@doc-json-fullwhich builds the json files for all of the same packages and libraries as@doc-full. The output of this is found in_build/default/_doc/_json_fullSherlodoc rule
There is a new rule to create the file
_build/default/_doc/_sherlodoc/db.marshal- this is a complete sherlodoc db that indexes all of the files that are produced as part of@doc-fulland can be queried using the sherlodoc CLI. For example, in the dune repo:Caveats / TODOs
Currently this does not work with dune package management. The main piece of work to do would be to implement the module
package_discovery.mlfor dune pkg mode. The job of this module is to figure out which opam package contains each library. For dune-built packages, of course, this is trivial as the names of the libraries are derived from the name of the package. For packages built in other ways, this isn't necessarily the case, and this module looks up information from the opam switch to figure the mapping out.Caching mostly works, but there is an odoc bug that needs to be fixed to make it work perfectly.
Questions
@doc,@doc-full,@doc-jsonand@doc-json-full)?