package odoc-parser

  1. Overview
  2. Docs
Parser for ocaml documentation comments

Install

dune-project
 Dependency

Authors

Maintainers

Sources

odoc-3.2.1.tbz
sha256=d45eb125514839fd9ac27702bb4938d1b4f3b6978e9b16ab9673ea067245affc
sha512=3555386b4770a7caa8ec903683bde5ecdc41d5e57ffaee617d5da225c747bbd1e9c1d2677f4df97e96bbdfc69f580ea83b1b92b933ea40a436a658788b677bbc

doc/odoc-parser/Odoc_parser/index.html

Module Odoc_parserSource

Parser for ocamldoc formatted comments.

Sourcetype t

type t is the result of parsing.

Sourceval parse_comment : location:Lexing.position -> text:string -> t

parse_comment ~location ~text parses text as an ocamldoc formatted string. The parser will try to recover from any invalid syntax encountered, and therefore this will always produce a result without raising exceptions with zero or more warnings. The location passed in should represent the start of the content of the documentation comment - so for a line such as

  (** A comment starting in the first column (0) *)

the location should represent the space immediately before the A, so the in the 4th column (e.g. {... pos_bol=0; pos_cnum=3 })

Sourcemodule Ast : sig ... end

Abstract syntax tree representing ocamldoc comments

Sourcemodule Loc : sig ... end

Locations in files.

Sourcemodule Warning : sig ... end

Warnings produced during parsing.

Sourceval warnings : t -> Warning.t list

Extract any warnings from the parser result.

Sourceval ast : t -> Ast.t

Extract the Ast.t from the parser result.

Sourceval position_of_point : t -> Loc.point -> Lexing.position

Helper function to turn the internal representation of positions back into the usual representation in the Lexing module. Note that this relies on the information passed in parse_comment, and hence requires the result of that call in addition to the Loc.point being converted.

Sourceval codeblock_content : Loc.span -> string -> string * Warning.t list

Process the content of a code block, following the rules described here. To achieve this, it needs the location of the code block (including the separators) and the raw content of the code block. For instance, with the following code block:

  {[
    hello
  ]}

We can go from the raw content "\n hello\n " to the processed content " hello" with:

  match codeblock.value with
  | `Code_block { content; _ } ->
      codeblock_content codeblock.location content.value

Also returns a list of warnings, eg if the content is not appropriately indented.

Sourceval verbatim_content : Loc.span -> string -> string * Warning.t list

Similar to codeblock_content but for verbatims.