Help Test the New Odoc-3-Powered Package Documentation Pages

We’re in the process of deploying odoc 3 on the package documentation pipeline that underpins the package documentation pages at OCaml Packages · Browse Community Packages.

We’ve prepared a patch for OCaml.org that renders the packages’ documentation pages with the new odoc 3 features. Before deploying this on the production version of the OCaml.org website, we’re looking for community feedback on the updated package documentation pages now available on staging.ocaml.org :tada:.

Some of the new odoc 3 features benefit all packages!

  • The docs CI is now using a new driver, with many more docs being built. Compare the docs for yojson in the old and new CI!
  • The docs now features a “source” link next to most items, taking you to a rendered version of the source code. For instance, if you wonder how the List.sort_uniq function is implemented, click on the source link next to it!
  • The sidebar and breadcrumbs, which were previously hacked together by ocaml.org, are now properly generated by odoc. Compare odoc’s old and new sidebar!
  • The URL layout has been updated to include the library names, with redirections to avoid dead links.

Some other new features opens new possibility for documentation authors! They are mostly unused as their support is so recent, but you can test then on odoc’s docs:

  • Ocaml.org now allows to reference other packages modules and pages! For instance, odoc-driver’s doc, in its introduction, references a page from sherlodoc’s doc! It’s as simple as this syntax.
  • Medias, such as images, finally work on ocaml.org. This requires using the special syntax that is so new that, currently, only odoc’s cheatsheet is using. But since we made sure to be compatible with odig’s convention, images now work for several packages: compare Vg’s tutorial before and after!

How to help:

  • Test browsing package documentation on staging.ocaml.org
  • Report any bugs you encounter (even if it’s just a small visual issue)

Your testing helps ensure a smooth transition when these improvements go live. Thanks for helping us!

The ocaml.org and odoc maintainers

17 Likes

Thats great news !

I went to look at docs, and I have a few comments:


This does not look very good because its multi-line. Also the color highlight is not part of the color scheme which makes feel it a little off.

I also think the line numbers are too large and bright, they’re not the main point here. Same with the link to the source in the main pages:

Cmdliner seems to lack sources: https://staging.ocaml.org/p/cmdliner/1.3.0/doc/cmdliner/Cmdliner/Cmd/Exit/index.html.

The sidebar has this small issue where the toplevel module is not being open by default:

I understand that for packages with multiple submodule you would not want to, but its probably possible to have modules be open by default when they are the only child of their parent.

It might be bad for odoc to do that:

But I think odoc itself is very atypical. Most packages don’t have a dozen of libraries.

Maybe even display the parent and the child on the same line when thats the case, vscode does that for folders.

Jump to definition does not work across submodules of the same file which depending on the shape of the source can be very limiting.

My screen is very large, but I still have to scroll to see the end of that line:

Its 88 chars wide, maybe the source view could accommodate up to 120 ? I am not sure there is a great solution here.

Congrats for the great work, I am really happy that this is happening.

5 Likes

Thanks a lot Emile for the valuable feedback! And for your help on odoc 3.

I’ll try to fix those issues before we merge then. (About the “visual” comments I have a disclaimer: I’m very not a designer, so I’ll do my best but … if anyone wants to help with a PR?)

This does not look very good because its multi-line. Also the color highlight is not part of the color scheme which makes feel it a little off.

I’ll see what I can do!

Cmdliner seems to lack sources: https://staging.ocaml.org/p/cmdliner/1.3.0/doc/cmdliner/Cmdliner/Cmd/Exit/index.html.

For a package to have source displayed, it needs to install the .ml. dune does this by default, so most packages get rendered sources. However I don’t think @dbuenzli’s packages do that. I don’t know if that is a choice to avoid having users depend on implementation details?

The sidebar has this small issue where the toplevel module is not being open by default:

As you point out, it’s hard to make the sidebar look good on most cases…

Its 88 chars wide, maybe the source view could accommodate up to 120 ? I am not sure there is a great solution here.

Surely we can improve things here.

Rather, no one told me that I should.

1 Like

So, once this PR is merged, to have your source be displayed in the docs, you need to install the .ml corresponding to your compilation units in order to have source rendered in the ocaml.org website!

I think this should be added to the documentation, with more details. I’ll open an issue.

(Note that I often end up in my opam switch by following merlin, and sometimes I use the installed source to look up for examples or other info on the API. This is not possible for packages which do not install source, which is not bad enough for me to open an issue. But I would be happy if your packages do install sources!)

Except for cmdliner whose distribution is based on a Makefile so that it only depends on ocaml, that’s an issue with topkg, not with individual packages. Opening one there increases the chances that I don’t forget.

I don’t think it should be too hard to add (it’s already done with for .mli files). There’s likely just a few subtelties with packed modules (manually with .cmi hiding, not -pack) and/or module aliases, but unless I’m mistaken this should be a matter of mimicking the install logic that is in place for .cmx files.

Btw. anyone knows if there is an invocation to retrigger package that build depend on topkg in an opam switch ?

Something like opam reinstall $(opam list -s --all-versions --installed --depends-on topkg) should do it

1 Like

Good work on the new features! They’ll make exploring package docs easier.

I noticed an issue when browsing the pages on mobile, the “Source” link looks like it is part of the signature:


This uses the exact same style as links which are part of the signature, and that can lead to unneeded confusion:

I fully understand focusing on the desktop experience over mobile for browsing the docs. But the above seems problematic enough to warrant a fix.

Diving into the CSS I noticed it is probably supposed to have a different color:


But there are two issues with this:

  • --source-link-color is unset
  • Even if it were set, its would be overridden by color: white from the .dark div.odoc a:not(.source_code a) selector.

I could fix the rendering by adding the following CSS rule:

.dark div.odoc a:not(.source_code a).source_link {
  color: #C14F1D;
}


However, even with the distinct color, I still think this layout is a bit confusing. I would consider moving this link to above or below the function signature, or also adding a distinct background color.

4 Likes

Thanks @dlesbre for your feedback! I have updated the style for the “link to source” button as per Emile’s comments, unfortunately it has still not yet been pulled on staging. I’ll ping @sabine about this.
While the new style will definitely be better, I haven’t tested properly on mobile. I’ll work on that!

image
image

Thanks so much for the feedback and bug reports! :orange_heart: :two_hump_camel:

I’ve just triggered the deployment of the current state of the PR (52d1860) to staging.ocaml.org, which includes fixes based @panglesd has made based on your reports.

The patch should be live in around 15 minutes. (Random trivia: you can check OCurrent Deployer to see the build logs and how the deployment is coming along.)

2 Likes

This website seems to be down, at least for me.

This website seems to be down

Thanks, I passed this on to the infrastructure folks.

The host staging.ocaml.org is a bit sickly - we’ve got another instance running at https://staging.ci.dev/ so please use that instead!

I’ve noticed another issue in the rendering of the markdown/README files on the new website, for example patricia-tree 0.11.0 (latest) · OCaml Package :

Notice that the badges are displayed here on separate lines, with weird quotation " symbols in between them. The expected output is visible in the github render of that same readme:

This wasn’t the case on the previous version, where the badges where just not shown.

Thanks a lot @dlesbre for the report. Indeed, this is a new bug, I’ve filed a bug report in the relevant repo.

I think we have two separate issues here though:

  • An extra added quote " after each image (I’ve submitted a PR to fix your issue)
  • The fact that images are styled with display: block;, forcing a new line after each image.

Yes this style seems to be something set by tailwind, I’ll change this on the README back to inline.

Thanks again for the report :slight_smile: