Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: rename mox->blox #159

Merged
merged 4 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ keywords = ["slack", "messages", "models", "ergonomic", "fully-documented"]
categories = ["data-structures"]

[features]
unstable = ["xml", "validation"]
xml = ["mox"]
unstable = ["blox", "validation"]
blox = ["mox"]
validation = []

[package.metadata.docs.rs]
Expand Down
6 changes: 3 additions & 3 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ dependencies = ["install-fmt"]

[tasks.doctest-slow]
command = "cargo"
args = ["--locked", "test", "--features", "xml", "--jobs", "1", "--doc", "--", "--quiet"]
args = ["--locked", "test", "--features", "blox", "--jobs", "1", "--doc", "--", "--quiet"]

[tasks.doctest]
command = "cargo"
args = ["--locked", "test", "--features", "xml", "--doc", "--", "--quiet"]
args = ["--locked", "test", "--features", "blox", "--doc", "--", "--quiet"]

[tasks.test]
command = "cargo"
args = ["--locked", "test", "--features", "xml", "--tests", "--", "--quiet"]
args = ["--locked", "test", "--features", "blox", "--tests", "--", "--quiet"]
dependencies = ["doctest"]

[tasks.tdd]
Expand Down
2 changes: 2 additions & 0 deletions src/blocks/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ pub mod build {
/// Invoked by `blox!` when a child element is passed to `<actions_block>`.
///
/// Alias of `ActionsBuilder.element`.
#[cfg(feature = "blox")]
#[cfg_attr(docsrs, doc(cfg(feature = "blox")))]
pub fn child<El>(self,
element: El)
-> ActionsBuilder<'a, Set<method::elements>>
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ pub mod build {
}

/// Alias of `element` for appending an element with an XML child.
#[cfg(feature = "xml")]
#[cfg_attr(docsrs, doc(cfg(feature = "xml")))]
#[cfg(feature = "blox")]
#[cfg_attr(docsrs, doc(cfg(feature = "blox")))]
pub fn child<El>(self,
element: El)
-> ContextBuilder<'a, Set<method::elements>>
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ pub mod build {
}

/// XML child alias for `element`
#[cfg(feature = "xml")]
#[cfg_attr(docsrs, doc(cfg(feature = "xml")))]
#[cfg(feature = "blox")]
#[cfg_attr(docsrs, doc(cfg(feature = "blox")))]
pub fn child<El>(self,
element: El)
-> InputBuilder<'a, Set<method::element>, L>
Expand Down
9 changes: 4 additions & 5 deletions src/blocks/section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,9 @@ pub mod build {
///
/// To set `text`, use the `text` attribute.
/// ```
/// use mox::mox;
/// use slack_blocks::{blocks::Section, mox::*, text, text::ToSlackPlaintext};
/// use slack_blocks::{blocks::Section, blox::*, text, text::ToSlackPlaintext};
///
/// let xml = mox! {
/// let xml = blox! {
/// <section_block text={"Section".plaintext()}>
/// <text kind=plain>"Foo"</text>
/// <text kind=plain>"Bar"</text>
Expand All @@ -246,8 +245,8 @@ pub mod build {
///
/// assert_eq!(xml, equiv);
/// ```
#[cfg(feature = "xml")]
#[cfg_attr(docsrs, doc(cfg(feature = "xml")))]
#[cfg(feature = "blox")]
#[cfg_attr(docsrs, doc(cfg(feature = "blox")))]
pub fn child<T>(self, text: T) -> SectionBuilder<'a, Set<method::text>>
where T: Into<text::Text>
{
Expand Down
65 changes: 31 additions & 34 deletions src/mox.rs → src/blox.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
//! # XML macro support
//!
//! This module provides shorthands for builder functions
//! to be used with `mox` or a similar "xml -> Builder" macro.
//! # XML macro builder support

pub use elems::{button::Style::{Danger as btn_danger,
Primary as btn_primary},
Expand All @@ -26,11 +23,11 @@ pub trait IntoChild: Sized {

impl<T> IntoChild for T {}

pub use mox_blocks::*;
pub use mox_compose::*;
pub use mox_elems::*;
pub use blox_blocks::*;
pub use blox_compose::*;
pub use blox_elems::*;

mod mox_blocks {
mod blox_blocks {
use super::*;

/// # Build an actions block
Expand All @@ -40,7 +37,7 @@ mod mox_blocks {
///
/// ## Example
/// ```
/// use slack_blocks::{blocks::Actions, elems::Button, mox::*, text};
/// use slack_blocks::{blocks::Actions, blox::*, elems::Button, text};
///
/// let xml = blox! {
/// <actions_block>
Expand Down Expand Up @@ -74,7 +71,7 @@ mod mox_blocks {
///
/// ## Example
/// ```
/// use slack_blocks::{blocks::Section, mox::*, text};
/// use slack_blocks::{blocks::Section, blox::*, text};
///
/// let xml = blox! {
/// <section_block text=blox!{<text kind=plain>"Foo"</text>} />
Expand All @@ -100,7 +97,7 @@ mod mox_blocks {
///
/// ## Example
/// ```
/// use slack_blocks::{blocks::Input, elems::TextInput, mox::*, text};
/// use slack_blocks::{blocks::Input, blox::*, elems::TextInput, text};
///
/// let xml = blox! {
/// <input_block label="foo">
Expand All @@ -126,7 +123,7 @@ mod mox_blocks {
///
/// ## Example
/// ```
/// use slack_blocks::{blocks::Context, elems::Image, mox::*, text};
/// use slack_blocks::{blocks::Context, blox::*, elems::Image, text};
///
/// let xml = blox! {
/// <context_block>
Expand Down Expand Up @@ -158,7 +155,7 @@ mod mox_blocks {
///
/// ## Example
/// ```
/// use slack_blocks::{blocks::File, mox::*};
/// use slack_blocks::{blocks::File, blox::*};
///
/// let xml = blox! {
/// <file_block external_id="foo" />
Expand All @@ -179,7 +176,7 @@ mod mox_blocks {
///
/// ## Example
/// ```
/// use slack_blocks::{blocks::Image, mox::*};
/// use slack_blocks::{blocks::Image, blox::*};
///
/// let xml = blox! {
/// <img_block src="https://foo.com/bar.png" alt="a pic of bar" />
Expand All @@ -196,7 +193,7 @@ mod mox_blocks {
}
}

mod mox_elems {
mod blox_elems {
use super::*;

/// # Build an text input element
Expand All @@ -206,7 +203,7 @@ mod mox_elems {
///
/// ## Example
/// ```
/// use slack_blocks::{elems::TextInput, mox::*};
/// use slack_blocks::{blox::*, elems::TextInput};
///
/// let xml: TextInput = blox! {
/// <text_input action_id="name_input"
Expand Down Expand Up @@ -238,7 +235,7 @@ mod mox_elems {
///
/// ## Example
/// ```
/// use slack_blocks::{elems::Image, mox::*};
/// use slack_blocks::{blox::*, elems::Image};
///
/// let xml: Image = blox! {
/// <img src="https://foo.com/bar.png" alt="a pic of bar" />
Expand All @@ -261,7 +258,7 @@ mod mox_elems {
///
/// ## Example
/// ```
/// use slack_blocks::{elems::Button, mox::*};
/// use slack_blocks::{blox::*, elems::Button};
///
/// let xml: Button = blox! {
/// <button action_id="click_me">"Click me!"</button>
Expand All @@ -284,7 +281,7 @@ mod mox_elems {
///
/// ## Example
/// ```
/// use slack_blocks::{compose::Opt, elems::Checkboxes, mox::*};
/// use slack_blocks::{blox::*, compose::Opt, elems::Checkboxes};
///
/// let xml: Checkboxes = blox! {
/// <checkboxes action_id="chex">
Expand Down Expand Up @@ -328,7 +325,7 @@ mod mox_elems {
///
/// ## Example
/// ```
/// use slack_blocks::{elems::DatePicker, mox::*};
/// use slack_blocks::{blox::*, elems::DatePicker};
///
/// let xml = blox! {
/// <date_picker action_id="pick_birthday" placeholder="Pick your birthday!" />
Expand All @@ -354,7 +351,7 @@ mod mox_elems {
///
/// ## Example
/// ```
/// use slack_blocks::{compose::Opt, elems::Overflow, mox::*};
/// use slack_blocks::{blox::*, compose::Opt, elems::Overflow};
///
/// let xml = blox! {
/// <overflow action_id="menu">
Expand Down Expand Up @@ -386,7 +383,7 @@ mod mox_elems {
///
/// ## Example
/// ```
/// use slack_blocks::{blocks::Input, compose::Opt, elems::Radio, mox::*};
/// use slack_blocks::{blocks::Input, blox::*, compose::Opt, elems::Radio};
///
/// let xml = blox! {
/// <input_block label="Pick your favorite cheese!">
Expand Down Expand Up @@ -423,8 +420,8 @@ mod mox_elems {
/// # Build a select menu
///
/// # Attributes
/// - `kind` (Optional): `single` or `multi` from `slack_blocks::mox`. Default is `single`.
/// - `choose_from` (Required): `users`, `public_channels`, `static_`, `external`, `conversations` from `slack_blocks::mox`
/// - `kind` (Optional): `single` or `multi` from `slack_blocks::blox`. Default is `single`.
/// - `choose_from` (Required): `users`, `public_channels`, `static_`, `external`, `conversations` from `slack_blocks::blox`
///
/// # Children
/// For `static_`, 1-100 `<option>` children are allowed.
Expand All @@ -439,7 +436,7 @@ mod mox_elems {
/// # Example - Select many Users
/// ```
/// use slack_blocks::elems::select;
/// use slack_blocks::mox::*;
/// use slack_blocks::blox::*;
///
/// let xml = blox! {
/// <select kind=multi choose_from=users placeholder="Pick some users!" action_id="foo" />
Expand All @@ -452,7 +449,7 @@ mod mox_elems {
///
/// # Example - Select an option from a list defined by your app
/// ```
/// use slack_blocks::{elems::select, compose::Opt, mox::*};
/// use slack_blocks::{elems::select, compose::Opt, blox::*};
///
/// let xml = blox! {
/// <select choose_from=static_ placeholder="Pick your favorite cheese!" action_id="foo">
Expand All @@ -478,7 +475,7 @@ mod mox_elems {
}
}

mod mox_compose {
mod blox_compose {
use super::*;

/// # Text
Expand All @@ -490,7 +487,7 @@ mod mox_compose {
///
/// ## Example
/// ```
/// use slack_blocks::{blocks::Section, mox::*, text};
/// use slack_blocks::{blocks::Section, blox::*, text};
///
/// let xml = blox! {
/// <text kind=plain>"Foo"</text>
Expand All @@ -514,7 +511,7 @@ mod mox_compose {
///
/// ## Example
/// ```
/// use slack_blocks::{compose::Opt, mox::*};
/// use slack_blocks::{blox::*, compose::Opt};
///
/// let xml = blox! {
/// <option value="foo">
Expand Down Expand Up @@ -543,8 +540,8 @@ mod mox_compose {
///
/// ## Example - Options known at compile-time
/// ```
/// use slack_blocks::{compose::{Opt, OptGroup},
/// mox::*};
/// use slack_blocks::{blox::*,
/// compose::{Opt, OptGroup}};
///
/// let xml = blox! {
/// <option_group label="foos_and_bars">
Expand All @@ -567,8 +564,8 @@ mod mox_compose {
///
/// ## Example - Dynamic vec of options
/// ```
/// use slack_blocks::{compose::{Opt, OptGroup},
/// mox::*};
/// use slack_blocks::{blox::*,
/// compose::{Opt, OptGroup}};
///
/// # fn uuid() -> String {"foo".to_string()}
/// # fn random_word() -> String {"foo".to_string()}
Expand Down Expand Up @@ -609,7 +606,7 @@ mod mox_compose {
///
/// ## Example
/// ```
/// use slack_blocks::{compose::Confirm, mox::*, text::ToSlackPlaintext};
/// use slack_blocks::{blox::*, compose::Confirm, text::ToSlackPlaintext};
///
/// let xml = blox! {
/// <confirm title="Title"
Expand Down
9 changes: 4 additions & 5 deletions src/compose/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,9 @@ pub mod build {
impl<'a, V, U> OptBuilder<'a, RequiredMethodNotCalled<method::text>, V, U> {
/// Alias for `text`, allowing you to set the text of the option like so:
/// ```
/// use mox::mox;
/// use slack_blocks::{compose::Opt, mox::*, text};
/// use slack_blocks::{blox::*, compose::Opt, text};
///
/// let xml = mox! {
/// let xml = blox! {
/// <option value="foo">
/// <text kind=plain>"Foo"</text>
/// </option>
Expand All @@ -331,8 +330,8 @@ pub mod build {
///
/// assert_eq!(xml, equiv)
/// ```
#[cfg(feature = "xml")]
#[cfg_attr(docsrs, doc(cfg(feature = "xml")))]
#[cfg(feature = "blox")]
#[cfg_attr(docsrs, doc(cfg(feature = "blox")))]
pub fn child<T: Into<text::Text>>(
self,
text: T)
Expand Down
8 changes: 4 additions & 4 deletions src/compose/opt_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ pub mod build {
}

/// XML child alias for `option`.
#[cfg(feature = "xml")]
#[cfg_attr(docsrs, doc(cfg(feature = "xml")))]
#[cfg(feature = "blox")]
#[cfg_attr(docsrs, doc(cfg(feature = "blox")))]
pub fn child<T2, U2>(
self,
option: Opt<'a, T2, U2>)
Expand All @@ -281,8 +281,8 @@ pub mod build {
}

/// XML child alias for `option`.
#[cfg(feature = "xml")]
#[cfg_attr(docsrs, doc(cfg(feature = "xml")))]
#[cfg(feature = "blox")]
#[cfg_attr(docsrs, doc(cfg(feature = "blox")))]
pub fn child(self, option: Opt<'a, T, U>) -> Self {
self.option(option)
}
Expand Down
Loading