# Proposal: ocamldoc should generate a table of contents in each module page

**URL:** https://discuss.ocaml.org/t/proposal-ocamldoc-should-generate-a-table-of-contents-in-each-module-page/871
**Category:** Ecosystem
**Tags:** ocamldoc
**Created:** [September 21, 2017, 6:15pm UTC](https://discuss.ocaml.org/t/proposal-ocamldoc-should-generate-a-table-of-contents-in-each-module-page/871 "2017-09-21T18:15:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)
#### Post date: [September 21, 2017, 6:15pm UTC](https://discuss.ocaml.org/t/proposal-ocamldoc-should-generate-a-table-of-contents-in-each-module-page/871/1 "2017-09-21T18:15:58Z")

</div>

Example is below. As you can see, the table of contents hyperlinks each name to the name’s documentation within the same page. This allows the reader to easily scan the TOC (which is helped by including the first line of the documentation comment in the TOC) to find what they’re looking for and jump down to it immediately. This is similar to what @dbuenzli suggested in [First installment of Lwt’s new manual](https://discuss.ocaml.org/t/first-installment-of-lwts-new-manual/815/2?u=yawaramin)

This is a very bare-bones design, e.g. it would benefit a lot from actual icons indicating the kind of name (module, type, or value) instead of the bullet points we have currently. See the right-hand side of [http://scala-lang.org/api/current/scala/io/index.html](http://scala-lang.org/api/current/scala/io/index.html) for an example.

* * *

# Module Arg

```auto
module Arg : sig .. end

```

Parsing of command line arguments.

This module provides a general mechanism…

> **Contents**
>
> - [type spec](#TYPEspec) - The concrete type describing the behavior associated with a keyword.
> - [type key](#TYPEkey)
> - ...
> - [val parse](#VALparse) - `Arg.parse speclist anon_fun usage_msg` parses the command line.
> - ...

* * *

[#](#TYPEspec)

```auto
type spec =

```

The concrete type describing the behavior associated with a keyword.

```auto
| Unit of (unit -> unit)

```

Call the function with unit argument

```auto
| Bool of (bool -> unit)

```

Call the function with a bool argument

```auto
...

```

[#](#TYPEkey)

```auto
type key = string

```

…

[#](#VALparse)

```auto
val parse : (key * spec * doc) list -> anon_fun -> usage_msg -> unit

```

`Arg.parse speclist anon_fun usage_msg` parses the command line. `speclist` is a list of triples `(key, spec, doc)`…

…

---

<div class="post-metadata">

### Author: ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)
#### Post date: [September 29, 2017, 1:09am UTC](https://discuss.ocaml.org/t/proposal-ocamldoc-should-generate-a-table-of-contents-in-each-module-page/871/2 "2017-09-29T01:09:14Z")

</div>

Created an issue on Mantis [https://caml.inria.fr/mantis/view.php?id=7646](https://caml.inria.fr/mantis/view.php?id=7646)

---

<div class="post-metadata">

### Author: ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)
#### Post date: [September 30, 2017, 5:05pm UTC](https://discuss.ocaml.org/t/proposal-ocamldoc-should-generate-a-table-of-contents-in-each-module-page/871/3 "2017-09-30T17:05:14Z")

</div>

Incidentally, updated my mockup above to reflect my proposed redesign of docstring appearance for variant types ( [https://caml.inria.fr/mantis/view.php?id=7634](https://caml.inria.fr/mantis/view.php?id=7634) ). I think this looks more like a literate programming style, which is nice, and less like raw source code comment. Compare with the original at [https://caml.inria.fr/pub/docs/manual-ocaml/libref/Arg.html](https://caml.inria.fr/pub/docs/manual-ocaml/libref/Arg.html) .
