html_export 0.1.1

Basic struct & enums to html file conversion crate
Documentation
  • Coverage
  • 58.91%
    506 out of 859 items documented0 out of 410 items with examples
  • Size
  • Source code size: 236.04 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 24.82 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 19s Average build duration of successful builds.
  • all releases: 18s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Hodson-Thomas/Rust-Html-Export
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Hodson-Thomas

Export rust structures, enums and data structures to html

A simple rust crate to convert structure, enums, data structures into html files.

This crate is designed to:

  1. Be as simple as possible.
  2. Simplify html generation
  3. Export structure, enums and data structures to html.

This crate is not designed to:

  1. Be implemented in frameworks
  2. Be implemented in web applications
use html_export::{
    element::{Element, HtmlElement, HtmlElementConfig},
    html::ToHtml,
    tags::TagType,
};

pub struct Person {
    pub name: String,
    pub age: u8,
}

impl ToHtml for Person {
    fn to_html(&self) -> Element {
        let mut div = Element::Element(HtmlElement::new(
            TagType::Div,
            HtmlElementConfig::new_empty(),
        ));
        div += Element::Element(HtmlElement::new(TagType::P, HtmlElementConfig::new_empty()))
            + Element::Text(format!("{} is {} years old.", self.name.clone(), self.age));
        div
    }
}

fn main() {
    let person = Person {
        name: "Thomas Hodson".to_string(),
        age: 22,
    };
    let html = person.to_html();
}

Please check out the Wiki.