From 99dec9fa2c97c6a290445a94e112778397ef5358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Sun, 22 Dec 2024 12:38:52 -0800 Subject: [PATCH] feat(api): unflagged ensure_v2 fns, and docsrs improvements --- Cargo.toml | 7 +++++++ README.md | 2 +- src/document.rs | 3 +-- src/entry.rs | 3 +-- src/identifier.rs | 2 +- src/lib.rs | 9 +++++---- src/node.rs | 3 +-- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e317dd4..0aa5d56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,3 +27,10 @@ kdlv1 = { package = "kdl", version = "4.7.0", optional = true } [dev-dependencies] miette = { version = "7.2.0", features = ["fancy"] } pretty_assertions = "1.3.0" + +# docs.rs-specific configuration +[package.metadata.docs.rs] +# document all features +all-features = true +# defines the configuration attribute `docsrs` +rustdoc-args = ["--cfg", "docsrs"] \ No newline at end of file diff --git a/README.md b/README.md index 99c6607..918eda4 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ You must be at least `1.70.0` tall to get on this ride. ### License The code in this repository is covered by [the Apache-2.0 -License](LICENSE). +License](./LICENSE). [`KdlDocument`]: https://docs.rs/kdl/latest/kdl/struct.KdlDocument.html [`KdlNode`]: https://docs.rs/kdl/latest/kdl/struct.KdlNode.html diff --git a/src/document.rs b/src/document.rs index 0abf693..1bd7fcf 100644 --- a/src/document.rs +++ b/src/document.rs @@ -221,7 +221,7 @@ impl KdlDocument { /// Clears leading and trailing text (whitespace, comments). `KdlNode`s in /// this document will be unaffected. /// - /// If you need to clear the `KdlNode`s, use [`Self::clear_fmt_recursive`]. + /// If you need to clear the `KdlNode`s, use [`Self::clear_format_recursive`]. pub fn clear_format(&mut self) { self.format = None; } @@ -385,7 +385,6 @@ impl KdlDocument { } /// Makes sure this document is in v2 format. - #[cfg(feature = "v1")] pub fn ensure_v2(&mut self) { // No need to touch KdlDocumentFormat, probably. In the longer term, // we'll want to make sure to parse out whitespace and comments and make diff --git a/src/entry.rs b/src/entry.rs index d37c78c..4677838 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -83,7 +83,7 @@ impl KdlEntry { /// Gets this entry's span. /// - /// This value will be properly initialized when created via [`KdlDocument::parse`] + /// This value will be properly initialized when created via [`crate::KdlDocument::parse`] /// but may become invalidated if the document is mutated. We do not currently /// guarantee this to yield any particularly consistent results at that point. #[cfg(feature = "span")] @@ -221,7 +221,6 @@ impl KdlEntry { } /// Makes sure this entry is in v2 format. - #[cfg(feature = "v1")] pub fn ensure_v2(&mut self) { let value_repr = self.format.as_ref().map(|x| { match &self.value { diff --git a/src/identifier.rs b/src/identifier.rs index f7767a5..796e5c4 100644 --- a/src/identifier.rs +++ b/src/identifier.rs @@ -42,7 +42,7 @@ impl KdlIdentifier { /// Gets this identifier's span. /// - /// This value will be properly initialized when created via [`KdlDocument::parse`] + /// This value will be properly initialized when created via [`crate::KdlDocument::parse`] /// but may become invalidated if the document is mutated. We do not currently /// guarantee this to yield any particularly consistent results at that point. #[cfg(feature = "span")] diff --git a/src/lib.rs b/src/lib.rs index e3eff78..d063190 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,8 +104,8 @@ //! ``` //! //! ## Features -//! -//! * `span` (default) - Includes spans in the various document-related structs. +//! +//! * `span` (default) - Includes spans in the various document-related structs. //! * `v1` - Adds support for v1 parsing. This will pull in the entire previous //! version of `kdl-rs`, and so may be fairly heavy. //! * `v1-fallback` - Implies `v1`. Makes it so the various `*::parse()` and @@ -113,7 +113,7 @@ //! fails, try again with `v1`. Errors will only be reported as if the input was //! `v2`. To manage this more precisely, you can use the `*::parse_v2` and //! `*::parse_v1` methods. -//! +//! //! ## Quirks //! //! ### Properties @@ -145,7 +145,7 @@ //! ## License //! //! The code in this repository is covered by [the Apache-2.0 -//! License](LICENSE). +//! License](./LICENSE). // TODO(@zkat): bring this back later. // ### Query Engine @@ -183,6 +183,7 @@ #![deny(missing_debug_implementations, nonstandard_style)] #![warn(missing_docs, rust_2018_idioms, unreachable_pub)] #![cfg_attr(test, deny(warnings))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc(html_favicon_url = "https://kdl.dev/favicon.ico")] #![doc(html_logo_url = "https://kdl.dev/logo.svg")] diff --git a/src/node.rs b/src/node.rs index 6bfc41a..df44293 100644 --- a/src/node.rs +++ b/src/node.rs @@ -130,7 +130,7 @@ impl KdlNode { /// their formatting will be preserved. /// /// If you want to clear formatting on all children and entries as well, - /// use [`Self::clear_fmt_recursive`]. + /// use [`Self::clear_format_recursive`]. pub fn clear_format(&mut self) { self.format = None; } @@ -355,7 +355,6 @@ impl KdlNode { } /// Makes sure this node is in v2 format. - #[cfg(feature = "v1")] pub fn ensure_v2(&mut self) { self.ty = self.ty.take().map(|ty| ty.value().into()); let v2_name: KdlIdentifier = self.name.value().into();