Skip to content

Commit

Permalink
feat(api): unflagged ensure_v2 fns, and docsrs improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Dec 22, 2024
1 parent 5aa81f8 commit 99dec9f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@
//! ```
//!
//! ## 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
//! `FromStr` implementations try to parse their inputs as `v2`, and, if that
//! 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")]

Expand Down
3 changes: 1 addition & 2 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 99dec9f

Please sign in to comment.