Skip to content

Commit

Permalink
idl: generate API reference readme with correct version
Browse files Browse the repository at this point in the history
Signed-off-by: Pau Ruiz Safont <[email protected]>
  • Loading branch information
psafont committed Jan 12, 2024
1 parent 8db76b3 commit 13da274
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ocaml/xenopsd/scripts/xen-backend.rules
ocaml/xenopsd/xentoollog_flags

ocaml/idl/gen_lifecycle.exe
ocaml/idl/datamodel_main.exe

.hugo_build.lock
go.sum
Expand Down
9 changes: 7 additions & 2 deletions ocaml/idl/dune
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,26 @@
(libraries
dune-build-info
mustache
xapi-consts.xapi_version
xapi-datamodel
xapi-stdext-std
xapi-stdext-pervasives
xapi-stdext-unix
)
(promote (until-clean))
)

; use the binary promoted file from the source dir (not the build dir) that has
; the correct version number embedded
(rule
(alias markdowngen)
(deps
(:x datamodel_main.exe)
datamodel_main.exe
(source_tree templates)
(universe)
)
(package xapi-datamodel)
(action (run %{x} -closed -markdown))
(action (system "%{project_root}/../../ocaml/idl/datamodel_main.exe -closed -markdown"))
)

(test
Expand Down
7 changes: 7 additions & 0 deletions ocaml/idl/markdown_backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,12 @@ let generate_errors () =
("api_errors.mustache", "api-ref-autogen-errors.md")
error_json templatesdir destdir

let generate_ref () =
let ref_json = `O [("version", `String Xapi_version.version)] in
render_file
("api_ref.mustache", "api-ref-autogen.md")
ref_json templatesdir destdir

let all api =
(* Remove private messages that are only used internally (e.g. get_record_internal) *)
let api =
Expand All @@ -549,6 +555,7 @@ let all api =
in

List.iter generate_class system ;
generate_ref () ;
generate_classes system ;
generate_relationships api ;
generate_types system ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# API Reference

Version **@xapi-version@**
Version {{version}}

- [Classes](@root@management-api/classes.html)
- [Relationships Between Classes](@root@management-api/relationships-between-classes.html)
Expand Down

0 comments on commit 13da274

Please sign in to comment.