Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add odoc syntax support #1397

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ open Stanza.Decoder
(* This file defines the jbuild types as well as the S-expression
syntax for the various supported version of the specification.
*)

(* Deprecated *)
module Jbuild_version = struct
type t =
Expand Down Expand Up @@ -1894,20 +1893,34 @@ module Copy_files = struct
end

module Documentation = struct
module Doc_Syntax = struct
type t = Reason | OCaml | All
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other places use something like All | Only of syntax list which is more flexible - with this type you can not only enable a subset, it's all or only one. But this is not a problem since there are only two languages here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that All doesn't make sense anyways. odoc plans to provide both formats within the same html file, so the syntax option is only for the "preferred default syntax" later on


let decode =
enum [ "reason", Reason
; "ocaml", OCaml
; "re", Reason
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that "reason" & "ocaml" are enough. These names are also used in formatting rules for examples.

; "ml", OCaml
; "all", All]
end

type t =
{ loc : Loc.t
; package : Package.t
; mld_files : Ordered_set_lang.t
; syntax : Doc_Syntax.t
}

let decode =
record
(let%map package = Pkg.field "documentation"
and mld_files = Ordered_set_lang.field "mld_files"
and syntax = field ~default: Doc_Syntax.All "syntax" Doc_Syntax.decode
and loc = loc in
{ loc
; package
; mld_files
; syntax
}
)
end
Expand Down
7 changes: 7 additions & 0 deletions src/dune_file.mli
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,17 @@ module Copy_files : sig
end

module Documentation : sig
module Doc_Syntax : sig
type t = Reason | OCaml | All

val decode : t Dune_lang.Decoder.t
end

type t =
{ loc : Loc.t
; package : Package.t
; mld_files : Ordered_set_lang.t
; syntax : Doc_Syntax.t
}
end

Expand Down