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]
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"]

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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")]

View File

@ -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")]

View File

@ -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();