Skip to content

Commit

Permalink
fix docify attribute regex, still leaving extra newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
sam0x17 committed Oct 27, 2023
1 parent 84ecebd commit 2288c60
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ impl<'ast> SupportedVisitItem<'ast> for ItemVisitor {
}
}

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, PartialEq, Eq)]
enum ResultStyle {
Export,
ExportContent,
Expand Down Expand Up @@ -778,8 +778,11 @@ impl CompressedString {
}
}

static DOCIFY_ATTRIBUTES: Lazy<Regex> =
Lazy::new(|| Regex::new(r"\#\[(?:\w+::)*export(?:\s*\(\s*(\w+)\s*\))?\]").unwrap());
static DOCIFY_ATTRIBUTES: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"\n?\#\[(?:\w+\s*::\s*)*(?:export|export_content)(?:\s*\(\s*(\w+)\s*\))?\]\n?")
.unwrap()
});

static DOC_COMMENT: Lazy<Regex> = Lazy::new(|| Regex::new(r"///.*").unwrap());
static DOC_COMMENT_ATTR: Lazy<Regex> =
Lazy::new(|| Regex::new(r#"#\[doc\s*=\s*".*"\s*]"#).unwrap());
Expand Down Expand Up @@ -905,7 +908,8 @@ fn source_excerpt<'a, T: ToTokens>(
item: &'a T,
style: ResultStyle,
) -> Result<String> {
// note: can't rely on span locations because this requires nightly and/or is otherwise bugged
// note: can't rely on span locations because this requires nightly and/or is otherwise
// bugged
let compressed_source = CompressedString::from(source);
let item_tokens = match style {
ResultStyle::Export => item.to_token_stream(),
Expand Down

0 comments on commit 2288c60

Please sign in to comment.