I often write scientific texts in which I need to cite existing work. However, citing crates can be a hassle since most do not provide predefined citation and so you have to scramble together your very own version of it. But this problem should be solvable. After all, basically all crates are published on crates.io from which we can retrieve metadata in order to automatically generate our very own BiBTeX entry.
Base Crate
The base crate is a pure Rust library.
It relies on multiple dependencies, most notably reqwest,
biblatex,
citeworks-cff and modified version of the
crates_io_api crate which provides wasm support:
crates_io_api-wasm-patch.
The last modification was necessary in order to provide Wasm support for the webapp.
Its main functionality is provided by the get_biblatex function.
|
|
The get_biblatex function retrieves information from [crates.io] and then queries the github
repository for more information.
It also searches for additional files which might contain a bibliography entry.
At the time of writing, 2 formats are supported: CFF,BibLaTeX.
The base crate also provides functions for only querying github.com or
crates.io.
The base crate also contains python bindings which are generated with pyo3 and maturin and automatically published to pypi.
|
|
Cli
The crate2bib-cli crate provides a simply interface for using the crate from the command line.
[user@machine ~]$ crate2bib nalgebra -v 0.33
Generated enty from crates.io information
@software {Crozet2024,
author = {Sébastien Crozet},
title = {{nalgebra}: General-purpose linear algebra library with transformations and statically-sized or dynamically-sized matrices.},
url = {https://github.com/dimforge/nalgebra},
date = {2024-10-29},
version = {0.33.2},
license = {Apache-2.0},
}
WebApp
The crate2bib-app uses dioxus for the web-app. Building project was relatively straightforward due to the Wasm support of crate2bib. It is automatically built and hosted on the Github-provided pages of the repository.