Exploring the Docusaurus+Odoc combo

To OCaml & Docusaurus enthusiasts out there :camel:+ :sauropod:

Some time ago, I shared my experience using Docusaurus to document an OCaml project, highlighting the integration between Docusaurus, ocaml-mdx, and the dune workflow (previous post here).

Today I wanted to share that Iā€™ve resumed this exploration in documentation tools to try and integrate odoc-generated pages into Docusaurus, with the aim of creating a somewhat minimal template/example for this.

Iā€™ve published my experiment here: https://mbarbin.github.io/doc-experiment-docusaurus/.

Integrating odoc posed challenges - Iā€™ve written about the (pragmatic) approach I took here. Iā€™m linking this odoc issue too, for reference about exploring more native solutions for this interop.

Have you too tried this ā€œmagic comboā€ of Docusaurus, Odoc, and OCaml tools? And if so, how did you approach it? Do you have insights or suggestions? If this sparks your curiosity, please donā€™t hesitate to engage with the repository.

Thanks!

2 Likes

Iā€™ve never used Docusaurus, but I have some experience creating a documentation website with odoc and jekyll (see Patricia Tree | Codex). It used odoc nice json output (dune build @doc-json) to generate the docs in an easy to reuse manner, and then a custom jekyll plugin and layout to render them.

Overall its a bit hacky and I encountered a few unique issues doing it (like odoc output being broken since it relied on whitespace for indent in html and jekyll just-the-docs automatically stripping extra whitespace). But Iā€™m pretty happy with how the result turned out.

1 Like

I hadnā€™t seen a setup using @doc-json before. That looks pretty interesting and aligns well with what I am trying to achieve. Thank you for sharing!

I like it! From a few prompts in the search boxes, it looks like Search Codex searches the entire website (including odoc APIs), whereas Search patricia-tree API is the equivalent of the sherlodoc-powered search box. Is that right? Is the Search Codex provided by Jekyll?

I havenā€™t made much progress with my experiment yet, except for perhaps one small step. I tried enabling an Algolia Search Box on a Docusaurus site that includes the odoc files in the static directory (here). Unfortunately, the odoc pages are not presented as search results by the Algolia Search Box by default. However, I can see indexed objects related to the odoc files in my Algolia Dashboard for the project, so Iā€™m guessing the crawler does work, and itā€™s a Docusaurus config that needs to be adjusted. To be continued.

Thanks again for showing a live example involving @doc-json. Perhaps that could be part of a better answer for the Docusaurus integration as well.

Yes exactly, the ā€œSearch Codexā€ bar is auto-generated by Jekyll (Its a part of the just-the-docs plugin). It is based on a Jekyll generated JSON list of all pages and contents (which I had to hack a bit to add the odoc pages as well see here).

The ā€œSearch patricia-treeā€ is the sherlodoc powered one, I just copied the HTML/JS elements from the classic odoc page and edited the paths where relevant to fit the new site layout.

Its a bit clumsy having two search bars but I couldnā€™t be bothered to dive into the JS and merge them properly.

1 Like