From 54302a2d3b6ee2695325a29e917ca15a0abdd9ba Mon Sep 17 00:00:00 2001 From: Andrew Hickman Date: Sat, 28 Oct 2023 22:16:37 +0100 Subject: [PATCH] Include source_code_info in example file descriptors in docs --- protox-parse/src/lib.rs | 25 ++++++++++++------------- protox/src/file/mod.rs | 18 ++++++++---------- protox/src/lib.rs | 34 ++++++++++++++++------------------ 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/protox-parse/src/lib.rs b/protox-parse/src/lib.rs index d282339..36952c6 100644 --- a/protox-parse/src/lib.rs +++ b/protox-parse/src/lib.rs @@ -22,7 +22,7 @@ mod tests; const MAX_MESSAGE_FIELD_NUMBER: i32 = 536_870_911; -/// Parses a single protobuf source file into a [`FileDescriptorProto`](prost_types::FileDescriptorProto). +/// Parses a single protobuf source file into a [`FileDescriptorProto`]. /// /// This function only looks at the syntax of the file, without resolving type names or reading /// imported files. @@ -58,18 +58,17 @@ const MAX_MESSAGE_FIELD_NUMBER: i32 = 536_870_911; /// ..Default::default() /// }], /// source_code_info: Some(SourceCodeInfo { -/// /* ... */ -/// # location: vec![ -/// # Location { path: vec![], span: vec![1, 4, 6, 5], ..Default::default() }, -/// # Location { path: vec![3, 0], span: vec![2, 4, 23], ..Default::default() }, -/// # Location { path: vec![4, 0], span: vec![4, 4, 6, 5], ..Default::default() }, -/// # Location { path: vec![4, 0, 1], span: vec![4, 12, 15], ..Default::default() }, -/// # Location { path: vec![4, 0, 2, 0], span: vec![5, 8, 20], ..Default::default() }, -/// # Location { path: vec![4, 0, 2, 0, 1], span: vec![5, 12, 15], ..Default::default() }, -/// # Location { path: vec![4, 0, 2, 0, 3], span: vec![5, 18, 19], ..Default::default() }, -/// # Location { path: vec![4, 0, 2, 0, 6], span: vec![5, 8, 11], ..Default::default() }, -/// # Location { path: vec![12], span: vec![1, 4, 22], ..Default::default() }, -/// # ], +/// location: vec![ +/// Location { path: vec![], span: vec![1, 4, 6, 5], ..Default::default() }, +/// Location { path: vec![3, 0], span: vec![2, 4, 23], ..Default::default() }, +/// Location { path: vec![4, 0], span: vec![4, 4, 6, 5], ..Default::default() }, +/// Location { path: vec![4, 0, 1], span: vec![4, 12, 15], ..Default::default() }, +/// Location { path: vec![4, 0, 2, 0], span: vec![5, 8, 20], ..Default::default() }, +/// Location { path: vec![4, 0, 2, 0, 1], span: vec![5, 12, 15], ..Default::default() }, +/// Location { path: vec![4, 0, 2, 0, 3], span: vec![5, 18, 19], ..Default::default() }, +/// Location { path: vec![4, 0, 2, 0, 6], span: vec![5, 8, 11], ..Default::default() }, +/// Location { path: vec![12], span: vec![1, 4, 22], ..Default::default() }, +/// ], /// }), /// ..Default::default() /// }) diff --git a/protox/src/file/mod.rs b/protox/src/file/mod.rs index a6be4ff..f8bd0a5 100644 --- a/protox/src/file/mod.rs +++ b/protox/src/file/mod.rs @@ -106,10 +106,9 @@ impl File { /// }], /// source_code_info: Some(SourceCodeInfo { /// location: vec![ - /// /* ... */ - /// # Location { path: vec![], span: vec![0, 0, 15], ..Default::default() }, - /// # Location { path: vec![4, 0], span: vec![0, 0, 15], ..Default::default() }, - /// # Location { path: vec![4, 0, 1], span: vec![0, 8, 11], ..Default::default() } + /// Location { path: vec![], span: vec![0, 0, 15], ..Default::default() }, + /// Location { path: vec![4, 0], span: vec![0, 0, 15], ..Default::default() }, + /// Location { path: vec![4, 0, 1], span: vec![0, 8, 11], ..Default::default() } /// ] /// }), /// ..Default::default() @@ -179,10 +178,9 @@ impl File { /// }], /// source_code_info: Some(SourceCodeInfo { /// location: vec![ - /// /* ... */ - /// # Location { path: vec![], span: vec![0, 0, 15], ..Default::default() }, - /// # Location { path: vec![4, 0], span: vec![0, 0, 15], ..Default::default() }, - /// # Location { path: vec![4, 0, 1], span: vec![0, 8, 11], ..Default::default() } + /// Location { path: vec![], span: vec![0, 0, 15], ..Default::default() }, + /// Location { path: vec![4, 0], span: vec![0, 0, 15], ..Default::default() }, + /// Location { path: vec![4, 0, 1], span: vec![0, 8, 11], ..Default::default() } /// ] /// }), /// ..Default::default() @@ -199,7 +197,7 @@ impl File { }) } - /// Create a new instance of [`File`] from a parsed [`FileDescriptorProto`](prost_types::FileDescriptorProto). + /// Create a new instance of [`File`] from a parsed [`FileDescriptorProto`]. /// /// The file does not need to have type names or imports resolved. Typically, it would be returned by the [`parse()`](protox_parse::parse()) method. pub fn from_file_descriptor_proto(file: prost_types::FileDescriptorProto) -> Self { @@ -211,7 +209,7 @@ impl File { } } - /// Create an instance of [`File`] by deserializing a [`FileDescriptorProto`](prost_types::FileDescriptorProto) + /// Create an instance of [`File`] by deserializing a [`FileDescriptorProto`] /// from the given bytes. /// /// Unlike when going through [`from_file_descriptor_proto()`](File::from_file_descriptor_proto), extension options are preserved. diff --git a/protox/src/lib.rs b/protox/src/lib.rs index ed2ca1f..2daf7c0 100644 --- a/protox/src/lib.rs +++ b/protox/src/lib.rs @@ -84,12 +84,11 @@ pub use self::error::Error; /// ..Default::default() /// }], /// source_code_info: Some(SourceCodeInfo { -/// /* ... */ -/// # location: vec![ -/// # Location { path: vec![], span: vec![1, 4, 19], ..Default::default() }, -/// # Location { path: vec![4, 0], span: vec![1, 4, 19], ..Default::default() }, -/// # Location { path: vec![4, 0, 1], span: vec![1, 12, 15], ..Default::default() }, -/// # ], +/// location: vec![ +/// Location { path: vec![], span: vec![1, 4, 19], ..Default::default() }, +/// Location { path: vec![4, 0], span: vec![1, 4, 19], ..Default::default() }, +/// Location { path: vec![4, 0, 1], span: vec![1, 12, 15], ..Default::default() }, +/// ], /// }), /// ..Default::default() /// }, @@ -110,18 +109,17 @@ pub use self::error::Error; /// ..Default::default() /// }], /// source_code_info: Some(SourceCodeInfo { -/// /* ... */ -/// # location: vec![ -/// # Location { path: vec![], span: vec![1, 4, 5, 5], ..Default::default() }, -/// # Location { path: vec![3, 0], span: vec![1, 4, 23], ..Default::default() }, -/// # Location { path: vec![4, 0], span: vec![3, 4, 5, 5], ..Default::default() }, -/// # Location { path: vec![4, 0, 1], span: vec![3, 12, 15], ..Default::default() }, -/// # Location { path: vec![4, 0, 2, 0], span: vec![4, 8, 29], ..Default::default() }, -/// # Location { path: vec![4, 0, 2, 0, 1], span: vec![4, 21, 24], ..Default::default() }, -/// # Location { path: vec![4, 0, 2, 0, 3], span: vec![4, 27, 28], ..Default::default() }, -/// # Location { path: vec![4, 0, 2, 0, 4], span: vec![4, 8, 16], ..Default::default() }, -/// # Location { path: vec![4, 0, 2, 0, 6], span: vec![4, 17, 20], ..Default::default() }, -/// # ], +/// location: vec![ +/// Location { path: vec![], span: vec![1, 4, 5, 5], ..Default::default() }, +/// Location { path: vec![3, 0], span: vec![1, 4, 23], ..Default::default() }, +/// Location { path: vec![4, 0], span: vec![3, 4, 5, 5], ..Default::default() }, +/// Location { path: vec![4, 0, 1], span: vec![3, 12, 15], ..Default::default() }, +/// Location { path: vec![4, 0, 2, 0], span: vec![4, 8, 29], ..Default::default() }, +/// Location { path: vec![4, 0, 2, 0, 1], span: vec![4, 21, 24], ..Default::default() }, +/// Location { path: vec![4, 0, 2, 0, 3], span: vec![4, 27, 28], ..Default::default() }, +/// Location { path: vec![4, 0, 2, 0, 4], span: vec![4, 8, 16], ..Default::default() }, +/// Location { path: vec![4, 0, 2, 0, 6], span: vec![4, 17, 20], ..Default::default() }, +/// ], /// }), /// ..Default::default() /// },