Skip to content

[WIP] odoc rules - #74

Merged
10 commits merged into
masterfrom
odoc
May 26, 2017
Merged

10 commits merged into
masterfrom
odoc

Conversation

@ghost

@ghost ghost commented May 11, 2017 •

Copy link
Copy Markdown

This adds the @doc alias to build documentation of public libraries. The doc is stored in _build/doc/<context-name>.

  • : odoc compilation rules
  • : generate indexes for libraries
  • : generate a global index
  • : add a doc command, that build the @doc aliases
  • : document the feature

@ghost ghost mentioned this pull request May 11, 2017
@ghost

ghost commented May 12, 2017

Copy link
Copy Markdown
Author

The rules work. Generating a global index will have to wait for some support from odoc. But technically this is already enough.

Currently the doc is generated in _build/doc/<context-name>. There are a few sub-systems that generate artifacts in _build/<blah>/<context-name>:

  • ppx drivers, in _build/.ppx
  • js_of_ocaml, in _build/.js_of_ocaml
  • install symlinks, in _build/install
  • now the doc in _build/doc

It's a bit annoying as the default output is not right, it talks about contexts doc or .ppx that don't exist. Moreover the artifacts for a build context are scattered around.

I think I'll change that so that all the artifacts are generated in _build/<context-name>, i.e.:

  • _build/<context>/_ppx
  • _build/<context>/_js_of_ocaml
  • _build/<context>/_install
  • _build/<context>/_doc

Then I'll document and merge this PR. This change needs to be done before since the manual needs to precise where the generated html is.

@ghost

ghost commented May 15, 2017

Copy link
Copy Markdown
Author

Looking at the doc for opam2, we should rather have a --with-doc and write this in the opam file:

build: [["jbuilder" "build" "-p" name "-j" jobs --with-doc {with-doc}]]

that would build the doc and add it to the generated install file. There are a few open questions:

  1. where to install the odoc files?
  2. where to install the html files?

For (1), the library directory seems like the obvious place, so that we can just include these path when building the .odoc and .html files, as we do when building other artifacts.

For 2, it is more complicated. odoc generates the doc using the following structure:

  • <doc-dir>/<package-name>/index.html
  • <doc-dir>/<package-name>/<toplevel-module>/index.html

where <package-name> is whatever we want. All the html files for all the libraries must be installed in the same <doc-dir> for the links to work between opam packages. So there are in fact two more questions:

2a. what to choose for the <doc-dir>?
3a. what to choose for the <package-name>?

The natural solution would be to choose <opam-prefix>/doc as <doc-dir> and the opam package name as<package-name> . However this mean that the html files will be mixed with whatever other documentation files the user wants to install, as well as the README, changelog, etc...

Another solution would be to install the doc in <opam-prefix>/doc/html-doc. However it's odd to write in another package directory.

Using the opam package for <package-name> is fine. The custom index files, that will produce <doc-dir>/<package-name>/index.html will have to be <pkg>.mld for every <pkg>.opam. This means more files at the root of the project. However this can be easily worked around by writing some copy rules in the jbuild. jbuilder could also look for the index in doc/<pkg>.mld if not found at the root of the project.

Currently, the rules as implemented in this PR use the public library name as <package-name>. This has the advantage that the user can write one index page per library. However, this would only be fine if all the html documentation for all the projects was installed in a sub-directory of <opam-prefix>/doc such as <opam-prefix>/doc/html-doc.

@ghost
ghost merged commit 15491fd into master May 26, 2017
@ghost
ghost deleted the odoc branch February 7, 2018 14:48
This pull request was closed.
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.

2 participants