Skip to content

module_renderer Rust

Module page rendering for Python and Rust documentation

This module provides rendering functionality for converting PythonModule and RustModule structures into Markdown documentation files.

Structs

struct RenderedPage

pub

Derives: Debug, Clone

Rendered output for a documentation file

Fields

Name Type Description
path PathBuf Relative path for output (e.g., "my_module.md" or "rust/my_crate.md")
content String The rendered Markdown content

struct ModulePageBuilder

private

Builder for constructing module documentation pages.

This provides a common structure for both Python and Rust module pages, reducing code duplication between render_python_module_inline and render_rust_module_inline.

Fields

Name Type Description
content String

Methods

new private
fn new () -> Self

Create a new page builder

Source
    fn new() -> Self {
        Self {
            content: String::new(),
        }
    }
add_header private
fn add_header (& mut self , module_name : & str , badge : & str)

Add the module header with a badge

Source
    fn add_header(&mut self, module_name: &str, badge: &str) {
        self.content.push_str(&format!("# {} {}\n\n", module_name, badge));
    }
add_docstring private
fn add_docstring (& mut self , docstring : & crate :: model :: ParsedDocstring)

Add a parsed docstring section

Source
    fn add_docstring(&mut self, docstring: &crate::model::ParsedDocstring) {
        self.content.push_str(&render_docstring(docstring));
        self.content.push_str("\n\n");
    }
add_section private
fn add_section (& mut self , title : & str)

Add a section header (h2)

Source
    fn add_section(&mut self, title: &str) {
        self.content.push_str(&format!("## {}\n\n", title));
    }
add_item private
fn add_item (& mut self , item_content : & str)

Add rendered item content with spacing

Source
    fn add_item(&mut self, item_content: &str) {
        self.content.push_str(item_content);
        self.content.push_str("\n\n");
    }
add_variables_table private
fn add_variables_table < T , F > (& mut self , title : & str , items : & [T] , row_renderer : F) where F : Fn (& T) -> (String , String , String) ,

Add a variables/constants table

Source
    fn add_variables_table<T, F>(&mut self, title: &str, items: &[T], row_renderer: F)
    where
        F: Fn(&T) -> (String, String, String), // (name, type, desc)
    {
        if items.is_empty() {
            return;
        }
        self.content.push_str(&format!("## {}\n\n", title));
        self.content.push_str("| Name | Type | Description |\n");
        self.content.push_str("|------|------|-------------|\n");
        for item in items {
            let (name, ty, desc) = row_renderer(item);
            self.content.push_str(&format!("| `{}` | `{}` | {} |\n", name, ty, desc));
        }
        self.content.push('\n');
    }
build private
fn build (self) -> String

Build the final content

Source
    fn build(self) -> String {
        self.content
    }

struct ModuleRenderer<'a>

pub

Module page renderer that converts DocModel modules into Markdown files.

Fields

Name Type Description
renderer & 'a Renderer
linker CrossRefLinker