aboutsummaryrefslogtreecommitdiff
path: root/mingling
diff options
context:
space:
mode:
Diffstat (limited to 'mingling')
-rw-r--r--mingling/Cargo.toml7
-rw-r--r--mingling/src/constants.rs3
-rw-r--r--mingling/src/constants/picker.rs16
-rw-r--r--mingling/src/example_docs.rs8
-rw-r--r--mingling/src/features.rs11
-rw-r--r--mingling/src/lib.md2
-rw-r--r--mingling/src/lib.rs67
-rw-r--r--mingling/src/picker/entry_picker.rs6
-rw-r--r--mingling/src/setups/repl_basic.rs4
9 files changed, 92 insertions, 32 deletions
diff --git a/mingling/Cargo.toml b/mingling/Cargo.toml
index adf900f..351384f 100644
--- a/mingling/Cargo.toml
+++ b/mingling/Cargo.toml
@@ -21,7 +21,9 @@ mingling = { path = ".", features = [
] }
[package.metadata.docs.rs]
+rustdoc-args = ["--generate-link-to-definition"]
features = [
+ "docs_rs",
"core",
"macros",
"builds",
@@ -50,7 +52,7 @@ dispatch_tree = ["mingling_core/dispatch_tree", "mingling_macros/dispatch_tree"]
repl = ["mingling_core/repl", "mingling_macros/repl"]
comp = ["mingling_core/comp", "mingling_macros/comp"]
parser = ["dep:size"]
-picker = ["dep:arg-picker", "arg-picker/mingling_support"]
+picker = ["mingling_core/picker", "dep:arg-picker", "arg-picker/mingling_support"]
pathf = ["mingling_core/pathf", "mingling_macros/pathf"]
structural_renderer = [
@@ -87,6 +89,9 @@ ron_serde_fmt = ["mingling_core/ron_serde_fmt"]
extra_macros = ["mingling_macros/extra_macros"]
+# Section only shown in docs.rs
+docs_rs = []
+
[dependencies]
mingling_core = { workspace = true, optional = true }
mingling_macros = { workspace = true, optional = true }
diff --git a/mingling/src/constants.rs b/mingling/src/constants.rs
index 65d02e8..75f1c73 100644
--- a/mingling/src/constants.rs
+++ b/mingling/src/constants.rs
@@ -4,5 +4,8 @@ mod picker;
#[cfg(feature = "picker")]
pub use picker::*;
+#[cfg(feature = "picker")]
+pub use arg_picker::consts::*;
+
mod exit_codes;
pub use exit_codes::*;
diff --git a/mingling/src/constants/picker.rs b/mingling/src/constants/picker.rs
index f2a448b..d98dcab 100644
--- a/mingling/src/constants/picker.rs
+++ b/mingling/src/constants/picker.rs
@@ -1,20 +1,6 @@
+use arg_picker::{PickerArg, value::Flag};
use std::marker::PhantomData;
-use arg_picker::{PickerArg, PickerArgs, value::Flag};
-
-/// Remaining positional arguments (anything not consumed as an option).
-/// - `full`: `[]` (empty — not triggered by any `--` prefix).
-/// - `short`: (none)
-/// - `positional`: `false` (this is a meta‑argument that collects everything left).
-/// This constant is used internally to access any leftover arguments after
-/// all defined flags/options have been processed.
-pub const REMAINS: PickerArg<PickerArgs> = PickerArg::<PickerArgs> {
- full: &[],
- short: None,
- positional: false,
- internal_type: PhantomData,
-};
-
/// Help flag: display usage information.
/// - `full`: `["help"]`
/// - `short`: `'h'`
diff --git a/mingling/src/example_docs.rs b/mingling/src/example_docs.rs
index bdefb5a..3b36f00 100644
--- a/mingling/src/example_docs.rs
+++ b/mingling/src/example_docs.rs
@@ -2796,25 +2796,25 @@ pub mod example_structural_renderer {}
/// #[test]
/// fn test_render_result_name() {
/// let r = render_result_name(ResultName::new("Peter".into()));
-/// assert_eq!(r.to_string().as_str(), "Hello, Peter!\n")
+/// assert_eq!(r.to_string().as_str(), "Hello, Peter!")
/// }
///
/// #[test]
/// fn test_render_error_no_name_provided() {
/// let r = render_error_no_name_provided(ErrorNoNameProvided::default());
-/// assert_eq!(r.to_string().as_str(), "No name provided\n")
+/// assert_eq!(r.to_string().as_str(), "No name provided")
/// }
///
/// #[test]
/// fn test_render_error_name_not_available() {
/// let r = render_error_name_not_available(ErrorNameNotAvailable::default());
-/// assert_eq!(r.to_string().as_str(), "Name not available\n")
+/// assert_eq!(r.to_string().as_str(), "Name not available")
/// }
///
/// #[test]
/// fn test_render_error_name_too_long() {
/// let r = render_error_name_too_long(ErrorNameTooLong::new(17));
-/// assert_eq!(r.to_string().as_str(), "Name too long: 17 > 10\n")
+/// assert_eq!(r.to_string().as_str(), "Name too long: 17 > 10")
/// }
/// // --------- IMPORTANT ---------
/// }
diff --git a/mingling/src/features.rs b/mingling/src/features.rs
index cb474ae..78d6226 100644
--- a/mingling/src/features.rs
+++ b/mingling/src/features.rs
@@ -97,6 +97,17 @@ pub const MINGLING_DISPATCH_TREE: bool = false;
#[cfg(feature = "dispatch_tree")]
#[allow(unused)]
pub const MINGLING_DISPATCH_TREE: bool = true;
+/// Whether the `docs_rs` feature is enabled
+/// Current: `disabled`
+#[cfg(not(feature = "docs_rs"))]
+#[allow(unused)]
+pub const MINGLING_DOCS_RS: bool = false;
+
+/// Whether the `docs_rs` feature is enabled
+/// Current: `enabled`
+#[cfg(feature = "docs_rs")]
+#[allow(unused)]
+pub const MINGLING_DOCS_RS: bool = true;
/// Whether the `extra_macros` feature is enabled
/// Current: `disabled`
#[cfg(not(feature = "extra_macros"))]
diff --git a/mingling/src/lib.md b/mingling/src/lib.md
index 03fa61d..4d20a8b 100644
--- a/mingling/src/lib.md
+++ b/mingling/src/lib.md
@@ -76,7 +76,7 @@ Command not found: [great]
## Examples
`Mingling` provides detailed usage examples for your reference.
-See [Examples](_mingling_examples/index.html) or [Helpdoc](https://mingling-rs.github.io/mingling/docs/examples.html)
+See [Examples](EXAMPLES/index.html) or [Helpdoc](https://mingling-rs.github.io/mingling/docs/examples.html)
## About Features
diff --git a/mingling/src/lib.rs b/mingling/src/lib.rs
index f4bc9dc..fd274aa 100644
--- a/mingling/src/lib.rs
+++ b/mingling/src/lib.rs
@@ -1,3 +1,8 @@
+#![doc(html_logo_url = "https://github.com/mingling-rs/mingling/raw/main/docs/res/icon3.png")]
+#![doc(
+ html_favicon_url = "https://github.com/mingling-rs/mingling/raw/main/docs/res/favicon_small.png"
+)]
+#![deny(missing_docs)]
#![doc = include_str!("lib.md")]
#[cfg(feature = "core")]
@@ -42,6 +47,8 @@ pub mod macros {
/// New Parser provided by the `picker` feature
#[cfg(feature = "picker")]
pub use arg_picker::macros::*;
+ /// `#[buffer]` - Wraps a unit-returning function to produce a `RenderResult`.
+ pub use mingling_macros::buffer;
/// `#[chain]` - Used to generate a struct implementing the `Chain` trait via a method
pub use mingling_macros::chain;
/// `#[completion(EntryType)]` - Used to generate completion entry
@@ -68,6 +75,9 @@ pub mod macros {
pub use mingling_macros::group_structural;
/// `#[help]` - Used to generate a struct implementing the `HelpRequest` trait via a method
pub use mingling_macros::help;
+ /// `#[mlint(...)]` - Marker attribute for the Mingling lint system.
+ /// Content is ignored by rustc and reserved for mlint tooling.
+ pub use mingling_macros::mlint;
/// `node!("remote.rm")` - Used to create a `Node` struct via a literal
pub use mingling_macros::node;
/// `pack!(StateGreet = String)` - Used to create a wrapper type for use with `Chain` and `Renderer`
@@ -91,6 +101,21 @@ pub mod macros {
/// `#[program_setup]` - Used to generate program setup
#[cfg(feature = "extra_macros")]
pub use mingling_macros::program_setup;
+ /// `r_append!` - Appends the contents of one `RenderResult` to another.
+ /// See the macro documentation for implicit vs. explicit buffer usage.
+ pub use mingling_macros::r_append;
+ /// `r_eprint!` - Prints text to a `RenderResult` error buffer (without newline).
+ /// See the macro documentation for implicit vs. explicit buffer usage.
+ pub use mingling_macros::r_eprint;
+ /// `r_eprintln!` - Prints text to a `RenderResult` error buffer (with newline).
+ /// See the macro documentation for implicit vs. explicit buffer usage.
+ pub use mingling_macros::r_eprintln;
+ /// `r_print!` - Prints text to a `RenderResult` buffer (without newline).
+ /// See the macro documentation for implicit vs. explicit buffer usage.
+ pub use mingling_macros::r_print;
+ /// `r_println!` - Prints text to a `RenderResult` buffer (with newline).
+ /// See the macro documentation for implicit vs. explicit buffer usage.
+ pub use mingling_macros::r_println;
#[doc(hidden)]
pub use mingling_macros::register_chain;
#[doc(hidden)]
@@ -101,11 +126,24 @@ pub mod macros {
pub use mingling_macros::register_renderer;
#[doc(hidden)]
pub use mingling_macros::register_type;
+ /// `render_route! { /* ... */ }` - Routes errors to the rendering pipeline.
+ /// Similar to `route!`, but used in `#[renderer]` and `#[help]` functions
+ /// where the return type is `RenderResult` instead of `ChainProcess`.
+ #[cfg(feature = "extra_macros")]
+ pub use mingling_macros::render_route;
/// `#[renderer]` - Used to generate a struct implementing the `Renderer` trait via a method
pub use mingling_macros::renderer;
+ /// `#[renderify]` - An extension attribute macro that transforms `expr?` into `render_route!(expr)`.
+ /// Can be used standalone or as a renderer/help extension: `#[renderer(renderify, ...)]`, `#[help(renderify, ...)]`.
+ #[cfg(feature = "extra_macros")]
+ pub use mingling_macros::renderify;
/// `route! { /* ... */ }` - Used to generate a route that either returns a successful result or early returns an error.
#[cfg(feature = "extra_macros")]
pub use mingling_macros::route;
+ /// `#[routeify]` - An extension attribute macro that transforms `expr?` into `route!(expr)`.
+ /// Can be used standalone or as a chain/renderer extension: `#[chain(routeify, ...)]`.
+ #[cfg(feature = "extra_macros")]
+ pub use mingling_macros::routeify;
/// `suggest! { "hello", "bye" }` - Used to generate suggestions
#[cfg(feature = "comp")]
pub use mingling_macros::suggest;
@@ -127,8 +165,9 @@ pub use mingling_macros::Grouped;
pub use mingling_macros::StructuralData;
/// Example projects for `Mingling`, for learning how to use `Mingling`
-#[cfg(feature = "core")]
-pub mod _mingling_examples {
+#[cfg(all(feature = "core", feature = "docs_rs"))]
+#[allow(nonstandard_style)]
+pub mod EXAMPLES {
pub use crate::example_docs::*;
}
@@ -171,12 +210,15 @@ pub mod res;
/// use mingling::prelude::*;
/// ```
pub mod prelude {
- /// Re-export of the `Grouped` derive macro for grouping types.
+ /// Re-export of the `Grouped` trait
#[cfg(feature = "core")]
pub use crate::Grouped;
/// Re-export of the `RenderResult` struct for outputting rendering result
#[cfg(feature = "core")]
pub use crate::RenderResult;
+ /// Re-export of the `Routable` trait
+ #[cfg(feature = "core")]
+ pub use crate::Routable;
/// Re-export of the `chain` macro for defining a chain of commands.
#[cfg(feature = "macros")]
pub use crate::macros::chain;
@@ -208,6 +250,21 @@ pub mod prelude {
/// Like `pack!` but also marks the type for structured output
#[cfg(all(feature = "macros", feature = "structural_renderer"))]
pub use mingling_macros::pack_structural;
+ /// `r_append!` - Appends the contents of one `RenderResult` to another.
+ /// See the macro documentation for implicit vs. explicit buffer usage.
+ pub use mingling_macros::r_append;
+ /// `r_eprint!` - Prints text to a `RenderResult` error buffer (without newline).
+ /// See the macro documentation for implicit vs. explicit buffer usage.
+ pub use mingling_macros::r_eprint;
+ /// `r_eprintln!` - Prints text to a `RenderResult` error buffer (with newline).
+ /// See the macro documentation for implicit vs. explicit buffer usage.
+ pub use mingling_macros::r_eprintln;
+ /// `r_print!` - Prints text to a `RenderResult` buffer (without newline).
+ /// See the macro documentation for implicit vs. explicit buffer usage.
+ pub use mingling_macros::r_print;
+ /// `r_println!` - Prints text to a `RenderResult` buffer (with newline).
+ /// See the macro documentation for implicit vs. explicit buffer usage.
+ pub use mingling_macros::r_println;
/// Re-export of the `completion` macro for generating completion entries.
#[cfg(all(feature = "macros", feature = "comp"))]
@@ -222,8 +279,4 @@ pub mod prelude {
#[cfg(feature = "picker")]
pub use crate::picker::EntryPicker;
-
- /// Used to enable the `writeln!` macro for `RenderResult`
- #[cfg(feature = "core")]
- pub use std::io::Write;
}
diff --git a/mingling/src/picker/entry_picker.rs b/mingling/src/picker/entry_picker.rs
index 7364c50..d9fb37c 100644
--- a/mingling/src/picker/entry_picker.rs
+++ b/mingling/src/picker/entry_picker.rs
@@ -35,7 +35,7 @@ pub trait EntryPicker<'a, This> {
) -> PickerPattern1<'a, Next, ChainProcess<This>>
where
Self: Sized,
- Next: Pickable<'a> + Default + Sized,
+ Next: Pickable<'a> + Sized,
{
let picker = Self::to_picker(self);
Picker::build_pattern1(picker.into_args(), arg.into(), None)
@@ -60,7 +60,7 @@ pub trait EntryPicker<'a, This> {
) -> PickerPattern1<'a, Next, ChainProcess<This>>
where
Self: Sized,
- Next: Pickable<'a> + Default + Sized,
+ Next: Pickable<'a> + Sized,
F: FnMut() -> Next + 'static,
{
self.pick(arg).or(func)
@@ -107,7 +107,7 @@ pub trait EntryPicker<'a, This> {
) -> PickerPattern1<'a, Next, ChainProcess<This>>
where
Self: Sized,
- Next: Pickable<'a> + Default + Sized,
+ Next: Pickable<'a> + Sized,
F: FnMut() -> ChainProcess<This> + 'static,
{
self.pick(arg).or_route(func)
diff --git a/mingling/src/setups/repl_basic.rs b/mingling/src/setups/repl_basic.rs
index 71a38d2..150048b 100644
--- a/mingling/src/setups/repl_basic.rs
+++ b/mingling/src/setups/repl_basic.rs
@@ -19,7 +19,9 @@ where
/// meaning only the last configured instance will take effect globally.
/// Do not configure multiple prompts with different values — only one will be used.
pub enum BasicREPLPromptSetup {
+ /// A static prompt string that is displayed before each REPL input.
Prompt(String),
+ /// A function that returns a dynamic prompt string each time the REPL reads input.
Func(fn() -> String),
}
@@ -73,7 +75,7 @@ where
fn setup(self, program: &mut Program<C>) {
program.with_hook(ProgramHook::empty().on_repl_receive_result(|r| {
if !r.result.is_empty() {
- println!("{}", r.result.trim())
+ println!("{}", r.result)
}
}));
}