Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ocaml-doc/odoc-parser
An OCaml library for parsing documentation comments written in 'odoc markup', a superset of 'ocamldoc markup'.
https://github.com/ocaml-doc/odoc-parser
ocaml parser
Last synced: 3 months ago
JSON representation
An OCaml library for parsing documentation comments written in 'odoc markup', a superset of 'ocamldoc markup'.
- Host: GitHub
- URL: https://github.com/ocaml-doc/odoc-parser
- Owner: ocaml-doc
- License: isc
- Created: 2021-06-23T22:35:29.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-19T08:19:56.000Z (about 1 year ago)
- Last Synced: 2024-05-31T10:40:50.889Z (6 months ago)
- Topics: ocaml, parser
- Language: OCaml
- Homepage:
- Size: 937 KB
- Stars: 16
- Watchers: 5
- Forks: 14
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# odoc-parser
Odoc-parser is a parser for odoc markup, which is an extension of the original markup
language parsed by [ocamldoc](https://ocaml.org/releases/4.12/htmlman/ocamldoc.html).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](https://github.com/ocaml/odoc/) project.
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details of the development process.
## Example usage:
```ocaml
# #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 =
# 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"}]}]
```