Skip to content

Commit 0644a33

Browse files
Merge pull request #412 from Leonidas-from-XIV/normal-markdown-rename
`Normal` -> `Markdown` rename
2 parents b8998ac + 7aabddd commit 0644a33

File tree

15 files changed

+30
-31
lines changed

15 files changed

+30
-31
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#### Changed
2222

2323
- Preserve indentation in multiline OCaml blocks in .mli files (#395, @panglesd)
24+
- Rename the `Normal` syntax to `Markdown` to better explain what the syntax is
25+
and moved it to `Mdx.Syntax` (#412, @Leonidas-from-XIV)
2426

2527
#### Fixed
2628

bin/cli.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ open Cmdliner.Term
22

33
val named : ('a -> 'b) -> 'a t -> 'b t
44
val non_deterministic : [> `Non_deterministic of bool ] t
5-
val syntax : [> `Syntax of Mdx.syntax option ] t
5+
val syntax : [> `Syntax of Mdx.Syntax.t option ] t
66
val file : [> `File of string ] t
77
val section : [> `Section of string option ] t
88
val silent_eval : [> `Silent_eval of bool ] t

bin/main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let cmds = [ Test.cmd; Pp.cmd; Deps.cmd; Dune_gen.cmd ]
2020
let main (`Setup ()) = `Help (`Pager, None)
2121

2222
let info =
23-
let doc = "Execute markdown files." in
23+
let doc = "Execute code in documentation files." in
2424
let man = [] in
2525
Cmd.info "ocaml-mdx" ~version:"%%VERSION%%" ~doc ~man
2626

bin/pp.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ let executable_contents (block : Block.t) =
7373
else (line, add_semi_semi contents))
7474

7575
let run (`Setup ()) (`File file) (`Section section) =
76-
Mdx.parse_file Normal file >>! fun t ->
76+
Mdx.parse_file Markdown file >>! fun t ->
7777
let t =
7878
match section with
7979
| None -> t

bin/test.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ let term =
5353
$ Cli.silent $ Cli.verbose_findlib $ Cli.prelude $ Cli.prelude_str
5454
$ Cli.file $ Cli.section $ Cli.root $ Cli.force_output $ Cli.output)
5555

56-
let doc = "Test markdown files."
56+
let doc = "Test code in documentation files."
5757
let info = Cmd.info "test" ~doc
5858
let cmd = Cmd.v info term

bin/test/main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ let term =
8282

8383
let info =
8484
let man = [] in
85-
let doc = "Test markdown files." in
85+
let doc = "Execute and test code in documentation files." in
8686
Cmd.info "ocaml-mdx-test" ~version:"%%VERSION%%" ~doc ~man
8787

8888
let cmd = Cmd.v info term

lib/block.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ let pp_footer ?syntax ppf _ =
173173
match syntax with
174174
| Some Syntax.Mli -> Fmt.string ppf "]}"
175175
| Some Syntax.Cram -> Fmt.string ppf "\n"
176-
| Some Syntax.Normal | None -> Fmt.string ppf "```\n"
176+
| Some Syntax.Markdown | None -> Fmt.string ppf "```\n"
177177

178178
let pp_legacy_labels ppf = function
179179
| [] -> ()
@@ -191,7 +191,7 @@ let pp_labels ?syntax ppf labels =
191191
| [ Non_det (Some Nd_command) ] ->
192192
Fmt.pf ppf "<-- non-deterministic command\n"
193193
| _ -> failwith "cannot happen: checked during parsing")
194-
| Some Syntax.Normal | None -> (
194+
| Some Syntax.Markdown | None -> (
195195
match labels with
196196
| [] -> ()
197197
| l ->
@@ -216,7 +216,7 @@ let pp_header ?syntax ppf t =
216216
in
217217
Fmt.pf ppf "{%a%a[" pp_lang_header lang_headers pp_labels other_labels
218218
| Some Syntax.Cram -> pp_labels ?syntax ppf t.labels
219-
| Some Syntax.Normal | None ->
219+
| Some Syntax.Markdown | None ->
220220
if t.legacy_labels then
221221
Fmt.pf ppf "```%a%a"
222222
Fmt.(option Header.pp)

lib/document.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515
*)
1616

17-
type syntax = Syntax.t = Normal | Cram | Mli
1817
type section = int * string
1918
type line = Section of section | Text of string | Block of Block.t
2019
type t = line list

lib/document.mli

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,18 @@
1616

1717
(** {2 Lines} *)
1818

19-
type syntax = Syntax.t = Normal | Cram | Mli
20-
2119
(** The type for the lines of a markdown or cram file. *)
2220
type line = Section of (int * string) | Text of string | Block of Block.t
2321

24-
val pp_line : ?syntax:syntax -> line Fmt.t
22+
val pp_line : ?syntax:Syntax.t -> line Fmt.t
2523
(** [pp_line] is the pretty-printer for markdown or cram lines. *)
2624

2725
(** {2 Document} *)
2826

2927
type t = line list
3028
(** The type for mdx documents. *)
3129

32-
val pp : ?syntax:syntax -> t Fmt.t
30+
val pp : ?syntax:Syntax.t -> t Fmt.t
3331
(** [pp] is the pretty printer for mdx documents. Should be idempotent
3432
with {!of_string}. *)
3533

lib/mdx.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ let parse l =
7171
let parse_lexbuf syntax Misc.{ string; lexbuf } =
7272
match syntax with
7373
| Syntax.Mli -> Mli_parser.parse_mli string
74-
| Normal ->
74+
| Markdown ->
7575
Util.Result.to_error_list @@ Lexer_mdx.markdown_token lexbuf >>= parse
7676
| Cram -> Util.Result.to_error_list @@ Lexer_mdx.cram_token lexbuf >>= parse
7777

@@ -80,7 +80,7 @@ let parse_file syntax f = Misc.load_file ~filename:f |> parse_lexbuf syntax
8080
let of_string syntax s =
8181
match syntax with
8282
| Syntax.Mli -> Mli_parser.parse_mli s
83-
| Syntax.Normal | Syntax.Cram ->
83+
| Syntax.Markdown | Syntax.Cram ->
8484
Misc.{ lexbuf = Lexing.from_string s; string = s } |> parse_lexbuf syntax
8585

8686
let dump_line ppf (l : line) =
@@ -107,15 +107,15 @@ let write_file ~outfile content =
107107
output_string oc content;
108108
close_out oc
109109

110-
let run_to_stdout ?(syntax = Normal) ~f infile =
110+
let run_to_stdout ?(syntax = Syntax.Markdown) ~f infile =
111111
let+ _, corrected = run_str ~syntax ~f infile in
112112
print_string corrected
113113

114-
let run_to_file ?(syntax = Normal) ~f ~outfile infile =
114+
let run_to_file ?(syntax = Syntax.Markdown) ~f ~outfile infile =
115115
let+ _, corrected = run_str ~syntax ~f infile in
116116
write_file ~outfile corrected
117117

118-
let run ?(syntax = Normal) ?(force_output = false) ~f infile =
118+
let run ?(syntax = Syntax.Markdown) ?(force_output = false) ~f infile =
119119
let outfile = infile ^ ".corrected" in
120120
let+ test_result, corrected = run_str ~syntax ~f infile in
121121
match (force_output, test_result) with

0 commit comments

Comments
 (0)