r-description-parser 0.4.0

Lossless, failure-tolerant R DESCRIPTION metadata
Documentation

r-description-parser

Lossless, failure-tolerant parsing, validation, building, and editing of R package DESCRIPTION files.

crates.io | API documentation | repository

cargo add r-description-parser

The package name is r-description-parser; the Rust library name is r_description.

use r_description::Description;

let description = Description::parse(
    "Package: example\nVersion: broken\nTitle: Example\nDescription: Demo\nLicense: MIT\nAuthors@R: person('A', 'B')\n",
);

assert_eq!(description.package().unwrap().as_str(), "example");
assert!(description.version_parsed().unwrap().is_err());
assert_eq!(description.to_string().lines().next(), Some("Package: example"));

Parsing preserves the original text and never rejects malformed DCF syntax. Structural diagnostics, document validation, and field-local semantic parsing are separate, so one malformed field does not prevent access to unrelated metadata. Duplicate lookup follows R's case-sensitive, last-occurrence behavior.

See the workspace overview for the lower-level syntax and semantic-value crates.

PACKAGES record conversion

The r-packages-parser crate provides lossless conversions between Description and r_packages::PackageRecord, using From and TryFrom. See its conversion documentation for examples and the record-count, malformed-input, and formatting contract.

License

MIT