Skip to main content

grobid_bibtex/
lib.rs

1//! A reference management system for scientific writing.
2//!
3//! `grobid-bibtex` combines [GROBID] for reference extraction and [OpenAlex]
4//! for reference completion with a data model organized around
5//! BibTeX/BibLaTeX. It is the foundation for user-facing tools such as
6//! editor plugins (citation keys, duplicate detection, pickers) and LLM- or
7//! RAG-based writing assistants (structured, deduplicated bibliography
8//! data).
9//!
10//! The modules follow the pipeline of that workflow:
11//!
12//! - [`extract`]: turn PDFs into [`Biblio`] records with a GROBID server.
13//! - `complete` (feature `openalex`): fill gaps in extracted records from
14//!   OpenAlex.
15//! - [`collection`]: parse, index and append `.bib` files; assign citation
16//!   keys; detect and merge duplicates.
17//! - [`bibtex`]: render individual records as BibLaTeX and derive citation
18//!   keys and file names.
19//! - [`files`]: work with the PDFs behind the records (discovery, renaming).
20//! - [`cite`]: resolve `@key` mentions in a query to documents in a corpus
21//!   (`cite_keys`, [`cite::CiteState`], [`cite::load_documents`]).
22//! - `prepass` (feature `pipeline`): the orchestration around those modules —
23//!   fingerprint, extract, complete, rename and merge a corpus, with
24//!   progress and cancellation hooks.
25//!
26//! The `pdf2bibtex` and `refs2bibtex` binaries are front ends over these
27//! modules.
28//!
29//! # Example
30//!
31//! ```
32//! use std::path::PathBuf;
33//!
34//! use grobid_bibtex::collection::Collection;
35//! use grobid_bibtex::{Author, Biblio, FileLink};
36//!
37//! let biblio = Biblio {
38//!     authors: vec![Author {
39//!         surname: Some("Kahle".to_string()),
40//!         ..Author::default()
41//!     }],
42//!     date: Some("2000".to_string()),
43//!     ..Biblio::default()
44//! };
45//! let collection = Collection::new();
46//! let entries = collection.format_all(
47//!     &[(PathBuf::from("paper.pdf"), biblio)],
48//!     &FileLink::Absolute,
49//! );
50//! assert!(entries[0].1.starts_with("@misc{Kahle2000,"));
51//! ```
52//!
53//! [GROBID]: https://grobid.readthedocs.io/
54//! [OpenAlex]: https://openalex.org/
55//!
56//! The full README is included below.
57#![doc = include_str!("../README.md")]
58#![forbid(unsafe_code)]
59#![warn(missing_docs)]
60#![warn(clippy::missing_errors_doc)]
61#![warn(clippy::missing_panics_doc)]
62
63pub mod bibtex;
64pub mod cite;
65pub mod collection;
66#[cfg(feature = "openalex")]
67pub mod complete;
68pub mod extract;
69pub mod files;
70#[cfg(feature = "pipeline")]
71pub mod prepass;
72
73#[cfg(feature = "openalex")]
74pub use grobid::openalex;
75
76pub use bibtex::FileLink;
77pub use collection::Collection;
78pub use grobid::tei;
79pub use grobid::{
80    Author, Biblio, Citation, CitationConsolidation, DEFAULT_GROBID_URL, Error, GrobidClient,
81    GrobidClientBuilder, HeaderConsolidation, PdfInput, ProcessOptions, RetryPolicy,
82};