List and diff the public API of Rust library crates by analyzing rustdoc JSON output files from the nightly toolchain.
This library is the backbone of cargo public-api
.
The library comes with a thin bin wrapper that can be used to explore the capabilities of this library.
```bash
cargo install public-api
rustup install nightly ```
To list all items that form the public API of your Rust library:
```bash
% cd ~/src/your_library % RUSTDOCFLAGS='-Z unstable-options --output-format json' cargo +nightly doc --lib --no-deps
% public-api ./target/doc/yourlibrary.json
pub mod publicapi
pub fn publicapi::Options::clone(&self) -> Options
pub fn publicapi::Options::default() -> Self
pub fn publicapi::PublicItem::clone(&self) -> PublicItem
pub fn publicapi::publicapifromrustdocjsonstr(rustdocjsonstr: &str, options: Options) -> Result
It is frequently of interest to know how the public API of a crate has changed. You can find this out by doing a diff between different versions of the same library. The higher level tool cargo public-api
makes this more convenient, but it is possible without it.
```bash
% public-api ./target/doc/yourlibrary.old.json ./target/doc/yourlibrary.json Removed: (nothing)
Changed:
-pub fn publicapi::sortedpublicapifromrustdocjsonstr(rustdocjsonstr: &str) -> Result
Added: +pub fn publicapi::Options::clone(&self) -> Options +pub fn publicapi::Options::default() -> Self +pub struct publicapi::Options +pub struct field publicapi::Options::withblanketimplementations: bool ```
Documentation can be found at docs.rs as usual. There are also some simple examples on how to use the library. The code for the thin bin wrapper might also be of interest.
The code for this library used to live at https://github.com/Enselic/public-api. So git tags for old versions are found in that repo rather than this repo.