Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi-byte utf-8 characters in doc comments break docify #7

Closed
sam0x17 opened this issue Sep 13, 2023 · 4 comments
Closed

multi-byte utf-8 characters in doc comments break docify #7

sam0x17 opened this issue Sep 13, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@sam0x17
Copy link
Owner

sam0x17 commented Sep 13, 2023

Code sample:

/// Example struct holding the most recently set [`u32`] and the second
/// most recently set [`u32`] (if one existed).
pub struct Foo;

Fixes when word wrapping is tweaked to:

/// Example struct holding the most recently set [`u32`] and the
/// second most recently set [`u32`] (if one existed).
pub struct Foo;

cc @liamaharon

@sam0x17 sam0x17 added the bug Something isn't working label Sep 13, 2023
@sam0x17 sam0x17 self-assigned this Sep 13, 2023
@sam0x17
Copy link
Owner Author

sam0x17 commented Sep 13, 2023

This regex change fixes it this regex change fixes the initial issue:

-static DOC_COMMENT_ATTR: Lazy<Regex> = Lazy::new(|| Regex::new(r#"#\[doc = ".*"]"#).unwrap());
+static DOC_COMMENT_ATTR: Lazy<Regex> =
+    Lazy::new(|| Regex::new(r#"#\[doc\s*=\s*".*"\s*]"#).unwrap());

@sam0x17 sam0x17 changed the title source_excerpt: can't find item in source when doc comments longer than 70 characters on exported item source_excerpt: can't find item in source when special characters are in doc comments Sep 14, 2023
@sam0x17 sam0x17 reopened this Sep 14, 2023
@sam0x17
Copy link
Owner Author

sam0x17 commented Sep 14, 2023

Re-opening because the real reason this is happening is the presence of special characters in doc comments in the file. The following being present anywhere in the source file being embedded will reproduce the bug:

//! ```text
//! ├
//! ```

@sam0x17
Copy link
Owner Author

sam0x17 commented Sep 14, 2023

ah and the reason this is an issue is multi-byte UTF-8 characters

@sam0x17 sam0x17 changed the title source_excerpt: can't find item in source when special characters are in doc comments multi-byte utf-8 characters in doc comments break docify Sep 14, 2023
sam0x17 added a commit that referenced this issue Sep 14, 2023
sam0x17 added a commit that referenced this issue Sep 14, 2023
@sam0x17
Copy link
Owner Author

sam0x17 commented Sep 14, 2023

fixed in v0.2.3

@sam0x17 sam0x17 closed this as completed Sep 14, 2023
sam0x17 added a commit to paritytech/polkadot-sdk that referenced this issue Sep 15, 2023
Upgrades to docify v0.2.3, which includes a fix for
sam0x17/docify#7 and full support for
multi-byte UTF-8 characters
bgallois pushed a commit to duniter/duniter-polkadot-sdk that referenced this issue Mar 25, 2024
Upgrades to docify v0.2.3, which includes a fix for
sam0x17/docify#7 and full support for
multi-byte UTF-8 characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant