Enhance tool documentation and add new features
- Added module-level documentation for memory tools (`remember`, `recall`, `forget`) to clarify their purpose. - Improved documentation in `recall.rs` and `remember.rs` to describe the functionality and flow of memory entry operations. - Updated `mod.rs` to include descriptions for the tool trait and execution context. - Enhanced `plan.rs` with detailed comments on plan-mode signaling tools. - Documented text search tools in `search.rs` to explain their functionality. - Improved sequential-thinking tool documentation in `seqthink.rs`. - Added safety filter documentation in `shell_filter` for credential and git operations. - Enhanced utility tools documentation, including `cd`, `dir_cache_update`, and `todowrite`. - Improved rendering documentation in view modules (`chat`, `markdown`, `status`, `workflow`) to clarify rendering flows and purposes.
This commit is contained in:
@@ -1,6 +1,30 @@
|
||||
//! Markdown-to-styled-spans rendering for the chat transcript.
|
||||
//!
|
||||
//! Flow: `render_markdown` walks a `pulldown_cmark` event stream and
|
||||
//! translates each markdown construct (headings, code blocks, links,
|
||||
//! emphasis, block quotes, lists) into styled `ratatui::text::Span`s,
|
||||
//! then optionally re-wraps the flat span list to a target column width.
|
||||
//!
|
||||
//! Why: ratatui has no built-in markdown renderer, so this module bridges
|
||||
//! `pulldown_cmark`'s event-based parser to ratatui's span/line model.
|
||||
|
||||
use ratatui::style::{Color, Modifier, Style};
|
||||
use ratatui::text::Span;
|
||||
|
||||
/// Render a markdown string into styled terminal spans, word-wrapped to `width`.
|
||||
///
|
||||
/// Flow: pulldown_cmark parses `text` into an event stream → each
|
||||
/// Start/End/Text/Code/Break event is translated into styled `Span`s
|
||||
/// (headings colored by level, code blocks green, links bracketed, etc.)
|
||||
/// → if `width > 0`, a second pass inserts manual newline spans whenever
|
||||
/// the running line length would exceed `width`.
|
||||
///
|
||||
/// Why: ratatui has no native markdown renderer, and the built-in `Wrap`
|
||||
/// widget wraps on grapheme count without honoring markdown structure,
|
||||
/// so wrapping is done manually here in terms of raw span byte length.
|
||||
///
|
||||
/// Return: a flat vec of styled spans; `chat::split_spans_into_lines`
|
||||
/// turns it back into `Line`s for the Paragraph widget.
|
||||
pub fn render_markdown(text: &str, width: u16) -> Vec<Span<'static>> {
|
||||
let mut spans = Vec::new();
|
||||
let parser = pulldown_cmark::Parser::new(text);
|
||||
|
||||
Reference in New Issue
Block a user