Skip to content

[RFC] Simpler AST #355

@Julow

Description

@Julow

Hi,

First of all, thanks for this great library !

I'm trying to use Odoc in OCamlformat to format documentation comments.
It's been great so far but I ran into a few problems with the representation of comments (Model.Comment):

  • The parser requires passing a containing_definition argument that is hard to understand.
  • A lot of comments that were valid with Octavius now trigger warnings
  • Some part of the AST are very hard to understand and pretty print
    References (see Reference.deconstruct #354)

I proposed in #351 to expose Parser_.Ast.
This AST has some advantages:

  • Parser is easier to call (no need to build dummy arguments)
  • Less strict (no non_link_inline_element, etc..)
  • Heading label is not auto generated yet

It could then be simplified by moving some code from the parser to the semantics pass that build Model.Comment:

  • Represent references as strings
  • List syntax (- or + vs ul or ol)
    This information could also be in Model.Comment.
  • Keep whitespaces
  • Allow any language or none in blocks (eg. Raw_markup of string option * string)

Alternatively, most of these could be fixed without exposing Parser_.Ast and only modifying Model.Comment.
But I think this AST will be much easier to change in the future to allow more use cases.
We will probably receive issues about documentation comments on OCamlformat and Odoc will be used by a lot of projects.

I'll be happy to hear your opinions on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions