Skip to content

Commit

Permalink
Do not use field attributes (#2943)
Browse files Browse the repository at this point in the history
* Do not use field attributes

* Formatting

* Remove [@printer

---------

Co-authored-by: Cuihtlauac ALVARADO <[email protected]>
  • Loading branch information
cuihtlauac and Cuihtlauac ALVARADO authored Feb 7, 2025
1 parent ecd9974 commit 054907a
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 32 deletions.
82 changes: 50 additions & 32 deletions src/ocamlorg_data/data_intf.ml
Original file line number Diff line number Diff line change
@@ -1,33 +1,51 @@
module Academic_institution = struct
type location = { lat : float; long : float } [@@deriving of_yaml, show]

let pp_ptime fmt t =
Format.pp_print_string fmt "Ptime.of_rfc3339 \"";
Ptime.pp_rfc3339 () fmt t;
Format.pp_print_string fmt
"\" |> function Ok (t, _, _) -> t | Error _ -> failwith \"RFC 3339\""

let pp_print_option pp fmt = function
| None -> Format.pp_print_string fmt "None"
| Some x ->
Format.pp_print_string fmt "Some (";
pp fmt x;
Format.pp_print_string fmt ")"

type course = {
name : string;
acronym : string option;
url : string option;
teacher : string option;
enrollment : string option;
year : int option;
description : string;
last_check : Ptime.t option; [@printer pp_print_option pp_ptime]
lecture_notes : bool;
exercises : bool;
video_recordings : bool;
}
[@@deriving show]
include (
struct
module Ptime = struct
include Ptime

let pp fmt t =
Format.pp_print_string fmt "(Ptime.of_rfc3339 \"";
Ptime.pp_rfc3339 () fmt t;
Format.pp_print_string fmt
"\" |> function Ok (t, _, _) -> t | Error _ -> failwith \"RFC \
3339\")"
end

type course = {
name : string;
acronym : string option;
url : string option;
teacher : string option;
enrollment : string option;
year : int option;
description : string;
last_check : Ptime.t option;
lecture_notes : bool;
exercises : bool;
video_recordings : bool;
}
[@@deriving show]
end :
sig
type course = {
name : string;
acronym : string option;
url : string option;
teacher : string option;
enrollment : string option;
year : int option;
description : string;
last_check : Ptime.t option;
lecture_notes : bool;
exercises : bool;
video_recordings : bool;
}

val pp_course : Format.formatter -> course -> unit
end)

type t = {
name : string;
Expand Down Expand Up @@ -300,11 +318,11 @@ module Governance = struct
name : string;
description : string;
contacts : contact list;
dev_meeting : dev_meeting option; [@default None] [@key "dev-meeting"]
members : Member.t list; [@default []]
subteams : team list; [@default []]
dev_meeting : dev_meeting option;
members : Member.t list;
subteams : team list;
}
[@@deriving of_yaml, show]
[@@deriving show]
end

module Industrial_user = struct
Expand Down Expand Up @@ -611,7 +629,7 @@ module Video = struct
title : string;
url : string;
thumbnail : string;
description : string; [@default ""]
description : string;
published : string;
author_name : string;
author_uri : string;
Expand Down
14 changes: 14 additions & 0 deletions tool/ood-gen/lib/governance.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
open Ocamlorg.Import
open Data_intf.Governance

type team_metadata = {
id : string;
name : string;
description : string;
contacts : contact list;
dev_meeting : dev_meeting option; [@default None] [@key "dev-meeting"]
members : Member.t list; [@default []]
subteams : team_metadata list; [@default []]
}
[@@deriving of_yaml, stable_record ~version:team]

let team_of_yaml yml =
yml |> team_metadata_of_yaml |> Result.map team_metadata_to_team

type metadata = {
teams : team list;
working_groups : team list; [@key "working-groups"]
Expand Down
13 changes: 13 additions & 0 deletions tool/ood-gen/lib/youtube.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
open Ocamlorg.Import
open Data_intf.Video

let to_yaml video =
match to_yaml video with
| `O u -> `O (List.filter (( <> ) ("description", `String "")) u)
| x -> x

let add_key_default k v = function
| `O u when u |> List.split |> fst |> List.mem k |> not ->
prerr_endline k;
`O ((k, v) :: u)
| x -> x

let of_yaml yml = yml |> add_key_default "description" (`String "") |> of_yaml

type kind = Playlist | Channel

let kind_of_string = function
Expand Down

0 comments on commit 054907a

Please sign in to comment.