gsh/evaluator/docs
The docs module powers the shell’s built-in documentation engine.
It dynamically locates, reads, and lexes Gleam source files on demand to extract
module-level (////) and function-level (///) docstrings. It then renders
these raw strings into formatted, ANSI-colored terminal output for quick reference.
Values
pub fn get_function_help(
module_path: String,
func_name: String,
) -> String
Extracts and formats documentation and type signatures for a specific function
(e.g., h simplifile.append).
Extraction Logic:
- Lexes the target module and scans sequentially for the target function name.
- Captures the preceding block of
CommentDoc(///) strings. - Captures the exact function signature tokens up to the opening curly brace.
- Renders the signature in green, followed by the formatted Markdown description.
pub fn get_module_help(module_path: String) -> String
Extracts and formats the top-level module documentation (e.g., h simplifile).
Extraction Logic:
- Locates the module’s
.gleamsource file on disk. - Lexes the raw source and filters out all tokens except
CommentModule(////). - Renders a centered, bolded title followed by the parsed Markdown description.