From 7f2cf1dce8236c60931f729748c487d401878067 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Sun, 29 Dec 2024 09:01:27 +1100 Subject: [PATCH] api: Include generics in regex The regex is still wrong, it misses structs with generics. Currently `contrib/api.sh io types` returns: ErrorKind Error Sink But with this patch applied it returns: FromStd ToStd ErrorKind Cursor Error Sink Take<'a, R: bitcoin_io::Read + ?core::marker::Sized> --- contrib/api.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/api.sh b/contrib/api.sh index 97bfcf1e1..03bfe1203 100755 --- a/contrib/api.sh +++ b/contrib/api.sh @@ -99,12 +99,12 @@ main() { # Print all public structs and enums. structs_and_enums() { - grep -oP 'pub (struct|enum) \K[\w:]+(?=\(|;| |$)' "$file" | sed "s/^${crate_full_name}:://" + grep -oP 'pub (struct|enum) \K[\w:]+(?:<[^>]+>)?(?=\(|;| |$)' "$file" | sed "s/^${crate_full_name}:://" } # Print all public structs and enums excluding error types. structs_and_enums_no_err() { - grep -oP 'pub (struct|enum) \K[\w:]+(?=\(|;| |$)' "$file" | sed "s/^${crate_full_name}:://" | grep -v Error + grep -oP 'pub (struct|enum) \K[\w:]+(?:<[^>]+>)?(?=\(|;| |$)' "$file" | sed "s/^${crate_full_name}:://" | grep -v Error } # Print all public traits.