feat(api): unflagged ensure_v2 fns, and docsrs improvements

This commit is contained in:
Kat Marchán 2024-12-22 12:38:52 -08:00
parent 5aa81f8e15
commit 99dec9fa2c
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
7 changed files with 17 additions and 12 deletions

View File

@ -27,3 +27,10 @@ kdlv1 = { package = "kdl", version = "4.7.0", optional = true }
[dev-dependencies] [dev-dependencies]
miette = { version = "7.2.0", features = ["fancy"] } miette = { version = "7.2.0", features = ["fancy"] }
pretty_assertions = "1.3.0" 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"]

View File

@ -147,7 +147,7 @@ You must be at least `1.70.0` tall to get on this ride.
### License ### License
The code in this repository is covered by [the Apache-2.0 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 [`KdlDocument`]: https://docs.rs/kdl/latest/kdl/struct.KdlDocument.html
[`KdlNode`]: https://docs.rs/kdl/latest/kdl/struct.KdlNode.html [`KdlNode`]: https://docs.rs/kdl/latest/kdl/struct.KdlNode.html

View File

@ -221,7 +221,7 @@ impl KdlDocument {
/// Clears leading and trailing text (whitespace, comments). `KdlNode`s in /// Clears leading and trailing text (whitespace, comments). `KdlNode`s in
/// this document will be unaffected. /// 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) { pub fn clear_format(&mut self) {
self.format = None; self.format = None;
} }
@ -385,7 +385,6 @@ impl KdlDocument {
} }
/// Makes sure this document is in v2 format. /// Makes sure this document is in v2 format.
#[cfg(feature = "v1")]
pub fn ensure_v2(&mut self) { pub fn ensure_v2(&mut self) {
// No need to touch KdlDocumentFormat, probably. In the longer term, // No need to touch KdlDocumentFormat, probably. In the longer term,
// we'll want to make sure to parse out whitespace and comments and make // we'll want to make sure to parse out whitespace and comments and make

View File

@ -83,7 +83,7 @@ impl KdlEntry {
/// Gets this entry's span. /// 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 /// but may become invalidated if the document is mutated. We do not currently
/// guarantee this to yield any particularly consistent results at that point. /// guarantee this to yield any particularly consistent results at that point.
#[cfg(feature = "span")] #[cfg(feature = "span")]
@ -221,7 +221,6 @@ impl KdlEntry {
} }
/// Makes sure this entry is in v2 format. /// Makes sure this entry is in v2 format.
#[cfg(feature = "v1")]
pub fn ensure_v2(&mut self) { pub fn ensure_v2(&mut self) {
let value_repr = self.format.as_ref().map(|x| { let value_repr = self.format.as_ref().map(|x| {
match &self.value { match &self.value {

View File

@ -42,7 +42,7 @@ impl KdlIdentifier {
/// Gets this identifier's span. /// 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 /// but may become invalidated if the document is mutated. We do not currently
/// guarantee this to yield any particularly consistent results at that point. /// guarantee this to yield any particularly consistent results at that point.
#[cfg(feature = "span")] #[cfg(feature = "span")]

View File

@ -145,7 +145,7 @@
//! ## License //! ## License
//! //!
//! The code in this repository is covered by [the Apache-2.0 //! The code in this repository is covered by [the Apache-2.0
//! License](LICENSE). //! License](./LICENSE).
// TODO(@zkat): bring this back later. // TODO(@zkat): bring this back later.
// ### Query Engine // ### Query Engine
@ -183,6 +183,7 @@
#![deny(missing_debug_implementations, nonstandard_style)] #![deny(missing_debug_implementations, nonstandard_style)]
#![warn(missing_docs, rust_2018_idioms, unreachable_pub)] #![warn(missing_docs, rust_2018_idioms, unreachable_pub)]
#![cfg_attr(test, deny(warnings))] #![cfg_attr(test, deny(warnings))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(html_favicon_url = "https://kdl.dev/favicon.ico")] #![doc(html_favicon_url = "https://kdl.dev/favicon.ico")]
#![doc(html_logo_url = "https://kdl.dev/logo.svg")] #![doc(html_logo_url = "https://kdl.dev/logo.svg")]

View File

@ -130,7 +130,7 @@ impl KdlNode {
/// their formatting will be preserved. /// their formatting will be preserved.
/// ///
/// If you want to clear formatting on all children and entries as well, /// 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) { pub fn clear_format(&mut self) {
self.format = None; self.format = None;
} }
@ -355,7 +355,6 @@ impl KdlNode {
} }
/// Makes sure this node is in v2 format. /// Makes sure this node is in v2 format.
#[cfg(feature = "v1")]
pub fn ensure_v2(&mut self) { pub fn ensure_v2(&mut self) {
self.ty = self.ty.take().map(|ty| ty.value().into()); self.ty = self.ty.take().map(|ty| ty.value().into());
let v2_name: KdlIdentifier = self.name.value().into(); let v2_name: KdlIdentifier = self.name.value().into();