Skip to content

Commit

Permalink
Add basic documentation support for structs
Browse files Browse the repository at this point in the history
  • Loading branch information
AS1100K committed Jan 25, 2025
1 parent fd97cc9 commit 546d880
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/_examples/struct_examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub struct UnitStruct;

pub struct TupleStruct(i32, u64);

/// This is a very basic struct
pub struct Basic {
pub type_: String,
pub r#type: String,
Expand Down
8 changes: 8 additions & 0 deletions src/generators/struct_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ impl Generator for StructGenerator {
impls,
}) = &item.inner
{
let mut docs = match &item.docs {
Some(docs) => docs.clone(),
None => String::new(),
};
let mut fields_section = String::new();
let mut syntax = String::from("```rust\n");
syntax.push_str(&VisibilityGenerator::generate_visibility(&item.visibility));
Expand Down Expand Up @@ -129,6 +133,10 @@ impl Generator for StructGenerator {
title: String::new(),
content: syntax,
},
InnerModuleContent {
title: String::new(),
content: docs,
},
InnerModuleContent {
title: String::from("Fields"),
content: fields_section,
Expand Down

0 comments on commit 546d880

Please sign in to comment.