Skip to content

Commit

Permalink
Warn on missing documentation on public items. Documented a few items.
Browse files Browse the repository at this point in the history
  • Loading branch information
orium committed Sep 12, 2023
1 parent 483cb83 commit 9d88dbf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/base/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ use std::cell::Cell;
use std::ops::Deref;
use std::rc::Rc;

/// A charset encoding that can be shared and modified.
///
/// This is, for instance, used to adapt the charset dynamically in a [crate::HtmlRewriter] if it
/// encounters a `meta` tag that specifies the charset (that behavior is dependent on
/// [crate::Settings::adjust_charset_on_meta_tag]).
#[derive(Clone)]
pub struct SharedEncoding {
encoding: Rc<Cell<AsciiCompatibleEncoding>>,
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
//! [`HtmlRewriter`]: struct.HtmlRewriter.html
//! [`rewrite_str`]: fn.rewrite_str.html

// TODO Uncomment this once we have all items documented.
// #![cfg_attr(not(any(feature = "integration_test", test)), warn(missing_docs))]

#[macro_use]
mod base;

Expand Down Expand Up @@ -166,7 +169,6 @@ cfg_if! {
EndTag, Serialize, StartTag, Token, TokenCaptureFlags, Mutations
};

pub use self::base::Bytes;
pub use self::memory::MemoryLimiter;
pub use self::html::{LocalName, LocalNameHash, Tag, Namespace};
} else {
Expand Down
9 changes: 9 additions & 0 deletions src/rewritable_units/tokens/end_tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,25 @@ impl<'i> EndTag<'i> {
self.set_name(Bytes::from_string(name, self.encoding))
}

/// Inserts `content` before the end tag.
///
/// Consequent calls to the method append `content` to the previously inserted content.
#[inline]
pub fn before(&mut self, content: &str, content_type: ContentType) {
self.mutations.before(content, content_type);
}

/// Inserts `content` after the end tag.
///
/// Consequent calls to the method prepend `content` to the previously inserted content.
#[inline]
pub fn after(&mut self, content: &str, content_type: ContentType) {
self.mutations.after(content, content_type);
}

/// Replaces the end tag with `content`.
///
/// Consequent calls to the method overwrite previous replacement content.
#[inline]
pub fn replace(&mut self, content: &str, content_type: ContentType) {
self.mutations.replace(content, content_type);
Expand Down
9 changes: 9 additions & 0 deletions src/rewritable_units/tokens/start_tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,25 @@ impl<'i> StartTag<'i> {
self.self_closing
}

/// Inserts `content` before the start tag.
///
/// Consequent calls to the method append `content` to the previously inserted content.
#[inline]
pub fn before(&mut self, content: &str, content_type: ContentType) {
self.mutations.before(content, content_type);
}

/// Inserts `content` after the start tag.
///
/// Consequent calls to the method prepend `content` to the previously inserted content.
#[inline]
pub fn after(&mut self, content: &str, content_type: ContentType) {
self.mutations.after(content, content_type);
}

/// Replaces the start tag with `content`.
///
/// Consequent calls to the method overwrite previous replacement content.
#[inline]
pub fn replace(&mut self, content: &str, content_type: ContentType) {
self.mutations.replace(content, content_type);
Expand Down

0 comments on commit 9d88dbf

Please sign in to comment.