Skip to content

Commit

Permalink
Changed the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorlott committed Jan 16, 2023
1 parent 6efa27d commit 38da8df
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 35 deletions.
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,10 @@
# rust-typed

`Typed` is a procedural macro that is used for disassembling `structs`, `enums` and `fns` into their inner `type` components that are then accompanied with documentation and examples. The `Typed` structures will be wrapped into a module and reassigned with a name (default `core`), this also goes for the `static` and `generic` fields.
`Typed` is a procedural macro that is used for disassembling `structs` and `fns` into their inner `type` components that are then accompanied with documentation and examples. The `Typed` structures will be wrapped into a module and reassigned with a name (default `core`), this also goes for the `static` and `generic` fields.


#### *Project is still under development*

# Disassembler
```rust
#[type_it]
struct #name {
#(#ident: #ty)*
}

// Turns into

#[allow(non_snake_case)]
// Docs (/w examples) describing the original `item` and also what `types` are available to use.
#[doc = #docs]
pub mod #name {
#![allow(non_camel_case_types)]

// The static fields of the `item` as type aliases.
#(#ty_decls)* // Access through `#name::#field`

// A trait where all `ìtem` fields are associated types
#struct_generic // Access through `#name::gen`

// Docs (/w examples) describing the original `item`.
#[doc = #docs]
// The original `ìtem`.
#struct_original // Access through `#name::core`
}
```


# Struct example
```rust
#[type_it]
Expand Down Expand Up @@ -64,6 +36,34 @@ trait Trait: Container::protocol {
}
```

# Disassembler
```rust
#[type_it]
struct #name {
#(#ident: #ty)*
}

// Turns into

#[allow(non_snake_case)]
// Docs (/w examples) describing the original `item` and also what `types` are available to use.
#[doc = #docs]
pub mod #name {
#![allow(non_camel_case_types)]

// The static fields of the `item` as type aliases.
#(#ty_decls)* // Access through `#name::#field`

// A trait where all `ìtem` fields are associated types
#struct_generic // Access through `#name::gen`

// Docs (/w examples) describing the original `item`.
#[doc = #docs]
// The original `ìtem`.
#struct_original // Access through `#name::core`
}
```

# Future plans
#### Renaming disassembler
```rust
Expand Down
7 changes: 2 additions & 5 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,7 @@ impl TypeAlias {
pub fn new<'a>(source_code: &'a str, ident: &'a Ident, ty: &'a Type, generics: Option<Generics>) -> Self {
let type_doc = doc_type(ident, ty, &generics, source_code);

new!({
clone[ident, ty, generics],
docs(parse_quote!(#[doc = #type_doc])),
} => Self)
new!({ clone[ident, ty, generics], docs(parse_quote!(#[doc = #type_doc])) } => Self)
}
}

Expand All @@ -271,7 +268,7 @@ where
Ok(Fields::Unit)
}
}

// FIXME: Refactor this please
fn parse_type_decls(fields: &mut Fields, generics: &Generics, source: &Source) -> Vec<TypeAlias> {
let mut type_decls: Vec<TypeAlias> = Vec::new();

Expand Down

0 comments on commit 38da8df

Please sign in to comment.