macros: Use a nicer syntax when declaring attributes.

The previous version had a => required|optional|default token, this was
duplicating information for Option types and didn’t look very good.

This new version looks like a type, which can be either Required<_>,
Option<_> or Default<_>, and means the same thing.
This commit is contained in:
Emmanuel Gil Peyrot 2019-02-24 20:26:40 +01:00
commit bcd42a26e3
27 changed files with 162 additions and 137 deletions

View file

@ -17,7 +17,7 @@ generate_element!(
/// accepted too.
///
/// [1]: https://www.iana.org/assignments/media-types/media-types.xhtml
type_: String = "type" => required
type_: Required<String> = "type"
],
text: (
/// The actual URI contained.
@ -31,10 +31,10 @@ generate_element!(
MediaElement, "media", MEDIA_ELEMENT,
attributes: [
/// The recommended display width in pixels.
width: Option<usize> = "width" => optional,
width: Option<usize> = "width",
/// The recommended display height in pixels.
height: Option<usize> = "height" => optional
height: Option<usize> = "height"
],
children: [
/// A list of URIs referencing this media.