diff --git a/crates/stef-doc/src/lib.rs b/crates/stef-doc/src/lib.rs index 4ba4d74..141b0dd 100644 --- a/crates/stef-doc/src/lib.rs +++ b/crates/stef-doc/src/lib.rs @@ -38,7 +38,10 @@ pub struct Output<'a> { pub fn render_schema<'a>( _opts: &'a Opts, Schema { - path, definitions, .. + path, + comment, + definitions, + .. }: &'a Schema<'_>, ) -> Result> { let name = path @@ -52,6 +55,7 @@ pub fn render_schema<'a>( content: templates::Index { name, path: &path, + comment, definitions, } .render()?, diff --git a/crates/stef-doc/src/templates.rs b/crates/stef-doc/src/templates.rs index 57650d1..938fcd0 100644 --- a/crates/stef-doc/src/templates.rs +++ b/crates/stef-doc/src/templates.rs @@ -12,6 +12,7 @@ use stef_parser::{Comment, Const, Definition, Enum, Fields, Module, Struct, Type pub struct Index<'a> { pub name: &'a str, pub path: &'a [Rc], + pub comment: &'a Comment<'a>, pub definitions: &'a [Definition<'a>], } diff --git a/crates/stef-doc/templates/index.html b/crates/stef-doc/templates/index.html index c708930..f7bb90f 100644 --- a/crates/stef-doc/templates/index.html +++ b/crates/stef-doc/templates/index.html @@ -5,6 +5,9 @@ {% block content %}

Schema {{ name }}

+
+ {{ self::merge_comments(comment)|markdown|trim|safe }} +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@alias_basic.stef.snap b/crates/stef-doc/tests/snapshots/render__render@alias_basic.stef.snap index 816fc77..1c7ee91 100644 --- a/crates/stef-doc/tests/snapshots/render__render@alias_basic.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@alias_basic.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/alias_basic.stef

Schema alias_basic

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@attribute_multi.stef.snap b/crates/stef-doc/tests/snapshots/render__render@attribute_multi.stef.snap index 6f2f302..02b3e2d 100644 --- a/crates/stef-doc/tests/snapshots/render__render@attribute_multi.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@attribute_multi.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/attribute_multi.stef

Schema attribute_multi

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@attribute_single.stef.snap b/crates/stef-doc/tests/snapshots/render__render@attribute_single.stef.snap index 85e6bb1..66e12d5 100644 --- a/crates/stef-doc/tests/snapshots/render__render@attribute_single.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@attribute_single.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/attribute_single.stef

Schema attribute_single

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@attribute_unit.stef.snap b/crates/stef-doc/tests/snapshots/render__render@attribute_unit.stef.snap index 37d6a37..de58c62 100644 --- a/crates/stef-doc/tests/snapshots/render__render@attribute_unit.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@attribute_unit.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/attribute_unit.stef

Schema attribute_unit

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@attributes.stef.snap b/crates/stef-doc/tests/snapshots/render__render@attributes.stef.snap index 9579e5c..bae05e8 100644 --- a/crates/stef-doc/tests/snapshots/render__render@attributes.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@attributes.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/attributes.stef

Schema attributes

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@attributes_min_ws.stef.snap b/crates/stef-doc/tests/snapshots/render__render@attributes_min_ws.stef.snap index ed227de..fdd603c 100644 --- a/crates/stef-doc/tests/snapshots/render__render@attributes_min_ws.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@attributes_min_ws.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/attributes_min_ws.stef

Schema attributes_min_ws

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@const_basic.stef.snap b/crates/stef-doc/tests/snapshots/render__render@const_basic.stef.snap index ca3b96a..c7adc8d 100644 --- a/crates/stef-doc/tests/snapshots/render__render@const_basic.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@const_basic.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/const_basic.stef

Schema const_basic

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@const_string.stef.snap b/crates/stef-doc/tests/snapshots/render__render@const_string.stef.snap index 3262316..11bded5 100644 --- a/crates/stef-doc/tests/snapshots/render__render@const_string.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@const_string.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/const_string.stef

Schema const_string

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@enum_basic.stef.snap b/crates/stef-doc/tests/snapshots/render__render@enum_basic.stef.snap index 36342d2..35dea78 100644 --- a/crates/stef-doc/tests/snapshots/render__render@enum_basic.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@enum_basic.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/enum_basic.stef

Schema enum_basic

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@enum_generics.stef.snap b/crates/stef-doc/tests/snapshots/render__render@enum_generics.stef.snap index 1b66dc3..3d8c870 100644 --- a/crates/stef-doc/tests/snapshots/render__render@enum_generics.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@enum_generics.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/enum_generics.stef

Schema enum_generics

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@enum_many_ws.stef.snap b/crates/stef-doc/tests/snapshots/render__render@enum_many_ws.stef.snap index eccd595..2e01290 100644 --- a/crates/stef-doc/tests/snapshots/render__render@enum_many_ws.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@enum_many_ws.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/enum_many_ws.stef

Schema enum_many_ws

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@enum_min_ws.stef.snap b/crates/stef-doc/tests/snapshots/render__render@enum_min_ws.stef.snap index 5ff9888..9511016 100644 --- a/crates/stef-doc/tests/snapshots/render__render@enum_min_ws.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@enum_min_ws.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/enum_min_ws.stef

Schema enum_min_ws

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@import_basic.stef.snap b/crates/stef-doc/tests/snapshots/render__render@import_basic.stef.snap index 1342ced..c0ade79 100644 --- a/crates/stef-doc/tests/snapshots/render__render@import_basic.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@import_basic.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/import_basic.stef

Schema import_basic

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@mixed.stef.snap b/crates/stef-doc/tests/snapshots/render__render@mixed.stef.snap index e8a8329..57ab99c 100644 --- a/crates/stef-doc/tests/snapshots/render__render@mixed.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@mixed.stef.snap @@ -1,6 +1,6 @@ --- source: crates/stef-doc/tests/render.rs -description: "/// Basic user information.\n///\n/// Uses various other `structs` and `enums` to compose the information\n/// in a **type safe** way.\nstruct User {\n name: FullName @1,\n /// Physical address, might not be specified by the user.\n address: option
@2,\n age: u8 @3,\n birthday: birthday::DayOfBirth @4,\n}\n\n/// Full name of a user.\nstruct FullName {\n first: string @1,\n middle: option @2,\n last: string @3,\n}\n\n/// Simple alias for convenience.\n///\n/// - Might be easier to remember.\n/// - Often referenced as this.\ntype Name = FullName;\n\nstruct Address {\n /// Street name.\n street: string @1,\n /// Number of the house in the street.\n house_no: HouseNumber @2,\n city: string @3,\n}\n\n/// The number on the house.\n///\n/// More details can be found at [Wikipedia](https://en.wikipedia.org/wiki/House_numbering).\nenum HouseNumber {\n /// Digit only number.\n Digit(u16 @1) @1,\n /// Mixed _number_ with characters like `1a`.\n Text(string @1) @2,\n}\n\n/// Probably the max age of a human, currently.\nconst MAX_AGE: u8 = 120;\n\n\n/// Details for defining birthdays.\nmod birthday {\n /// As the name suggests, specifies details about birthdays.\n enum DayOfBirth {\n Specific {\n year: u16 @1,\n month: Month @2,\n day: u8 @3,\n } @1,\n /// The user didn't want to say.\n Secret {\n /// Optional info from the user about why they didn't want to\n /// reveal their birthday.\n reason: option @1,\n } @2,\n /// We never asked and nobody knows.\n Unknown @3,\n }\n\n /// Let's assume we only have details of people born **after** this year.\n const MIN_YEAR: u16 = 1900;\n\n /// Absolute maximum for a day, but might be even less depending\n /// on the month.\n const MAX_DAY: u8 = 31;\n\n /// The month of the year.\n enum Month {\n January @1,\n February @2,\n March @3,\n April @4,\n May @5,\n June @6,\n July @7,\n August @8,\n September @9,\n October @10,\n November @11,\n December @12,\n }\n}" +description: "/// Schema with a bit of everything, to try out more complex scenarios.\n\n/// Basic user information.\n///\n/// Uses various other `structs` and `enums` to compose the information\n/// in a **type safe** way.\nstruct User {\n name: FullName @1,\n /// Physical address, might not be specified by the user.\n address: option
@2,\n age: u8 @3,\n birthday: birthday::DayOfBirth @4,\n}\n\n/// Full name of a user.\nstruct FullName {\n first: string @1,\n middle: option @2,\n last: string @3,\n}\n\n/// Simple alias for convenience.\n///\n/// - Might be easier to remember.\n/// - Often referenced as this.\ntype Name = FullName;\n\nstruct Address {\n /// Street name.\n street: string @1,\n /// Number of the house in the street.\n house_no: HouseNumber @2,\n city: string @3,\n}\n\n/// The number on the house.\n///\n/// More details can be found at [Wikipedia](https://en.wikipedia.org/wiki/House_numbering).\nenum HouseNumber {\n /// Digit only number.\n Digit(u16 @1) @1,\n /// Mixed _number_ with characters like `1a`.\n Text(string @1) @2,\n}\n\n/// Probably the max age of a human, currently.\nconst MAX_AGE: u8 = 120;\n\n\n/// Details for defining birthdays.\nmod birthday {\n /// As the name suggests, specifies details about birthdays.\n enum DayOfBirth {\n Specific {\n year: u16 @1,\n month: Month @2,\n day: u8 @3,\n } @1,\n /// The user didn't want to say.\n Secret {\n /// Optional info from the user about why they didn't want to\n /// reveal their birthday.\n reason: option @1,\n } @2,\n /// We never asked and nobody knows.\n Unknown @3,\n }\n\n /// Let's assume we only have details of people born **after** this year.\n const MIN_YEAR: u16 = 1900;\n\n /// Absolute maximum for a day, but might be even less depending\n /// on the month.\n const MAX_DAY: u8 = 31;\n\n /// The month of the year.\n enum Month {\n January @1,\n February @2,\n March @3,\n April @4,\n May @5,\n June @6,\n July @7,\n August @8,\n September @9,\n October @10,\n November @11,\n December @12,\n }\n}" input_file: crates/stef-parser/tests/inputs/mixed.stef --- --- mixed/index.html @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/mixed.stef

Schema mixed

+
+

Schema with a bit of everything, to try out more complex scenarios.

+

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@module_basic.stef.snap b/crates/stef-doc/tests/snapshots/render__render@module_basic.stef.snap index 253627a..d7f82fe 100644 --- a/crates/stef-doc/tests/snapshots/render__render@module_basic.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@module_basic.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/module_basic.stef

Schema module_basic

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@schema_basic.stef.snap b/crates/stef-doc/tests/snapshots/render__render@schema_basic.stef.snap index 232b4df..fa70646 100644 --- a/crates/stef-doc/tests/snapshots/render__render@schema_basic.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@schema_basic.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/schema_basic.stef

Schema schema_basic

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@struct_basic.stef.snap b/crates/stef-doc/tests/snapshots/render__render@struct_basic.stef.snap index 6ac5fd2..5e29b00 100644 --- a/crates/stef-doc/tests/snapshots/render__render@struct_basic.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@struct_basic.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/struct_basic.stef

Schema struct_basic

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@struct_generics.stef.snap b/crates/stef-doc/tests/snapshots/render__render@struct_generics.stef.snap index 4b3a1b7..42a9d1a 100644 --- a/crates/stef-doc/tests/snapshots/render__render@struct_generics.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@struct_generics.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/struct_generics.stef

Schema struct_generics

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@struct_many_ws.stef.snap b/crates/stef-doc/tests/snapshots/render__render@struct_many_ws.stef.snap index 644180a..da58ead 100644 --- a/crates/stef-doc/tests/snapshots/render__render@struct_many_ws.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@struct_many_ws.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/struct_many_ws.stef

Schema struct_many_ws

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@struct_min_ws.stef.snap b/crates/stef-doc/tests/snapshots/render__render@struct_min_ws.stef.snap index e53af85..fc95c36 100644 --- a/crates/stef-doc/tests/snapshots/render__render@struct_min_ws.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@struct_min_ws.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/struct_min_ws.stef

Schema struct_min_ws

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@struct_tuple.stef.snap b/crates/stef-doc/tests/snapshots/render__render@struct_tuple.stef.snap index 23954d1..7a6fb58 100644 --- a/crates/stef-doc/tests/snapshots/render__render@struct_tuple.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@struct_tuple.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/struct_tuple.stef

Schema struct_tuple

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@types_basic.stef.snap b/crates/stef-doc/tests/snapshots/render__render@types_basic.stef.snap index 6cfac0e..f2ba73d 100644 --- a/crates/stef-doc/tests/snapshots/render__render@types_basic.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@types_basic.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/types_basic.stef

Schema types_basic

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@types_generic.stef.snap b/crates/stef-doc/tests/snapshots/render__render@types_generic.stef.snap index c5a35c3..1d1c91d 100644 --- a/crates/stef-doc/tests/snapshots/render__render@types_generic.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@types_generic.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/types_generic.stef

Schema types_generic

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@types_nested.stef.snap b/crates/stef-doc/tests/snapshots/render__render@types_nested.stef.snap index e318034..e84c850 100644 --- a/crates/stef-doc/tests/snapshots/render__render@types_nested.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@types_nested.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/types_nested.stef

Schema types_nested

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@types_non_zero.stef.snap b/crates/stef-doc/tests/snapshots/render__render@types_non_zero.stef.snap index c1a9286..a7c7b72 100644 --- a/crates/stef-doc/tests/snapshots/render__render@types_non_zero.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@types_non_zero.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/types_non_zero.stef

Schema types_non_zero

+
+ +

Modules

diff --git a/crates/stef-doc/tests/snapshots/render__render@types_ref.stef.snap b/crates/stef-doc/tests/snapshots/render__render@types_ref.stef.snap index 60401bb..f1be410 100644 --- a/crates/stef-doc/tests/snapshots/render__render@types_ref.stef.snap +++ b/crates/stef-doc/tests/snapshots/render__render@types_ref.stef.snap @@ -22,6 +22,9 @@ input_file: crates/stef-parser/tests/inputs/types_ref.stef

Schema types_ref

+
+ +

Modules

diff --git a/crates/stef-lsp/src/handlers/compile.rs b/crates/stef-lsp/src/handlers/compile.rs index 0a1ea29..033a3cc 100644 --- a/crates/stef-lsp/src/handlers/compile.rs +++ b/crates/stef-lsp/src/handlers/compile.rs @@ -32,6 +32,7 @@ fn parse_schema_diagnostic(index: &LineIndex, e: &ParseSchemaError) -> Diagnosti ParseSchemaCause::Parser(_, at) => { Diagnostic::new_simple(get_range(index, *at..*at), e.to_string()) } + ParseSchemaCause::Comment(e) => parse_comment_diagnostic(index, e), ParseSchemaCause::Definition(e) => parse_definition_diagnostic(index, e), } } diff --git a/crates/stef-parser/src/error.rs b/crates/stef-parser/src/error.rs index 15ebf6e..cfc8cf8 100644 --- a/crates/stef-parser/src/error.rs +++ b/crates/stef-parser/src/error.rs @@ -80,6 +80,8 @@ impl Diagnostic for ParseSchemaError { pub enum ParseSchemaCause { Parser(ErrorKind, usize), #[diagnostic(transparent)] + Comment(ParseCommentError), + #[diagnostic(transparent)] Definition(ParseDefinitionError), } @@ -87,6 +89,7 @@ impl Error for ParseSchemaCause { fn source(&self) -> Option<&(dyn Error + 'static)> { match self { Self::Parser(kind, _) => kind.source(), + Self::Comment(inner) => inner.source(), Self::Definition(inner) => inner.source(), } } @@ -96,11 +99,18 @@ impl Display for ParseSchemaCause { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Parser(kind, _) => kind.fmt(f), + Self::Comment(inner) => inner.fmt(f), Self::Definition(inner) => inner.fmt(f), } } } +impl From for ParseSchemaCause { + fn from(value: ParseCommentError) -> Self { + Self::Comment(value) + } +} + impl From for ParseSchemaCause { fn from(value: ParseDefinitionError) -> Self { Self::Definition(value) diff --git a/crates/stef-parser/src/lib.rs b/crates/stef-parser/src/lib.rs index f565173..ef61ae1 100644 --- a/crates/stef-parser/src/lib.rs +++ b/crates/stef-parser/src/lib.rs @@ -112,6 +112,8 @@ pub struct Schema<'a> { pub path: Option, /// Original source code form which this schema was parsed. pub source: &'a str, + /// Optional schema-level comment. + pub comment: Comment<'a>, /// List of all the definitions that make up the schema. pub definitions: Vec>, } @@ -146,6 +148,10 @@ impl<'a> Schema<'a> { impl Display for Schema<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if !self.comment.0.is_empty() { + writeln!(f, "{}", self.comment)?; + } + for definition in &self.definitions { writeln!(f, "{definition}")?; } diff --git a/crates/stef-parser/src/parser.rs b/crates/stef-parser/src/parser.rs index e130fe6..350f2a5 100644 --- a/crates/stef-parser/src/parser.rs +++ b/crates/stef-parser/src/parser.rs @@ -1,6 +1,6 @@ use winnow::{ - ascii::{multispace0, space0}, - combinator::{fail, peek, preceded, repeat, terminated}, + ascii::{multispace0, newline, space0}, + combinator::{fail, opt, peek, preceded, repeat, terminated}, dispatch, error::ParserError, prelude::*, @@ -50,15 +50,19 @@ pub(crate) fn parse_schema<'i>(input: &mut Input<'i>) -> Result, Pars trace( "schema", - terminated( - repeat(0.., parse_definition.map_err(Into::into)), - multispace0, + ( + opt(terminated(ws(comments::parse.map_err(Into::into)), newline)), + terminated( + repeat(0.., parse_definition.map_err(Into::into)), + multispace0, + ), ), ) .parse_next(input) - .map(|definitions| Schema { + .map(|(comment, definitions)| Schema { path: None, source, + comment: comment.unwrap_or_default(), definitions, }) } diff --git a/crates/stef-parser/tests/inputs/mixed.stef b/crates/stef-parser/tests/inputs/mixed.stef index ab20436..2771cc3 100644 --- a/crates/stef-parser/tests/inputs/mixed.stef +++ b/crates/stef-parser/tests/inputs/mixed.stef @@ -1,3 +1,5 @@ +/// Schema with a bit of everything, to try out more complex scenarios. + /// Basic user information. /// /// Uses various other `structs` and `enums` to compose the information diff --git a/crates/stef-parser/tests/snapshots/parser__parse@alias_basic.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@alias_basic.stef.snap index 7b0f37f..576bffc 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@alias_basic.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@alias_basic.stef.snap @@ -8,6 +8,9 @@ Schema { "alias_basic.stef", ), source: "/// Sample type alias.\ntype Sample = u32;\n", + comment: Comment( + [], + ), definitions: [ TypeAlias( TypeAlias { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@attribute_multi.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@attribute_multi.stef.snap index 5fc8f39..f0445d6 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@attribute_multi.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@attribute_multi.stef.snap @@ -8,6 +8,9 @@ Schema { "attribute_multi.stef", ), source: "#[validate(min = 1, max = 100)]\nstruct Sample\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@attribute_single.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@attribute_single.stef.snap index 55b4228..740a7cc 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@attribute_single.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@attribute_single.stef.snap @@ -8,6 +8,9 @@ Schema { "attribute_single.stef", ), source: "#[deprecated = \"don't use\"]\nstruct Sample\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@attribute_unit.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@attribute_unit.stef.snap index 5bf03e6..4ff7391 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@attribute_unit.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@attribute_unit.stef.snap @@ -8,6 +8,9 @@ Schema { "attribute_unit.stef", ), source: "#[deprecated]\nstruct Sample\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@attributes.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@attributes.stef.snap index 43bfe06..15e616f 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@attributes.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@attributes.stef.snap @@ -8,6 +8,9 @@ Schema { "attributes.stef", ), source: "#[deprecated = \"don't use\", compress]\n#[validate(\n in_range(min = 100, max = 200),\n non_empty,\n)]\nstruct Sample\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@attributes_min_ws.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@attributes_min_ws.stef.snap index 2eb197f..98519fd 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@attributes_min_ws.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@attributes_min_ws.stef.snap @@ -8,6 +8,9 @@ Schema { "attributes_min_ws.stef", ), source: "#[deprecated=\"don't use\",compress]\n#[validate(in_range(min=100,max=200),non_empty)]\nstruct Sample\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@const_basic.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@const_basic.stef.snap index 933459f..bc70885 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@const_basic.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@const_basic.stef.snap @@ -8,6 +8,9 @@ Schema { "const_basic.stef", ), source: "const BOOL_TRUE: bool = true;\nconst BOOL_FALSE: bool = false;\nconst INT: u32 = 100;\nconst FLOAT: f64 = 5.5;\nconst STRING: string = \"value\";\nconst BYTES: bytes = [1, 2, 3];\n", + comment: Comment( + [], + ), definitions: [ Const( Const { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@const_string.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@const_string.stef.snap index fb1a598..89492ce 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@const_string.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@const_string.stef.snap @@ -8,6 +8,9 @@ Schema { "const_string.stef", ), source: "const SIMPLE: string = \"value\";\n\nconst NEWLINE_ESCAPE: string = \"one \\\n two \\\n three\\\n\";\n\nconst ESCAPES: string = \"escape basics \\r\\n \\t \\b \\f \\\\ \\\"\\\n hello\\\" \\n\\\n unicode \\u{2764} \\\n emoji ❤ \\\n\";\n\nconst MULTILINE: string = \"a\n b\n c\n\";\n", + comment: Comment( + [], + ), definitions: [ Const( Const { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@enum_basic.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@enum_basic.stef.snap index f4c9c40..2a9671d 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@enum_basic.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@enum_basic.stef.snap @@ -8,6 +8,9 @@ Schema { "enum_basic.stef", ), source: "/// Sample enum.\nenum Sample {\n One @1,\n /// Second variant\n Two(u32 @1, u64 @2) @2,\n Three {\n field1: u32 @1,\n /// Second field of third variant\n field2: bool @2,\n } @3,\n}\n", + comment: Comment( + [], + ), definitions: [ Enum( Enum { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@enum_generics.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@enum_generics.stef.snap index c6daa9d..42d8356 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@enum_generics.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@enum_generics.stef.snap @@ -8,6 +8,9 @@ Schema { "enum_generics.stef", ), source: "/// Enum with generics.\nenum Sample {\n One @1,\n Two(A @1, B @2) @2,\n Three {\n field1: C @1,\n field2: D @2,\n } @3,\n}\n", + comment: Comment( + [], + ), definitions: [ Enum( Enum { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@enum_many_ws.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@enum_many_ws.stef.snap index b03fe4e..829f88f 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@enum_many_ws.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@enum_many_ws.stef.snap @@ -8,6 +8,9 @@ Schema { "enum_many_ws.stef", ), source: "\n /// Sample enum.\n enum Sample {\n\n One @1,\n\n Two ( u32 @1, u64 @2) @2,\n\n Three {\n\n field1: u32 @1,\n\n field2: bool @2,\n\n } @3,\n\n }\n", + comment: Comment( + [], + ), definitions: [ Enum( Enum { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@enum_min_ws.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@enum_min_ws.stef.snap index f937033..6230220 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@enum_min_ws.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@enum_min_ws.stef.snap @@ -8,6 +8,9 @@ Schema { "enum_min_ws.stef", ), source: "enum Sample{One@1,Two(u32@1,u64@2,T@3)@2,Three{field1:u32@1,field2:bool@2,field3:T@3}@3}\n", + comment: Comment( + [], + ), definitions: [ Enum( Enum { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@import_basic.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@import_basic.stef.snap index 989e992..58d05b4 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@import_basic.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@import_basic.stef.snap @@ -8,6 +8,9 @@ Schema { "import_basic.stef", ), source: "use other::schema::Sample;\nuse second::submodule;\n", + comment: Comment( + [], + ), definitions: [ Import( Import { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@mixed.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@mixed.stef.snap index 6457a1b..1d8e24d 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@mixed.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@mixed.stef.snap @@ -1,13 +1,24 @@ --- source: crates/stef-parser/tests/parser.rs -description: "/// Basic user information.\n///\n/// Uses various other `structs` and `enums` to compose the information\n/// in a **type safe** way.\nstruct User {\n name: FullName @1,\n /// Physical address, might not be specified by the user.\n address: option
@2,\n age: u8 @3,\n birthday: birthday::DayOfBirth @4,\n}\n\n/// Full name of a user.\nstruct FullName {\n first: string @1,\n middle: option @2,\n last: string @3,\n}\n\n/// Simple alias for convenience.\n///\n/// - Might be easier to remember.\n/// - Often referenced as this.\ntype Name = FullName;\n\nstruct Address {\n /// Street name.\n street: string @1,\n /// Number of the house in the street.\n house_no: HouseNumber @2,\n city: string @3,\n}\n\n/// The number on the house.\n///\n/// More details can be found at [Wikipedia](https://en.wikipedia.org/wiki/House_numbering).\nenum HouseNumber {\n /// Digit only number.\n Digit(u16 @1) @1,\n /// Mixed _number_ with characters like `1a`.\n Text(string @1) @2,\n}\n\n/// Probably the max age of a human, currently.\nconst MAX_AGE: u8 = 120;\n\n\n/// Details for defining birthdays.\nmod birthday {\n /// As the name suggests, specifies details about birthdays.\n enum DayOfBirth {\n Specific {\n year: u16 @1,\n month: Month @2,\n day: u8 @3,\n } @1,\n /// The user didn't want to say.\n Secret {\n /// Optional info from the user about why they didn't want to\n /// reveal their birthday.\n reason: option @1,\n } @2,\n /// We never asked and nobody knows.\n Unknown @3,\n }\n\n /// Let's assume we only have details of people born **after** this year.\n const MIN_YEAR: u16 = 1900;\n\n /// Absolute maximum for a day, but might be even less depending\n /// on the month.\n const MAX_DAY: u8 = 31;\n\n /// The month of the year.\n enum Month {\n January @1,\n February @2,\n March @3,\n April @4,\n May @5,\n June @6,\n July @7,\n August @8,\n September @9,\n October @10,\n November @11,\n December @12,\n }\n}" +description: "/// Schema with a bit of everything, to try out more complex scenarios.\n\n/// Basic user information.\n///\n/// Uses various other `structs` and `enums` to compose the information\n/// in a **type safe** way.\nstruct User {\n name: FullName @1,\n /// Physical address, might not be specified by the user.\n address: option
@2,\n age: u8 @3,\n birthday: birthday::DayOfBirth @4,\n}\n\n/// Full name of a user.\nstruct FullName {\n first: string @1,\n middle: option @2,\n last: string @3,\n}\n\n/// Simple alias for convenience.\n///\n/// - Might be easier to remember.\n/// - Often referenced as this.\ntype Name = FullName;\n\nstruct Address {\n /// Street name.\n street: string @1,\n /// Number of the house in the street.\n house_no: HouseNumber @2,\n city: string @3,\n}\n\n/// The number on the house.\n///\n/// More details can be found at [Wikipedia](https://en.wikipedia.org/wiki/House_numbering).\nenum HouseNumber {\n /// Digit only number.\n Digit(u16 @1) @1,\n /// Mixed _number_ with characters like `1a`.\n Text(string @1) @2,\n}\n\n/// Probably the max age of a human, currently.\nconst MAX_AGE: u8 = 120;\n\n\n/// Details for defining birthdays.\nmod birthday {\n /// As the name suggests, specifies details about birthdays.\n enum DayOfBirth {\n Specific {\n year: u16 @1,\n month: Month @2,\n day: u8 @3,\n } @1,\n /// The user didn't want to say.\n Secret {\n /// Optional info from the user about why they didn't want to\n /// reveal their birthday.\n reason: option @1,\n } @2,\n /// We never asked and nobody knows.\n Unknown @3,\n }\n\n /// Let's assume we only have details of people born **after** this year.\n const MIN_YEAR: u16 = 1900;\n\n /// Absolute maximum for a day, but might be even less depending\n /// on the month.\n const MAX_DAY: u8 = 31;\n\n /// The month of the year.\n enum Month {\n January @1,\n February @2,\n March @3,\n April @4,\n May @5,\n June @6,\n July @7,\n August @8,\n September @9,\n October @10,\n November @11,\n December @12,\n }\n}" input_file: crates/stef-parser/tests/inputs/mixed.stef --- Schema { path: Some( "mixed.stef", ), - source: "/// Basic user information.\n///\n/// Uses various other `structs` and `enums` to compose the information\n/// in a **type safe** way.\nstruct User {\n name: FullName @1,\n /// Physical address, might not be specified by the user.\n address: option
@2,\n age: u8 @3,\n birthday: birthday::DayOfBirth @4,\n}\n\n/// Full name of a user.\nstruct FullName {\n first: string @1,\n middle: option @2,\n last: string @3,\n}\n\n/// Simple alias for convenience.\n///\n/// - Might be easier to remember.\n/// - Often referenced as this.\ntype Name = FullName;\n\nstruct Address {\n /// Street name.\n street: string @1,\n /// Number of the house in the street.\n house_no: HouseNumber @2,\n city: string @3,\n}\n\n/// The number on the house.\n///\n/// More details can be found at [Wikipedia](https://en.wikipedia.org/wiki/House_numbering).\nenum HouseNumber {\n /// Digit only number.\n Digit(u16 @1) @1,\n /// Mixed _number_ with characters like `1a`.\n Text(string @1) @2,\n}\n\n/// Probably the max age of a human, currently.\nconst MAX_AGE: u8 = 120;\n\n\n/// Details for defining birthdays.\nmod birthday {\n /// As the name suggests, specifies details about birthdays.\n enum DayOfBirth {\n Specific {\n year: u16 @1,\n month: Month @2,\n day: u8 @3,\n } @1,\n /// The user didn't want to say.\n Secret {\n /// Optional info from the user about why they didn't want to\n /// reveal their birthday.\n reason: option @1,\n } @2,\n /// We never asked and nobody knows.\n Unknown @3,\n }\n\n /// Let's assume we only have details of people born **after** this year.\n const MIN_YEAR: u16 = 1900;\n\n /// Absolute maximum for a day, but might be even less depending\n /// on the month.\n const MAX_DAY: u8 = 31;\n\n /// The month of the year.\n enum Month {\n January @1,\n February @2,\n March @3,\n April @4,\n May @5,\n June @6,\n July @7,\n August @8,\n September @9,\n October @10,\n November @11,\n December @12,\n }\n}\n", + source: "/// Schema with a bit of everything, to try out more complex scenarios.\n\n/// Basic user information.\n///\n/// Uses various other `structs` and `enums` to compose the information\n/// in a **type safe** way.\nstruct User {\n name: FullName @1,\n /// Physical address, might not be specified by the user.\n address: option
@2,\n age: u8 @3,\n birthday: birthday::DayOfBirth @4,\n}\n\n/// Full name of a user.\nstruct FullName {\n first: string @1,\n middle: option @2,\n last: string @3,\n}\n\n/// Simple alias for convenience.\n///\n/// - Might be easier to remember.\n/// - Often referenced as this.\ntype Name = FullName;\n\nstruct Address {\n /// Street name.\n street: string @1,\n /// Number of the house in the street.\n house_no: HouseNumber @2,\n city: string @3,\n}\n\n/// The number on the house.\n///\n/// More details can be found at [Wikipedia](https://en.wikipedia.org/wiki/House_numbering).\nenum HouseNumber {\n /// Digit only number.\n Digit(u16 @1) @1,\n /// Mixed _number_ with characters like `1a`.\n Text(string @1) @2,\n}\n\n/// Probably the max age of a human, currently.\nconst MAX_AGE: u8 = 120;\n\n\n/// Details for defining birthdays.\nmod birthday {\n /// As the name suggests, specifies details about birthdays.\n enum DayOfBirth {\n Specific {\n year: u16 @1,\n month: Month @2,\n day: u8 @3,\n } @1,\n /// The user didn't want to say.\n Secret {\n /// Optional info from the user about why they didn't want to\n /// reveal their birthday.\n reason: option @1,\n } @2,\n /// We never asked and nobody knows.\n Unknown @3,\n }\n\n /// Let's assume we only have details of people born **after** this year.\n const MIN_YEAR: u16 = 1900;\n\n /// Absolute maximum for a day, but might be even less depending\n /// on the month.\n const MAX_DAY: u8 = 31;\n\n /// The month of the year.\n enum Month {\n January @1,\n February @2,\n March @3,\n April @4,\n May @5,\n June @6,\n July @7,\n August @8,\n September @9,\n October @10,\n November @11,\n December @12,\n }\n}\n", + comment: Comment( + [ + CommentLine { + value: "Schema with a bit of everything, to try out more complex scenarios.", + span: Span { + start: 0, + end: 71, + }, + }, + ], + ), definitions: [ Struct( Struct { @@ -16,29 +27,29 @@ Schema { CommentLine { value: "Basic user information.", span: Span { - start: 0, - end: 27, + start: 73, + end: 100, }, }, CommentLine { value: "", span: Span { - start: 28, - end: 31, + start: 101, + end: 104, }, }, CommentLine { value: "Uses various other `structs` and `enums` to compose the information", span: Span { - start: 32, - end: 103, + start: 105, + end: 176, }, }, CommentLine { value: "in a **type safe** way.", span: Span { - start: 104, - end: 131, + start: 177, + end: 204, }, }, ], @@ -49,8 +60,8 @@ Schema { name: Name { value: "User", span: Span { - start: 139, - end: 143, + start: 212, + end: 216, }, }, generics: Generics( @@ -65,8 +76,8 @@ Schema { name: Name { value: "name", span: Span { - start: 150, - end: 154, + start: 223, + end: 227, }, }, ty: Type { @@ -76,28 +87,28 @@ Schema { name: Name { value: "FullName", span: Span { - start: 156, - end: 164, + start: 229, + end: 237, }, }, generics: [], }, ), span: Span { - start: 156, - end: 164, + start: 229, + end: 237, }, }, id: Id { value: 1, span: Span { - start: 165, - end: 167, + start: 238, + end: 240, }, }, span: Span { - start: 150, - end: 167, + start: 223, + end: 240, }, }, NamedField { @@ -106,8 +117,8 @@ Schema { CommentLine { value: "Physical address, might not be specified by the user.", span: Span { - start: 173, - end: 230, + start: 246, + end: 303, }, }, ], @@ -115,8 +126,8 @@ Schema { name: Name { value: "address", span: Span { - start: 235, - end: 242, + start: 308, + end: 315, }, }, ty: Type { @@ -128,34 +139,34 @@ Schema { name: Name { value: "Address", span: Span { - start: 251, - end: 258, + start: 324, + end: 331, }, }, generics: [], }, ), span: Span { - start: 251, - end: 258, + start: 324, + end: 331, }, }, ), span: Span { - start: 244, - end: 259, + start: 317, + end: 332, }, }, id: Id { value: 2, span: Span { - start: 260, - end: 262, + start: 333, + end: 335, }, }, span: Span { - start: 231, - end: 262, + start: 304, + end: 335, }, }, NamedField { @@ -165,27 +176,27 @@ Schema { name: Name { value: "age", span: Span { - start: 268, - end: 271, + start: 341, + end: 344, }, }, ty: Type { value: U8, span: Span { - start: 273, - end: 275, + start: 346, + end: 348, }, }, id: Id { value: 3, span: Span { - start: 276, - end: 278, + start: 349, + end: 351, }, }, span: Span { - start: 268, - end: 278, + start: 341, + end: 351, }, }, NamedField { @@ -195,8 +206,8 @@ Schema { name: Name { value: "birthday", span: Span { - start: 284, - end: 292, + start: 357, + end: 365, }, }, ty: Type { @@ -206,36 +217,36 @@ Schema { Name { value: "birthday", span: Span { - start: 294, - end: 302, + start: 367, + end: 375, }, }, ], name: Name { value: "DayOfBirth", span: Span { - start: 304, - end: 314, + start: 377, + end: 387, }, }, generics: [], }, ), span: Span { - start: 294, - end: 314, + start: 367, + end: 387, }, }, id: Id { value: 4, span: Span { - start: 315, - end: 317, + start: 388, + end: 390, }, }, span: Span { - start: 284, - end: 317, + start: 357, + end: 390, }, }, ], @@ -249,8 +260,8 @@ Schema { CommentLine { value: "Full name of a user.", span: Span { - start: 322, - end: 346, + start: 395, + end: 419, }, }, ], @@ -261,8 +272,8 @@ Schema { name: Name { value: "FullName", span: Span { - start: 354, - end: 362, + start: 427, + end: 435, }, }, generics: Generics( @@ -277,27 +288,27 @@ Schema { name: Name { value: "first", span: Span { - start: 369, - end: 374, + start: 442, + end: 447, }, }, ty: Type { value: String, span: Span { - start: 376, - end: 382, + start: 449, + end: 455, }, }, id: Id { value: 1, span: Span { - start: 383, - end: 385, + start: 456, + end: 458, }, }, span: Span { - start: 369, - end: 385, + start: 442, + end: 458, }, }, NamedField { @@ -307,8 +318,8 @@ Schema { name: Name { value: "middle", span: Span { - start: 391, - end: 397, + start: 464, + end: 470, }, }, ty: Type { @@ -316,26 +327,26 @@ Schema { Type { value: String, span: Span { - start: 406, - end: 412, + start: 479, + end: 485, }, }, ), span: Span { - start: 399, - end: 413, + start: 472, + end: 486, }, }, id: Id { value: 2, span: Span { - start: 414, - end: 416, + start: 487, + end: 489, }, }, span: Span { - start: 391, - end: 416, + start: 464, + end: 489, }, }, NamedField { @@ -345,27 +356,27 @@ Schema { name: Name { value: "last", span: Span { - start: 422, - end: 426, + start: 495, + end: 499, }, }, ty: Type { value: String, span: Span { - start: 428, - end: 434, + start: 501, + end: 507, }, }, id: Id { value: 3, span: Span { - start: 435, - end: 437, + start: 508, + end: 510, }, }, span: Span { - start: 422, - end: 437, + start: 495, + end: 510, }, }, ], @@ -379,29 +390,29 @@ Schema { CommentLine { value: "Simple alias for convenience.", span: Span { - start: 442, - end: 475, + start: 515, + end: 548, }, }, CommentLine { value: "", span: Span { - start: 476, - end: 479, + start: 549, + end: 552, }, }, CommentLine { value: "- Might be easier to remember.", span: Span { - start: 480, - end: 514, + start: 553, + end: 587, }, }, CommentLine { value: "- Often referenced as this.", span: Span { - start: 515, - end: 546, + start: 588, + end: 619, }, }, ], @@ -409,8 +420,8 @@ Schema { name: Name { value: "Name", span: Span { - start: 552, - end: 556, + start: 625, + end: 629, }, }, generics: Generics( @@ -423,16 +434,16 @@ Schema { name: Name { value: "FullName", span: Span { - start: 559, - end: 567, + start: 632, + end: 640, }, }, generics: [], }, ), span: Span { - start: 559, - end: 567, + start: 632, + end: 640, }, }, }, @@ -448,8 +459,8 @@ Schema { name: Name { value: "Address", span: Span { - start: 577, - end: 584, + start: 650, + end: 657, }, }, generics: Generics( @@ -463,8 +474,8 @@ Schema { CommentLine { value: "Street name.", span: Span { - start: 591, - end: 607, + start: 664, + end: 680, }, }, ], @@ -472,27 +483,27 @@ Schema { name: Name { value: "street", span: Span { - start: 612, - end: 618, + start: 685, + end: 691, }, }, ty: Type { value: String, span: Span { - start: 620, - end: 626, + start: 693, + end: 699, }, }, id: Id { value: 1, span: Span { - start: 627, - end: 629, + start: 700, + end: 702, }, }, span: Span { - start: 608, - end: 629, + start: 681, + end: 702, }, }, NamedField { @@ -501,8 +512,8 @@ Schema { CommentLine { value: "Number of the house in the street.", span: Span { - start: 635, - end: 673, + start: 708, + end: 746, }, }, ], @@ -510,8 +521,8 @@ Schema { name: Name { value: "house_no", span: Span { - start: 678, - end: 686, + start: 751, + end: 759, }, }, ty: Type { @@ -521,28 +532,28 @@ Schema { name: Name { value: "HouseNumber", span: Span { - start: 688, - end: 699, + start: 761, + end: 772, }, }, generics: [], }, ), span: Span { - start: 688, - end: 699, + start: 761, + end: 772, }, }, id: Id { value: 2, span: Span { - start: 700, - end: 702, + start: 773, + end: 775, }, }, span: Span { - start: 674, - end: 702, + start: 747, + end: 775, }, }, NamedField { @@ -552,27 +563,27 @@ Schema { name: Name { value: "city", span: Span { - start: 708, - end: 712, + start: 781, + end: 785, }, }, ty: Type { value: String, span: Span { - start: 714, - end: 720, + start: 787, + end: 793, }, }, id: Id { value: 3, span: Span { - start: 721, - end: 723, + start: 794, + end: 796, }, }, span: Span { - start: 708, - end: 723, + start: 781, + end: 796, }, }, ], @@ -586,22 +597,22 @@ Schema { CommentLine { value: "The number on the house.", span: Span { - start: 728, - end: 756, + start: 801, + end: 829, }, }, CommentLine { value: "", span: Span { - start: 757, - end: 760, + start: 830, + end: 833, }, }, CommentLine { value: "More details can be found at [Wikipedia](https://en.wikipedia.org/wiki/House_numbering).", span: Span { - start: 761, - end: 853, + start: 834, + end: 926, }, }, ], @@ -612,8 +623,8 @@ Schema { name: Name { value: "HouseNumber", span: Span { - start: 859, - end: 870, + start: 932, + end: 943, }, }, generics: Generics( @@ -626,8 +637,8 @@ Schema { CommentLine { value: "Digit only number.", span: Span { - start: 877, - end: 899, + start: 950, + end: 972, }, }, ], @@ -635,8 +646,8 @@ Schema { name: Name { value: "Digit", span: Span { - start: 904, - end: 909, + start: 977, + end: 982, }, }, fields: Unnamed( @@ -645,20 +656,20 @@ Schema { ty: Type { value: U16, span: Span { - start: 910, - end: 913, + start: 983, + end: 986, }, }, id: Id { value: 1, span: Span { - start: 914, - end: 916, + start: 987, + end: 989, }, }, span: Span { - start: 910, - end: 916, + start: 983, + end: 989, }, }, ], @@ -666,13 +677,13 @@ Schema { id: Id { value: 1, span: Span { - start: 918, - end: 920, + start: 991, + end: 993, }, }, span: Span { - start: 900, - end: 920, + start: 973, + end: 993, }, }, Variant { @@ -681,8 +692,8 @@ Schema { CommentLine { value: "Mixed _number_ with characters like `1a`.", span: Span { - start: 926, - end: 971, + start: 999, + end: 1044, }, }, ], @@ -690,8 +701,8 @@ Schema { name: Name { value: "Text", span: Span { - start: 976, - end: 980, + start: 1049, + end: 1053, }, }, fields: Unnamed( @@ -700,20 +711,20 @@ Schema { ty: Type { value: String, span: Span { - start: 981, - end: 987, + start: 1054, + end: 1060, }, }, id: Id { value: 1, span: Span { - start: 988, - end: 990, + start: 1061, + end: 1063, }, }, span: Span { - start: 981, - end: 990, + start: 1054, + end: 1063, }, }, ], @@ -721,13 +732,13 @@ Schema { id: Id { value: 2, span: Span { - start: 992, - end: 994, + start: 1065, + end: 1067, }, }, span: Span { - start: 972, - end: 994, + start: 1045, + end: 1067, }, }, ], @@ -740,8 +751,8 @@ Schema { CommentLine { value: "Probably the max age of a human, currently.", span: Span { - start: 999, - end: 1046, + start: 1072, + end: 1119, }, }, ], @@ -749,15 +760,15 @@ Schema { name: Name { value: "MAX_AGE", span: Span { - start: 1053, - end: 1060, + start: 1126, + end: 1133, }, }, ty: Type { value: U8, span: Span { - start: 1062, - end: 1064, + start: 1135, + end: 1137, }, }, value: Literal { @@ -765,8 +776,8 @@ Schema { 120, ), span: Span { - start: 1067, - end: 1070, + start: 1140, + end: 1143, }, }, }, @@ -778,8 +789,8 @@ Schema { CommentLine { value: "Details for defining birthdays.", span: Span { - start: 1074, - end: 1109, + start: 1147, + end: 1182, }, }, ], @@ -787,8 +798,8 @@ Schema { name: Name { value: "birthday", span: Span { - start: 1114, - end: 1122, + start: 1187, + end: 1195, }, }, definitions: [ @@ -799,8 +810,8 @@ Schema { CommentLine { value: "As the name suggests, specifies details about birthdays.", span: Span { - start: 1129, - end: 1189, + start: 1202, + end: 1262, }, }, ], @@ -811,8 +822,8 @@ Schema { name: Name { value: "DayOfBirth", span: Span { - start: 1199, - end: 1209, + start: 1272, + end: 1282, }, }, generics: Generics( @@ -826,8 +837,8 @@ Schema { name: Name { value: "Specific", span: Span { - start: 1220, - end: 1228, + start: 1293, + end: 1301, }, }, fields: Named( @@ -839,27 +850,27 @@ Schema { name: Name { value: "year", span: Span { - start: 1243, - end: 1247, + start: 1316, + end: 1320, }, }, ty: Type { value: U16, span: Span { - start: 1249, - end: 1252, + start: 1322, + end: 1325, }, }, id: Id { value: 1, span: Span { - start: 1253, - end: 1255, + start: 1326, + end: 1328, }, }, span: Span { - start: 1243, - end: 1255, + start: 1316, + end: 1328, }, }, NamedField { @@ -869,8 +880,8 @@ Schema { name: Name { value: "month", span: Span { - start: 1269, - end: 1274, + start: 1342, + end: 1347, }, }, ty: Type { @@ -880,28 +891,28 @@ Schema { name: Name { value: "Month", span: Span { - start: 1276, - end: 1281, + start: 1349, + end: 1354, }, }, generics: [], }, ), span: Span { - start: 1276, - end: 1281, + start: 1349, + end: 1354, }, }, id: Id { value: 2, span: Span { - start: 1282, - end: 1284, + start: 1355, + end: 1357, }, }, span: Span { - start: 1269, - end: 1284, + start: 1342, + end: 1357, }, }, NamedField { @@ -911,27 +922,27 @@ Schema { name: Name { value: "day", span: Span { - start: 1298, - end: 1301, + start: 1371, + end: 1374, }, }, ty: Type { value: U8, span: Span { - start: 1303, - end: 1305, + start: 1376, + end: 1378, }, }, id: Id { value: 3, span: Span { - start: 1306, - end: 1308, + start: 1379, + end: 1381, }, }, span: Span { - start: 1298, - end: 1308, + start: 1371, + end: 1381, }, }, ], @@ -939,13 +950,13 @@ Schema { id: Id { value: 1, span: Span { - start: 1320, - end: 1322, + start: 1393, + end: 1395, }, }, span: Span { - start: 1220, - end: 1322, + start: 1293, + end: 1395, }, }, Variant { @@ -954,8 +965,8 @@ Schema { CommentLine { value: "The user didn't want to say.", span: Span { - start: 1332, - end: 1364, + start: 1405, + end: 1437, }, }, ], @@ -963,8 +974,8 @@ Schema { name: Name { value: "Secret", span: Span { - start: 1373, - end: 1379, + start: 1446, + end: 1452, }, }, fields: Named( @@ -975,15 +986,15 @@ Schema { CommentLine { value: "Optional info from the user about why they didn't want to", span: Span { - start: 1394, - end: 1455, + start: 1467, + end: 1528, }, }, CommentLine { value: "reveal their birthday.", span: Span { - start: 1468, - end: 1494, + start: 1541, + end: 1567, }, }, ], @@ -991,8 +1002,8 @@ Schema { name: Name { value: "reason", span: Span { - start: 1507, - end: 1513, + start: 1580, + end: 1586, }, }, ty: Type { @@ -1000,26 +1011,26 @@ Schema { Type { value: String, span: Span { - start: 1522, - end: 1528, + start: 1595, + end: 1601, }, }, ), span: Span { - start: 1515, - end: 1529, + start: 1588, + end: 1602, }, }, id: Id { value: 1, span: Span { - start: 1530, - end: 1532, + start: 1603, + end: 1605, }, }, span: Span { - start: 1495, - end: 1532, + start: 1568, + end: 1605, }, }, ], @@ -1027,13 +1038,13 @@ Schema { id: Id { value: 2, span: Span { - start: 1544, - end: 1546, + start: 1617, + end: 1619, }, }, span: Span { - start: 1365, - end: 1546, + start: 1438, + end: 1619, }, }, Variant { @@ -1042,8 +1053,8 @@ Schema { CommentLine { value: "We never asked and nobody knows.", span: Span { - start: 1556, - end: 1592, + start: 1629, + end: 1665, }, }, ], @@ -1051,21 +1062,21 @@ Schema { name: Name { value: "Unknown", span: Span { - start: 1601, - end: 1608, + start: 1674, + end: 1681, }, }, fields: Unit, id: Id { value: 3, span: Span { - start: 1609, - end: 1611, + start: 1682, + end: 1684, }, }, span: Span { - start: 1593, - end: 1611, + start: 1666, + end: 1684, }, }, ], @@ -1078,8 +1089,8 @@ Schema { CommentLine { value: "Let's assume we only have details of people born **after** this year.", span: Span { - start: 1624, - end: 1697, + start: 1697, + end: 1770, }, }, ], @@ -1087,15 +1098,15 @@ Schema { name: Name { value: "MIN_YEAR", span: Span { - start: 1708, - end: 1716, + start: 1781, + end: 1789, }, }, ty: Type { value: U16, span: Span { - start: 1718, - end: 1721, + start: 1791, + end: 1794, }, }, value: Literal { @@ -1103,8 +1114,8 @@ Schema { 1900, ), span: Span { - start: 1724, - end: 1728, + start: 1797, + end: 1801, }, }, }, @@ -1116,15 +1127,15 @@ Schema { CommentLine { value: "Absolute maximum for a day, but might be even less depending", span: Span { - start: 1735, - end: 1799, + start: 1808, + end: 1872, }, }, CommentLine { value: "on the month.", span: Span { - start: 1804, - end: 1821, + start: 1877, + end: 1894, }, }, ], @@ -1132,15 +1143,15 @@ Schema { name: Name { value: "MAX_DAY", span: Span { - start: 1832, - end: 1839, + start: 1905, + end: 1912, }, }, ty: Type { value: U8, span: Span { - start: 1841, - end: 1843, + start: 1914, + end: 1916, }, }, value: Literal { @@ -1148,8 +1159,8 @@ Schema { 31, ), span: Span { - start: 1846, - end: 1848, + start: 1919, + end: 1921, }, }, }, @@ -1161,8 +1172,8 @@ Schema { CommentLine { value: "The month of the year.", span: Span { - start: 1855, - end: 1881, + start: 1928, + end: 1954, }, }, ], @@ -1173,8 +1184,8 @@ Schema { name: Name { value: "Month", span: Span { - start: 1891, - end: 1896, + start: 1964, + end: 1969, }, }, generics: Generics( @@ -1188,21 +1199,21 @@ Schema { name: Name { value: "January", span: Span { - start: 1907, - end: 1914, + start: 1980, + end: 1987, }, }, fields: Unit, id: Id { value: 1, span: Span { - start: 1915, - end: 1917, + start: 1988, + end: 1990, }, }, span: Span { - start: 1907, - end: 1917, + start: 1980, + end: 1990, }, }, Variant { @@ -1212,21 +1223,21 @@ Schema { name: Name { value: "February", span: Span { - start: 1927, - end: 1935, + start: 2000, + end: 2008, }, }, fields: Unit, id: Id { value: 2, span: Span { - start: 1936, - end: 1938, + start: 2009, + end: 2011, }, }, span: Span { - start: 1927, - end: 1938, + start: 2000, + end: 2011, }, }, Variant { @@ -1236,21 +1247,21 @@ Schema { name: Name { value: "March", span: Span { - start: 1948, - end: 1953, + start: 2021, + end: 2026, }, }, fields: Unit, id: Id { value: 3, span: Span { - start: 1954, - end: 1956, + start: 2027, + end: 2029, }, }, span: Span { - start: 1948, - end: 1956, + start: 2021, + end: 2029, }, }, Variant { @@ -1260,21 +1271,21 @@ Schema { name: Name { value: "April", span: Span { - start: 1966, - end: 1971, + start: 2039, + end: 2044, }, }, fields: Unit, id: Id { value: 4, span: Span { - start: 1972, - end: 1974, + start: 2045, + end: 2047, }, }, span: Span { - start: 1966, - end: 1974, + start: 2039, + end: 2047, }, }, Variant { @@ -1284,21 +1295,21 @@ Schema { name: Name { value: "May", span: Span { - start: 1984, - end: 1987, + start: 2057, + end: 2060, }, }, fields: Unit, id: Id { value: 5, span: Span { - start: 1988, - end: 1990, + start: 2061, + end: 2063, }, }, span: Span { - start: 1984, - end: 1990, + start: 2057, + end: 2063, }, }, Variant { @@ -1308,21 +1319,21 @@ Schema { name: Name { value: "June", span: Span { - start: 2000, - end: 2004, + start: 2073, + end: 2077, }, }, fields: Unit, id: Id { value: 6, span: Span { - start: 2005, - end: 2007, + start: 2078, + end: 2080, }, }, span: Span { - start: 2000, - end: 2007, + start: 2073, + end: 2080, }, }, Variant { @@ -1332,21 +1343,21 @@ Schema { name: Name { value: "July", span: Span { - start: 2017, - end: 2021, + start: 2090, + end: 2094, }, }, fields: Unit, id: Id { value: 7, span: Span { - start: 2022, - end: 2024, + start: 2095, + end: 2097, }, }, span: Span { - start: 2017, - end: 2024, + start: 2090, + end: 2097, }, }, Variant { @@ -1356,21 +1367,21 @@ Schema { name: Name { value: "August", span: Span { - start: 2034, - end: 2040, + start: 2107, + end: 2113, }, }, fields: Unit, id: Id { value: 8, span: Span { - start: 2041, - end: 2043, + start: 2114, + end: 2116, }, }, span: Span { - start: 2034, - end: 2043, + start: 2107, + end: 2116, }, }, Variant { @@ -1380,21 +1391,21 @@ Schema { name: Name { value: "September", span: Span { - start: 2053, - end: 2062, + start: 2126, + end: 2135, }, }, fields: Unit, id: Id { value: 9, span: Span { - start: 2063, - end: 2065, + start: 2136, + end: 2138, }, }, span: Span { - start: 2053, - end: 2065, + start: 2126, + end: 2138, }, }, Variant { @@ -1404,21 +1415,21 @@ Schema { name: Name { value: "October", span: Span { - start: 2075, - end: 2082, + start: 2148, + end: 2155, }, }, fields: Unit, id: Id { value: 10, span: Span { - start: 2083, - end: 2086, + start: 2156, + end: 2159, }, }, span: Span { - start: 2075, - end: 2086, + start: 2148, + end: 2159, }, }, Variant { @@ -1428,21 +1439,21 @@ Schema { name: Name { value: "November", span: Span { - start: 2096, - end: 2104, + start: 2169, + end: 2177, }, }, fields: Unit, id: Id { value: 11, span: Span { - start: 2105, - end: 2108, + start: 2178, + end: 2181, }, }, span: Span { - start: 2096, - end: 2108, + start: 2169, + end: 2181, }, }, Variant { @@ -1452,21 +1463,21 @@ Schema { name: Name { value: "December", span: Span { - start: 2118, - end: 2126, + start: 2191, + end: 2199, }, }, fields: Unit, id: Id { value: 12, span: Span { - start: 2127, - end: 2130, + start: 2200, + end: 2203, }, }, span: Span { - start: 2118, - end: 2130, + start: 2191, + end: 2203, }, }, ], diff --git a/crates/stef-parser/tests/snapshots/parser__parse@module_basic.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@module_basic.stef.snap index bfa2c40..78f6317 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@module_basic.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@module_basic.stef.snap @@ -8,6 +8,9 @@ Schema { "module_basic.stef", ), source: "mod a {\n /// Inner module\n mod b {\n enum Sample {\n One @1,\n }\n }\n\n struct Sample {\n value: u32 @1,\n inner: b::Sample @2,\n }\n}\n", + comment: Comment( + [], + ), definitions: [ Module( Module { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@schema_basic.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@schema_basic.stef.snap index bd05895..b82177f 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@schema_basic.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@schema_basic.stef.snap @@ -8,6 +8,9 @@ Schema { "schema_basic.stef", ), source: "/// Basic struct.\nstruct SampleStruct {\n a: u32 @1,\n b: bool @2,\n}\n\n/// Sample enum.\nenum SampleEnum {\n One @1,\n Two(u32 @1, u64 @2) @2,\n Three {\n field1: u32 @1,\n field2: bool @2,\n } @3,\n}\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@struct_basic.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@struct_basic.stef.snap index 334ad46..6e99851 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@struct_basic.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@struct_basic.stef.snap @@ -8,6 +8,9 @@ Schema { "struct_basic.stef", ), source: "/// Basic struct.\nstruct Sample {\n a: u32 @1,\n /// Second field\n b: bool @2,\n}\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@struct_generics.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@struct_generics.stef.snap index 95defb2..89160e6 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@struct_generics.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@struct_generics.stef.snap @@ -8,6 +8,9 @@ Schema { "struct_generics.stef", ), source: "/// Generic key-value pair.\nstruct KeyValue {\n key: K @1,\n value: V @2,\n}\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@struct_many_ws.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@struct_many_ws.stef.snap index 5041cd1..e38ff3f 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@struct_many_ws.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@struct_many_ws.stef.snap @@ -8,6 +8,9 @@ Schema { "struct_many_ws.stef", ), source: "\n /// Some comment\n struct Sample<\n T\n > {\n\n a: u32 @1,\n b: bool @2,\n c: T @3,\n }\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@struct_min_ws.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@struct_min_ws.stef.snap index de18c8a..2aa9f4d 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@struct_min_ws.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@struct_min_ws.stef.snap @@ -8,6 +8,9 @@ Schema { "struct_min_ws.stef", ), source: "struct Sample{a:u32@1,b:bool@2,c:T@3}\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@struct_tuple.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@struct_tuple.stef.snap index fa1627f..0253d42 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@struct_tuple.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@struct_tuple.stef.snap @@ -8,6 +8,9 @@ Schema { "struct_tuple.stef", ), source: "/// Basic struct.\nstruct Sample(u32 @1, bool @2)\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@types_basic.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@types_basic.stef.snap index 855e278..10eae2e 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@types_basic.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@types_basic.stef.snap @@ -8,6 +8,9 @@ Schema { "types_basic.stef", ), source: "struct Sample {\n f01: bool @1,\n f02: u8 @2,\n f03: u16 @3,\n f04: u32 @4,\n f05: u64 @5,\n f06: u128 @6,\n f07: i8 @7,\n f08: i16 @8,\n f09: i32 @9,\n f10: i64 @10,\n f11: i128 @11,\n f12: f32 @12,\n f13: f64 @13,\n f14: string @14,\n f15: &string @15,\n f16: bytes @16,\n f17: &bytes @17,\n f18: box @18,\n f19: box @19,\n f20: (u32, u32, u32) @20,\n f21: [u32; 12] @21,\n}\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@types_generic.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@types_generic.stef.snap index 4d06e6f..730fcad 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@types_generic.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@types_generic.stef.snap @@ -8,6 +8,9 @@ Schema { "types_generic.stef", ), source: "struct Sample {\n f1: vec @1,\n f2: hash_map @2,\n f3: hash_set @3,\n f4: option @4,\n f5: non_zero @5,\n}\n\nstruct SampleUnnamed(\n vec @1,\n hash_map @2,\n hash_set @3,\n option @4,\n non_zero @5,\n)\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@types_nested.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@types_nested.stef.snap index e44b962..284b37c 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@types_nested.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@types_nested.stef.snap @@ -8,6 +8,9 @@ Schema { "types_nested.stef", ), source: "struct Sample {\n value: vec>>>> @1,\n}\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@types_non_zero.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@types_non_zero.stef.snap index 26c7134..f8750ce 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@types_non_zero.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@types_non_zero.stef.snap @@ -8,6 +8,9 @@ Schema { "types_non_zero.stef", ), source: "struct Sample {\n f01: non_zero @1,\n f02: non_zero @2,\n f03: non_zero @3,\n f04: non_zero @4,\n f05: non_zero @5,\n f06: non_zero @6,\n f07: non_zero @7,\n f08: non_zero @8,\n f09: non_zero @9,\n f10: non_zero @10,\n f11: non_zero @11,\n f12: non_zero @12,\n f13: non_zero> @13,\n f14: non_zero> @14,\n f15: non_zero> @15,\n}\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__parse@types_ref.stef.snap b/crates/stef-parser/tests/snapshots/parser__parse@types_ref.stef.snap index d180fba..3559f56 100644 --- a/crates/stef-parser/tests/snapshots/parser__parse@types_ref.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__parse@types_ref.stef.snap @@ -8,6 +8,9 @@ Schema { "types_ref.stef", ), source: "struct Sample {\n basic: Test123 @1,\n with_generics: KeyValue @2,\n}\n\nenum Test123 {\n Value @1,\n}\n\nstruct KeyValue {\n key: K @1,\n value: V @2,\n}\n", + comment: Comment( + [], + ), definitions: [ Struct( Struct { diff --git a/crates/stef-parser/tests/snapshots/parser__print@mixed.stef.snap b/crates/stef-parser/tests/snapshots/parser__print@mixed.stef.snap index 14de9b0..acb4bb4 100644 --- a/crates/stef-parser/tests/snapshots/parser__print@mixed.stef.snap +++ b/crates/stef-parser/tests/snapshots/parser__print@mixed.stef.snap @@ -1,8 +1,10 @@ --- source: crates/stef-parser/tests/parser.rs -description: "/// Basic user information.\n///\n/// Uses various other `structs` and `enums` to compose the information\n/// in a **type safe** way.\nstruct User {\n name: FullName @1,\n /// Physical address, might not be specified by the user.\n address: option
@2,\n age: u8 @3,\n birthday: birthday::DayOfBirth @4,\n}\n\n/// Full name of a user.\nstruct FullName {\n first: string @1,\n middle: option @2,\n last: string @3,\n}\n\n/// Simple alias for convenience.\n///\n/// - Might be easier to remember.\n/// - Often referenced as this.\ntype Name = FullName;\n\nstruct Address {\n /// Street name.\n street: string @1,\n /// Number of the house in the street.\n house_no: HouseNumber @2,\n city: string @3,\n}\n\n/// The number on the house.\n///\n/// More details can be found at [Wikipedia](https://en.wikipedia.org/wiki/House_numbering).\nenum HouseNumber {\n /// Digit only number.\n Digit(u16 @1) @1,\n /// Mixed _number_ with characters like `1a`.\n Text(string @1) @2,\n}\n\n/// Probably the max age of a human, currently.\nconst MAX_AGE: u8 = 120;\n\n\n/// Details for defining birthdays.\nmod birthday {\n /// As the name suggests, specifies details about birthdays.\n enum DayOfBirth {\n Specific {\n year: u16 @1,\n month: Month @2,\n day: u8 @3,\n } @1,\n /// The user didn't want to say.\n Secret {\n /// Optional info from the user about why they didn't want to\n /// reveal their birthday.\n reason: option @1,\n } @2,\n /// We never asked and nobody knows.\n Unknown @3,\n }\n\n /// Let's assume we only have details of people born **after** this year.\n const MIN_YEAR: u16 = 1900;\n\n /// Absolute maximum for a day, but might be even less depending\n /// on the month.\n const MAX_DAY: u8 = 31;\n\n /// The month of the year.\n enum Month {\n January @1,\n February @2,\n March @3,\n April @4,\n May @5,\n June @6,\n July @7,\n August @8,\n September @9,\n October @10,\n November @11,\n December @12,\n }\n}" +description: "/// Schema with a bit of everything, to try out more complex scenarios.\n\n/// Basic user information.\n///\n/// Uses various other `structs` and `enums` to compose the information\n/// in a **type safe** way.\nstruct User {\n name: FullName @1,\n /// Physical address, might not be specified by the user.\n address: option
@2,\n age: u8 @3,\n birthday: birthday::DayOfBirth @4,\n}\n\n/// Full name of a user.\nstruct FullName {\n first: string @1,\n middle: option @2,\n last: string @3,\n}\n\n/// Simple alias for convenience.\n///\n/// - Might be easier to remember.\n/// - Often referenced as this.\ntype Name = FullName;\n\nstruct Address {\n /// Street name.\n street: string @1,\n /// Number of the house in the street.\n house_no: HouseNumber @2,\n city: string @3,\n}\n\n/// The number on the house.\n///\n/// More details can be found at [Wikipedia](https://en.wikipedia.org/wiki/House_numbering).\nenum HouseNumber {\n /// Digit only number.\n Digit(u16 @1) @1,\n /// Mixed _number_ with characters like `1a`.\n Text(string @1) @2,\n}\n\n/// Probably the max age of a human, currently.\nconst MAX_AGE: u8 = 120;\n\n\n/// Details for defining birthdays.\nmod birthday {\n /// As the name suggests, specifies details about birthdays.\n enum DayOfBirth {\n Specific {\n year: u16 @1,\n month: Month @2,\n day: u8 @3,\n } @1,\n /// The user didn't want to say.\n Secret {\n /// Optional info from the user about why they didn't want to\n /// reveal their birthday.\n reason: option @1,\n } @2,\n /// We never asked and nobody knows.\n Unknown @3,\n }\n\n /// Let's assume we only have details of people born **after** this year.\n const MIN_YEAR: u16 = 1900;\n\n /// Absolute maximum for a day, but might be even less depending\n /// on the month.\n const MAX_DAY: u8 = 31;\n\n /// The month of the year.\n enum Month {\n January @1,\n February @2,\n March @3,\n April @4,\n May @5,\n June @6,\n July @7,\n August @8,\n September @9,\n October @10,\n November @11,\n December @12,\n }\n}" input_file: crates/stef-parser/tests/inputs/mixed.stef --- +/// Schema with a bit of everything, to try out more complex scenarios. + /// Basic user information. /// /// Uses various other `structs` and `enums` to compose the information