Skip to content

Commit

Permalink
(ood-gen) Adjust type of fields with option type in Workshop (#2068)
Browse files Browse the repository at this point in the history
* remove option type from  Workshop.presentation.poster

* remove option type from Workshop.presentation.additional_links
  • Loading branch information
egmaleta authored Feb 20, 2024
1 parent 2037d05 commit 31f69ad
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/ocamlorg_data/data.mli
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ module Workshop : sig
link : string option;
video : string option;
slides : string option;
poster : bool option;
additional_links : string list option;
poster : bool;
additional_links : string list;
}

type t = {
Expand Down
34 changes: 28 additions & 6 deletions tool/ood-gen/lib/workshop.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type committee_member = {
}
[@@deriving of_yaml, show { with_path = false }]

type presentation = {
type presentation_metadata = {
title : string;
authors : string list;
link : string option;
Expand All @@ -36,12 +36,26 @@ type metadata = {
location : string;
date : string;
important_dates : important_date list;
presentations : presentation list;
presentations : presentation_metadata list;
program_committee : committee_member list;
organising_committee : committee_member list;
}
[@@deriving of_yaml]

type presentation = {
title : string;
authors : string list;
link : string option;
video : string option;
slides : string option;
poster : bool;
additional_links : string list;
}
[@@deriving
stable_record ~version:presentation_metadata
~modify:[ poster; additional_links ],
show { with_path = false }]

type t = {
title : string;
slug : string;
Expand All @@ -55,10 +69,18 @@ type t = {
body_html : string;
}
[@@deriving
stable_record ~version:metadata ~remove:[ slug; body_md; body_html ],
stable_record ~version:metadata ~modify:[ presentations ]
~remove:[ slug; body_md; body_html ],
show { with_path = false }]

let of_metadata m = of_metadata m ~slug:(Utils.slugify m.title)
let of_presentation_metadata pm =
presentation_of_presentation_metadata pm
~modify_poster:(Option.value ~default:false)
~modify_additional_links:(Option.value ~default:[])

let of_metadata m =
of_metadata m ~slug:(Utils.slugify m.title)
~modify_presentations:(List.map of_presentation_metadata)

let decode (fpath, (head, body_md)) =
let metadata =
Expand Down Expand Up @@ -95,8 +117,8 @@ type presentation = {
link : string option;
video : string option;
slides : string option;
poster : bool option;
additional_links : string list option;
poster : bool;
additional_links : string list;
}

type t = {
Expand Down

0 comments on commit 31f69ad

Please sign in to comment.