Skip to content

Commit 53d1244

Browse files
authored
Builds the primus-api documentation (#1199)
* builds primus api documentation * typo fixed * fixes typo
1 parent 7a18ffb commit 53d1244

File tree

5 files changed

+35
-10
lines changed

5 files changed

+35
-10
lines changed

lib/bap_primus/bap_primus_env.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ let generated,on_generated =
2828
Observation.provide "var-generated"
2929
~inspect:inspect_generated
3030
~package:"bap"
31+
~desc:"Occurs when a new value is generated during the read operation"
3132

3233
let sexp_of_values values =
3334
Sexp.List (Map.to_sequence values |> Seq.map ~f:(fun (v,{value}) ->

lib/bap_primus/bap_primus_memory.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ let generated,on_generated =
120120
Bap_primus_observation.provide "load-generated"
121121
~inspect:inspect_generated
122122
~package:"bap"
123+
~desc:"Occurs when a new value is generated during the load operation"
123124

124125

125126
let virtual_memory arch =

plugins/glibc_runtime/glibc_runtime_main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let doc = "
22
Enables ad-hoc support for glibc runtime code. In particular it
3-
detects the locations of $(b,main) and $b(,__libc_start_main)
3+
detects the locations of $(b,main) and $(b,__libc_start_main)
44
functions (and adds the latter if it is absent).
55
"
66
open Core_kernel

plugins/primus_test/primus_test_main.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,17 @@ module Location = struct
111111
let new_instance,report_new_instance =
112112
Primus.Observation.provide "incident-new-instance"
113113
~inspect:inspect_instance
114+
~desc:"Occurs on a new instance of the incident class"
114115

115116
let new_class,report_new_class =
116117
Primus.Observation.provide "incident-new-class"
117118
~inspect:inspect_instance
119+
~desc:"Occurs when a new incident class is created"
118120

119121
let new_representative,report_new_representative =
120122
Primus.Observation.provide "incident-new-representative"
121123
~inspect:inspect_instance
124+
~desc:"Occurs when a new representative of the class is selected"
122125

123126
let trace = Primus.Machine.State.declare
124127
~uuid:"3663b645-87a6-4561-b75f-c447cdc221bc"

tools/bapdoc.ml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ let mkdir path =
8787
if not (Sys.file_exists path) then
8888
Unix.mkdir path 0o770
8989

90-
let run cmd =
91-
let res = Sys.command cmd in
92-
if res <> 0 then
93-
failwith ("Command: '" ^ cmd ^ "' failed")
90+
let run fmt =
91+
let cmd c =
92+
let res = Sys.command c in
93+
if res <> 0 then
94+
failwith ("Command: '" ^ c ^ "' failed") in
95+
ksprintf cmd fmt
9496

9597
let render_entry (_,entry,short,desc) =
9698
let name_to_display = match short with
@@ -143,7 +145,7 @@ let build_manual {man; help} tool =
143145
match Sys.command @@ sprintf "%s >/dev/null" (help tool) with
144146
| 0 ->
145147
let out = sprintf "man1/%s.1.html" (man tool) in
146-
run @@ dump_to_file out @@ connect_with_pipes [
148+
run "%s" @@ dump_to_file out @@ connect_with_pipes [
147149
help tool;
148150
repair_links;
149151
man2html;
@@ -165,7 +167,7 @@ let generate_manual () =
165167

166168
let odig_pkgs () =
167169
let f = Filename.temp_file "odig" ".pkgs" in
168-
run (sprintf "odig pkg > %s" f);
170+
run "odig pkg > %s" f;
169171
let pkgs =
170172
In_channel.read_lines f |>
171173
List.filter_map ~f:(fun s ->
@@ -202,7 +204,7 @@ let generate () =
202204
Out_channel.output_string out plugins_index;
203205
Out_channel.close out;
204206
let pkgs = remove_unresolved packages |> String.concat ~sep:" " in
205-
run @@ sprintf
207+
run
206208
{|odig odoc --index-title="BAP API" --no-tag-index --index-intro=%s %s|}
207209
intro pkgs;
208210
run @@ "ln -s $(odig cache path)/html odoc";
@@ -212,10 +214,27 @@ let install_handwritten_manpages () =
212214
mkdir "man1";
213215
run "cp ../man/* man1/"
214216

217+
(* by default, title is the buffer/file name with no extension,
218+
that's why we need override it with an empty title *)
219+
let html_of_org file =
220+
run "echo \"#+TITLE:\n\" >> %s" file;
221+
run "emacs %s --batch --eval '(org-html-export-to-html)'" file;
222+
Sys.remove file
223+
215224
let install_lisp_documentation () =
225+
let file = "lisp/index.org" in
216226
mkdir "lisp";
217-
run "bap /bin/true --primus-lisp-documentation > lisp/index.org";
218-
run "emacs lisp/index.org --batch --eval '(org-html-export-to-html)'"
227+
run "bap /bin/true --primus-lisp-documentation > %s" file;
228+
html_of_org file
229+
230+
let install_primus_api () =
231+
let file = "primus/index.org" in
232+
let add x =
233+
run "echo '* %s' >> %s" (String.capitalize x) file;
234+
run "bap primus-%s >> %s" x file in
235+
mkdir "primus";
236+
List.iter ~f:add ["systems"; "components"; "observations"];
237+
html_of_org file
219238

220239
let is_installed x = Sys.command (sprintf "which %s" x) = 0
221240

@@ -235,4 +254,5 @@ let () =
235254
generate_manual ();
236255
install_handwritten_manpages ();
237256
install_lisp_documentation ();
257+
install_primus_api ();
238258
generate ()

0 commit comments

Comments
 (0)