fig 2.0.0

Parse, edit, and convert config files while preserving comments. Supports JSON, YAML, TOML, and more.
[package]
name = "fig"
version.workspace = true
edition.workspace = true
license.workspace = true
description = "Parse, edit, and convert config files while preserving comments. Supports JSON, YAML, TOML, and more."
repository = "https://github.com/adammharris/fig"
# Rendered by crates.io on the package page. The file is the repo-root `fig.md`,
# copied in by `zig build vendor-rust` before publishing (git-ignored here, so
# `include` force-adds it to the tarball — see below). A local checkout that has
# not run the vendor step simply has no README.md; cargo only requires it when
# packaging/publishing, not for `build`/`test`.
readme = "README.md"
links = "fig"
# The crate builds the fig core from Zig source (see build.rs). That source is
# not in this directory in a checkout — build.rs walks up to the repo root — so
# `zig build vendor-rust` copies it into ./zig before publishing. ./zig is
# git-ignored, so `include` (an allowlist that bypasses VCS rules) is what
# actually puts it in the packaged tarball.
# Precise paths (not `zig/**/*`) so a stray build cache — a `.zig-cache/` or
# `zig-out/` left by running `zig build` inside the vendor dir — never lands in
# the tarball. These mirror the set `vendor-rust` copies.
include = [
    "build.rs",
    "src/**/*",
    "zig/build.zig",
    "zig/build.zig.zon",
    "zig/src/**/*",
    "zig/bindings/c/include/**/*",
    # Vendored in by `zig build vendor-rust` from the repo root (git-ignored here).
    "LICENSE-MIT",
    "LICENSE-APACHE",
    "README.md",
]

[lib]
name = "fig"
path = "src/lib.rs"

# JSON is in `default`, not implied by the base crate: `--no-default-features`
# compiles it out too (like any other language). `serde` is opt-in — the crate
# parses, edits, and serializes through the `Value` tree (and `#[derive]`) with
# no serde at all.
[features]
default = ["json", "yaml", "toml", "fig"]
# Typed (de)serialization: `to_string`/`from_str`, the editor's `T: Serialize`
# value methods, and serde impls for `Value`. Opt-in (not in `default`); without
# it, the binding still parses, edits, and serializes via the `Value` tree
# directly, and `#[derive(ToValue, FromValue)]` covers typed struct mapping.
serde = ["dep:serde"]
# Ergonomic typed mapping without serde: `#[derive(fig::ToValue, fig::FromValue)]`
# generates straight-line conversions to/from the concrete `Value` tree (no
# format-generic Visitor machinery), via the `fig-macros` proc-macro crate.
derive = ["dep:fig-macros"]
# `ToValue`/`FromValue` impls for `indexmap::IndexMap<String, T>`, preserving
# insertion order (unlike the std map impls). Opt-in to keep the dep optional.
indexmap = ["dep:indexmap"]
# Per-language gates, mirroring `build.zig`'s `-D<lang>` options. Each is passed
# through to the bundled `zig build` (see `build.rs`), so disabling a feature
# compiles that format's parser/printer out of the linked `libfig.a` and shrinks
# the binary. `json` gates the shared JSON/JSONC/JSON5 core. The `Format` enum
# keeps every variant regardless; selecting a format whose feature is off returns
# `Error::UnsupportedFormat` at runtime.
json = []
yaml = []
toml = []
zon = []
xml = []
fig = []

[dependencies]
serde = { version = "1", optional = true }
fig-macros = { workspace = true, optional = true }
indexmap = { version = "2", optional = true }

[dev-dependencies]
serde = { version = "1", features = ["derive"] }