Skip to content

Commit ac8cb48

Browse files
committed
README.md
1 parent 3258f9c commit ac8cb48

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
11
# attribute-derive
22

3-
You will be able to find the documentation on docs.rs.
3+
![docs.rs](https://img.shields.io/docsrs/attribute-derive)
4+
![crates.io](https://img.shields.io/crates/v/attribute-derive)
5+
![MIT](https://img.shields.io/crates/v/attribute-derive)
6+
7+
Basicly clap for attribute macros:
8+
```rust
9+
#[derive(Attribute)]
10+
#[attribute(ident = "collection")]
11+
#[attribute(invalid_field = "Error when an unsupported value is set (e.g. meaning=42")]
12+
struct CollectionAttribute {
13+
// Options are optional by default (will be set to None if not specified)
14+
authority: Option<String>,
15+
#[attribute(missing = "Error when the value is not set")]
16+
name: String,
17+
// Any type implementing default can be flagged as default
18+
// This will be set to Vec::default() when not specified
19+
#[attribute(default)]
20+
#[attribute(expected = "Error when an error occured while parsing")]
21+
views: Vec<Type>,
22+
// Booleans can be used without assiging a value. as a flag.
23+
// If omitted they are set to false
24+
some_flag
25+
}
26+
```
27+
28+
Will be able to parse an attribute like this:
29+
```rust
30+
#[collection(authority="Some String", name = r#"Another string"#, views = [Option, ()])]
31+
```
32+
33+
## Limitations
34+
35+
There are some limitations in syntax parsing that will be lifted future releases.
36+
37+
- literals in top level (meaning something like `#[attr(42, 3.14, "hi")]`
38+
- function like arguments (something like `#[attr(view(a = "test"))]`
39+
- other syntaxes, maybe something like `key: value`

0 commit comments

Comments
 (0)