1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
open Odoc_model
type args = { html_config : Odoc_html.Config.t; source_file : Fpath.t option }
let render { html_config; source_file = _ } page =
Odoc_html.Generator.render ~config:html_config page
let args unit ~syntax =
match (unit.Lang.Compilation_unit.source_info, args.source_file) with
| { Lang.Source_info.id = Some id; infos }, Some src -> (
match Fs.File.read src with
| Error (`Msg msg) ->
Error.raise_warning
(Error.filename_only "Couldn't load source file: %s" msg
(Fs.File.to_string src));
[]
| Ok source_code ->
let infos = infos @ Odoc_loader.Source_info.of_source source_code in
[
Odoc_document.Renderer.document_of_source ~syntax id infos
source_code;
])
| { id = Some id; _ }, None ->
let filename = Paths.Identifier.name id in
Error.raise_warning
(Error.filename_only
"The --source should be passed when generating documents from \
compilation units that were compiled with --source-parent and \
--source-name"
filename);
[]
| { id = None; _ }, Some src ->
Error.raise_warning
(Error.filename_only
"--source argument is invalid on compilation unit that were not \
compiled with --source-parent and --source-name"
(Fs.File.to_string src));
[]
| { id = None; _ }, None -> []
let renderer = { Odoc_document.Renderer.name = "html"; render; extra_documents }