Skip to content

Commit

Permalink
Add changelog and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Octachron committed Jan 23, 2023
1 parent 895ffe6 commit 244772f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## 0.5 (23 January 2023)

- First opam release
- Removed global state in the parser: the typed keys are now a separate argument.
- Basic documentation

14 changes: 7 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ Bitex items are stored inside a string map using their identifiants
let item = Bibtex.Database.find "Nothingness" dtb
```

Item fields can be accessed using the open record syntax (see [orec](https://github.com/Octachron/orec)). For convenience, the module Bibtex_fields(=Bibtex.Fields) define a `'a named_field` type which combines an access field with a name and a conversion function to string. The list of predefined fields can be found in the `Bibtex_fields` module.
Item fields can be accessed using the open record syntax (see [orec](https://github.com/Octachron/orec)). For convenience, the module Bibtex_fields(=Bibtex.Fields) define a `'a named_field` type which combines an access field with a name and a conversion function to string. The list of predefined fields can be found in the `Bibtex_fields` module.

```Ocaml
let () =
let open Bibtex.Fields in
assert ( item.{year.f} = Some 1995 );
assert( item.{page.f} = Some ( Interv(0,0) ) );
assert( item.{title.f} = Some "On empty articles" )
assert ( item.%{year.f} = Some 1995 );
assert( item.%{page.f} = Some ( Interv(0,0) ) );
assert( item.%{title.f} = Some "On empty articles" )
```

If needed, more fields can be added to the parser by using the `Bibtex.Parser.add_field` function.
If needed, more fields can be added to the parser by using a custom [~with_keys] arguments.

First-class fields allow to write generic function like
```Ocaml
let mayp field fmt =
let open Bibtex.Fields in
match item.{field} with
match item.%{field} with
| None -> ()
| Some x -> Printf.printf fmt x
Expand Down Expand Up @@ -70,7 +70,7 @@ pages={0-0}
let item = Bibtex.Database.find "Nothingness" dtb
let mayp field fmt =
let open Bibtex.Fields in
match item.{field} with
match item.%{field} with
| None -> ()
| Some x -> Printf.printf fmt x
Expand Down

0 comments on commit 244772f

Please sign in to comment.