package odoc-parser

  1. Overview
  2. Docs
Parser for ocaml documentation comments

Install

Dune Dependency

Authors

Maintainers

Sources

odoc-parser-0.9.0.tbz
sha256=df0dad1bad39bf4de6be666c4b63b973bd72eba3b75be9f726317121b5f0bd79
sha512=5222debc190784cee62fee177d39fcff56f326b1a3c5b4beb408d0c0eb3d43bf7dcfcffcd25ccc6c3d3c0c098771f01780cb687495ac2a4d95a4bc6401643316

README.md.html

odoc-parser

Odoc-parser is a parser for odoc markup, which is an extension of the original markup language parsed by ocamldoc.

OCaml code can contain specially formatted comments that are used to document the interfaces of modules. These comments are delimited by (** and *). This parser is intended to be used to parse the contents of these comments.

The parser is part of the odoc project.

Please see CONTRIBUTING.md for details of the development process.

Example usage:

# #require "odoc-parser";;
# let location = {Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 0};;
val location : Lexing.position =
  {Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 0}
# let p = Odoc_parser.parse_comment ~location ~text:"{b Bold!}[unfinished";;
val p : Odoc_parser.t = <abstr>
# let w = Odoc_parser.warnings p;;
val w : Odoc_parser.Warning.t list =
  [{Odoc_parser.Warning.location =
     {Odoc_parser.Loc.file = "";
      start = {Odoc_parser.Loc.line = 1; column = 20};
      end_ = {Odoc_parser.Loc.line = 1; column = 20}};
    message = "End of text is not allowed in '[...]' (code)."}]
# Odoc_parser.ast p;;
- : Odoc_parser.Ast.t =
[{Odoc_parser__.Loc.location =
   {Odoc_parser__.Loc.file = "";
    start = {Odoc_parser__.Loc.line = 1; column = 0};
    end_ = {Odoc_parser__.Loc.line = 1; column = 20}};
  value =
   `Paragraph
     [{Odoc_parser__.Loc.location =
        {Odoc_parser__.Loc.file = "";
         start = {Odoc_parser__.Loc.line = 1; column = 0};
         end_ = {Odoc_parser__.Loc.line = 1; column = 9}};
       value =
        `Styled
          (`Bold,
           [{Odoc_parser__.Loc.location =
              {Odoc_parser__.Loc.file = "";
               start = {Odoc_parser__.Loc.line = 1; column = 3};
               end_ = {Odoc_parser__.Loc.line = 1; column = 8}};
             value = `Word "Bold!"}])};
      {Odoc_parser__.Loc.location =
        {Odoc_parser__.Loc.file = "";
         start = {Odoc_parser__.Loc.line = 1; column = 9};
         end_ = {Odoc_parser__.Loc.line = 1; column = 20}};
       value = `Code_span "unfinished"}]}]
OCaml

Innovation. Community. Security.