lib/note.mli -rw-r--r-- 2.3 KiB
1module Frontmatter : sig
2 type t = { path : string; description : string option; tags : string list }
3 (* metadata in the heading of each markdown file seperated by --- *)
4end
5
6type t
7(* a note represented as a tuple of frontmatter and raw text content *)
8
9val to_string : t -> string
10(* return a note with frontmatter and content *)
11
12val of_string : ?path:string option -> string -> t
13(* parse a note with optional frontmatter data *)
14
15val to_json : t -> Ezjsonm.value
16(* get a note as json data with structured data extracted from it *)
17
18val to_html : t -> string
19(* return the html form of a note *)
20
21val frontmatter : t -> Frontmatter.t
22(* get decoded frontmatter structure *)
23
24val content : t -> string
25(* get the raw text content without frontmatter heading *)
26
27module Tree : sig
28 type tree = Tree of (t * tree list)
29 (* notes stored in a b-tree like data structure *)
30
31 val fst : tree -> t
32 (* return the top level note of a given tree *)
33
34 val flatten : tree -> t list
35 (* flatten a tree into a list of notes *)
36
37 val to_json : tree -> Ezjsonm.value
38 (* return a json representation of each note and their descendants *)
39
40 val to_html : tree -> string
41 (* return an html represetation of each note and their descendants *)
42
43end
44
45(*
46 * high level adapter options for interaction from the CLI
47 *)
48type options = {
49 state_dir : string;
50 editor : string;
51 on_modification : string option;
52}
53(* runtime options for interacting with the filesystem and manifest document*)
54
55val load : path:string -> options -> Tree.tree
56(* load all notes below the given path *)
57
58val find : path:string -> options -> t option
59(* find a single note *)
60
61val create :
62 ?description:string option ->
63 ?tags:string list ->
64 ?content:string option ->
65 path:string ->
66 options ->
67 unit
68(* create a new note opening it in an editor if no content is given *)
69
70val remove : path:string -> options -> unit
71(* remove an existing note *)
72
73val edit : path:string -> options -> unit
74(* edit an existing note opening it in the configured editor *)
75
76(* helper functions for autocomplete *)
77module Completion : sig
78 val suggest_paths : hint:string -> options -> string list
79 (* suggest paths for autocomplete *)
80
81 val suggest_tags : hint:string -> options -> string list
82 (* suggest tags for autocomplete *)
83end