Replies: 5 comments 14 replies
-
Does this mean we require package authors to list all the libraries the package offers? And if they don't provide this metadata, odoc makes a best effort in discovering these?
This makes it impossible to establish redirects for the old module reference URLs on ocaml.org. Can we use something other than
If I am not mistaken, this will break the old documentation URLs on ocaml.org in a way that we cannot create redirects for. However, I think that should not stop you from making these changes. We are still early in terms of OCaml adoption, and including the concept of libraries within a package in odoc does look like a good idea to me. We may lose a few backlinks into specific pages of package documentation, but I expect that this cost is worth to take here. We are currently suffering significant complexity because of the unclear relationship between package and libraries and modules contained therein. Introducing these concepts at the level of odoc and placing discovery of libraries into the responsibility of the driver will simplify things downstream at voodoo+ocaml.org. |
Beta Was this translation helpful? Give feedback.
-
Respective to my experience and my current needs:
|
Beta Was this translation helpful? Give feedback.
-
Is there any chance, odoc 3.0 can support Markdown, by the way? If a package only has Markdown documentation, we won't render it with odoc, right? In the long run it's obviously nice if people move to |
Beta Was this translation helpful? Give feedback.
-
About the resolution of pages references, @dbuenzli has made some comments in the asset discussion. |
Beta Was this translation helpful? Give feedback.
-
Here are a few comments on quick a read of the proposal:
Footnotes
|
Beta Was this translation helpful? Give feedback.
-
Hi everyone! We (the Odoc team here at Tarides) been thinking a lot recently about Odoc and the direction it's going. There have been a number of new features recently and some in the pipeline that made us want to write up our thoughts, and check with the community about the way we're heading.
The following is a write-up of our internal thoughts on the subject, where we've got to the point where we've got something more-or-less coherent that it will be useful to share with a wider audience to seek feedback on the ideas.
This isn't an exhaustive list of everything we'd like to do! However, this represents in some sense the 'core' of the design that it's important and most tricky to get right. We'll also post some more notes later for other aspects of the design (e.g. source rendering and others).
Introduction
This document describes a number of features geared towards improving the experience of documenting OCaml projects.
Included are a number of feature suggestions that are entirely new to odoc, some that have only recently been added, and some adjustments to existing features as a result of the experience of working with them.
First, we define an extension to the existing description of a package's documentation in the odig docs. The concept described there is of a documentation set - a 'unit of documentation', consisting of a number of documentation files and associated assets in addition to metadata about them. There may also be a number of associated OCaml libraries for which API documentation from doc comments are considered to be part of the documentation unit.
The extensions described here are:
As part of this, we will also describe the construction of a sidebar for navigating the documentation set.
We also take this opportunity when implementing these to address the way that odoc is driven to allow for better incremental building, including subsets of available docs. The details of these changes will follow in a further doc.
Principles
Globally-relevant information
This section contains information that is relevant to everyone maintaining ocaml package. These are the changes that will end up affecting the contents of peoples repositories, baked into package releases, and which we will do our best to support in odoc for the forseeable future.
Structured documentation
A 'unit of documentation' consists of a set of documents and assets in a hierarchical directory structure. Documentation files are
mld
files, and assets are jpegs, pngs, svgs, etc., that are referenced by the docs.For opam packages, there is one unit of documentation associated with each package, and the
mld
s are installed when installing a package with opam into<opam dir>/doc/<package>/odoc-pages/
and subdirectories.Each documentation directory or subdirectory should contain an
index.mld
file that represents the main index of the pages and subdirectories found within.In addition to the the text of the page, the
index.mld
files should contain a list of the pages and subdirectories that will be used to order the pages in a sidebar. If this does not exist, the order will be done by an appropriate sort. The order can be specified in the "frontmatter" or metadata block associated with the index.mld file (defined later).Assets may be put alongside the
mld
files, or they may be in a separate directory<opam dir>/doc/<package>/odoc-assets/
. There will be new syntax for referencing assets via new elements of odoc syntax such as images.References and scoping
It is implicit that all of the libraries of the package are 'in scope' when compiling/linking the documentation for a package. That is, all of the modules of all of the libraries are accessible via the usual syntax of
{!Module}
. Extra libraries (including, but not limited to dependencies of the packages libraries) will only be able to be referenced by explicitly requesting it. Only those libraries of the package that can be or have been successfully compiled will be linkable.Pages in other packages may be referenced, but once again they need to be explicitly requested. Requesting a package's pages and requesting libraries are independent.
Concretely, the extra packages and libraries will be added to fields in the metadata block (defined later).
We don't want to restrict documentation authors to the same constraints that OCaml programs and libraries must stick to, so where there are libraries that cannot be linked together in the same program we would like to still allow that when linking docs. A consequence of that is that modules need to be available in a namespaced way as well as via the standard flat namespace.
A package can be added to the scope, which will make that packages pages accessible by the reference
{!/packagename/a/b/c/page-d}
or more simply{!/packagename/a/b/c/d}
which would refer to the page that usually ends up installed at<opam dir>/doc/<packagename>/odoc-pages/a/b/c/d.mld
A module can be added to the scope by adding the library it's found in, which will make those modules accessible by the references
{!Module}
or{!/libname.sublib/Module}
(not{!sublib/Module}
). By default all modules in the package's libraries are added to the scope.Note
It's not always easy for anyone to determine in which library a particular module lives, which is a problem that current drivers have to worry about, and which this document does not change. If there's only one library that adds a specific include path to the compiler invocation then it's easy. If not, we have to fall back to querying archives for modules, although this only works for modules that have an implementation.
References in pages
When resolving references in a page within the hierarchy, pages can be resolved by different mechanism:
/
:{!pagename}
,{!page-pagename}
./
:{!dirname/pagename}
,{!../dirname/pagename}
,{!packagename/dirname/pagename}
.If two pages have the same name, they cannot be referenced by name.
To resolve a page in your own directory using a "relative path" reference, one need to use
{!./pagename}
instead of{!pagename}
: otherwise, there is no/
and the "resolving by name" is used.Finally, note that there is no way to use a resolving by name for pages in another package.
For example, given the hierarchy (omitting index.mld files):
when resolving references in
baz.mld
, the following are valid references (assuming our package name ispkgname
):At a lexical level, this will be handled by considering a reference to be optionally prefixed by a path terminating in a
/
, except where that/
is in parentheses. The conditional is to handle references to infix values containing/
, e.g.{!val-(/)}
.References in modules
A package can be added to the scope, which will make that packages pages accessible by the reference
{!/packagename/a/b/c/page-d}
or more simply{!/packagename/a/b/c/d}
which would refer to the page that usually ends up installed at<opam dir>/doc/<packagename>/odoc-pages/a/b/c/d.mld
If there are documentation pages for the package in which this module is contained, these are also added to the scope: they are linkable with the reference {!pagename}. If two pages have the same name, they need the {!/pkgname/path/page} syntax to be referenced.
Modules that are in scope are exactly those in libraries that are dependencies of the module in question. No more, no less. These are accessible by the references
{!Module}
or{!/libname.sublib/Module}
(not{!sublib.Module}
).Metadata block
The new items of metadata required by the above will be put into a metadata block somewhere near the beginning of the file. The suggested format for this is a code block with the language
meta
, containing key-value pairs:This is similar to the frontmatter of markdown docs, although we (currently) don't propose to have full yaml in the blocks, just key-value pairs. Only three keys are defined currently;
packages
,libs
andtoc
, but extra keys will be allowed for extensibility.Note that it's out of scope for this document how the packages get installed. We expect there to be constraints on what is possible, and there should be discussion on these at a later point.
Driver-level changes
The following sections won't affect what's in ocaml packages, but is important for consumers of the documentation as well as people maintaining tools that drive odoc in various ways.
Output file structure
In odoc today, the modules and pages are output into the same hierarchy when using the
--package
argument, although the parent/child arguments allows the output to be put wherever you like.In Odoc 3, we will be adding another mechanism that allows for the specification of the output path, but without some of the drawbacks of the parent/child mechanism.
In all current drivers; odig, dune and voodoo (for ocaml.org), the
mld
pages exist in the same hierarchy as the module reference documentation. With the addition of structure to themld
pages, and the addition of another hierarchy of source pages, there now exists a much more likely danger of filename clashes. We therefore propose to allow that the three hierarchies no longer necessarily have to be output under the same path, so for example we would like it to be possible for the resulting pages to exist under the URLs/lib
for the module reference documentation,/doc
for the mld-derived pages, and/src
for the source hierarchy.While it must be possible for the hierarchies to be different, it also must be possible to have them share the same path. For example, it may make sense to keep the manuals and the modules docs under the same tree.
Breadcrumbs
The breadcrumbs at the top of the page are currently purely based on the directory structure of the output files. We propose to change this such that in two few ways.
Manual pages
For example, where we have a page on the ocaml.org site like:
we might have the breadcrumbs
Package 1.0 Info > Manuals > Tutorial > Simple
where the name
Simple
comes from the{0 Simple}
insideodoc-pages/tutorial/simple.mld
,Tutorial
comes from the{0 Tutorial}
inodoc-pages/tutorial/index.mld
,Manuals
comes from the{0 Manuals}
inodoc-pages/index.mld
, andPackage 1.0 Info
would come from the file generated by the driver representing the package metadata page.Note that this does not require that the top page be one generated by a driver, it could equally be one whose text comes from
odoc-pages/index.mld
. However, in ocaml.org today theindex.mld
page is found at thedoc
subdirectory of the main package page, and we would like to support this case.Since the title might be lengthy, we will also add some syntax to allow for shorter names:
Modules
Another example will be a module found in a library. On ocaml.org, these currently live in the root of the documentation tree, so for example, there is a module page that lives at this URL:
When visiting that page today, we see the breadcrumbs:
so the breadcrumbs do not reflect the directory structure. In this proposal, the module would be output into the path:
and the breadcrumbs would reflect that:
Sidebar
The sidebar will be generated by creating an index of all pages (including modules and source) underneath a particular output hierarchy. It may include the contents of those pages (i.e., the sections in an mld file or the modules, values, type etc. found in a module). There will be options available to choose how this will be rendered, including whether siblings of ancestors can be expanded or not and more. This index will be created after linking (so a complete picture of the contents of modules can be found), and passed to the
html-generate
command. The details of this will be described in a further document.Beta Was this translation helpful? Give feedback.
All reactions