Google Docs API client for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-gdocs: enable MDX on lib/gdocs.mli, fix broken doc example

Run mdx on lib/gdocs.mli so the {[ ... ]} odoc block now type-checks
against the real Gdocs.get / Markdown / Document API.

The example used `let token : Gauth.token = (* ... *) in`, where
`(* ... *)` is not OCaml syntax, and `Result.get_ok` to swallow
errors. Wrapped in `let run ~(token : Gauth.token) ~doc_id = ...` so
the user supplies the credentials, and pattern-matched on
[Gdocs.get]'s `(_, [`Msg of string]) result` so the example shows
both the success and failure paths.

+10 -5
+4
lib/dune
··· 14 14 unix 15 15 uri 16 16 nox-xdge)) 17 + 18 + (mdx 19 + (files gdocs.mli) 20 + (libraries gdocs gauth requests eio eio.core eio.unix eio_main))
+6 -5
lib/gdocs.mli
··· 11 11 {1 Example} 12 12 13 13 {[ 14 + let run ~(token : Gauth.token) ~doc_id = 14 15 Eio_main.run @@ fun env -> 15 16 Eio.Switch.run @@ fun sw -> 16 17 let http = Requests.v ~sw env in 17 - let clock = Eio.Stdenv.clock env in 18 - let token : Gauth.token = (* ... *) in 19 - let doc = Gdocs.get http ~token "1abcDEF...xyz" |> Result.get_ok in 20 - print_endline (Gdocs.Document.title doc); 21 - print_endline (Gdocs.Markdown.of_document doc) 18 + match Gdocs.get http ~token doc_id with 19 + | Error (`Msg e) -> Format.eprintf "fetch failed: %s@." e 20 + | Ok doc -> 21 + print_endline (Gdocs.Document.title doc); 22 + print_endline (Gdocs.Markdown.of_document doc) 22 23 ]} *) 23 24 24 25 module Store = Store