Avoid trimming non whitespace characters.
Rustc already removes all leading `/` symbols during the conversion from doc-comments into annotations. Any additional trimming of non whitespace characters just reduces the formatting flexibility of a comment. ... fixes #374
This commit is contained in:
parent
65958a5a96
commit
47e831753b
@ -252,41 +252,25 @@ impl SynAttributeHelpers for [syn::Attribute] {
|
||||
}
|
||||
|
||||
fn get_comment_lines(&self) -> Vec<String> {
|
||||
let mut raw_comment = String::new();
|
||||
let mut comment = Vec::new();
|
||||
|
||||
for attr in self {
|
||||
if attr.style == syn::AttrStyle::Outer {
|
||||
if let Some(syn::Meta::NameValue(syn::MetaNameValue {
|
||||
ident,
|
||||
lit: syn::Lit::Str(comment),
|
||||
lit: syn::Lit::Str(content),
|
||||
..
|
||||
})) = attr.interpret_meta()
|
||||
{
|
||||
let name = ident.to_string();
|
||||
if &*name == "doc" {
|
||||
let text = comment.value();
|
||||
raw_comment += &text;
|
||||
raw_comment += "\n";
|
||||
let text = content.value().trim().to_owned();
|
||||
comment.push(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut comment_lines = Vec::new();
|
||||
for raw in raw_comment.lines() {
|
||||
let line = raw
|
||||
.trim_start_matches(" ")
|
||||
.trim_start_matches("//")
|
||||
.trim_start_matches("///")
|
||||
.trim_start_matches("/**")
|
||||
.trim_start_matches("/*")
|
||||
.trim_start_matches("*/")
|
||||
.trim_start_matches("*")
|
||||
.trim_end();
|
||||
|
||||
comment_lines.push(line.to_owned());
|
||||
}
|
||||
|
||||
comment_lines
|
||||
comment
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,14 @@
|
||||
* # Hint
|
||||
*
|
||||
* Always ensure that everything is properly documented, even if you feel lazy.
|
||||
* Sometimes** it is also helpful to include some markdown formatting.
|
||||
* **Sometimes** it is also helpful to include some markdown formatting.
|
||||
*
|
||||
* ////////////////////////////////////////////////////////////////////////////
|
||||
*
|
||||
* # Attention
|
||||
*
|
||||
* Rust is going to trim all leading `/` symbols. If you want to use them as a
|
||||
* marker you need to add at least a single whitespace inbetween the tripple
|
||||
* slash doc-comment marker and the rest.
|
||||
*/
|
||||
void root(void);
|
||||
|
@ -16,7 +16,15 @@ extern "C" {
|
||||
* # Hint
|
||||
*
|
||||
* Always ensure that everything is properly documented, even if you feel lazy.
|
||||
* Sometimes** it is also helpful to include some markdown formatting.
|
||||
* **Sometimes** it is also helpful to include some markdown formatting.
|
||||
*
|
||||
* ////////////////////////////////////////////////////////////////////////////
|
||||
*
|
||||
* # Attention
|
||||
*
|
||||
* Rust is going to trim all leading `/` symbols. If you want to use them as a
|
||||
* marker you need to add at least a single whitespace inbetween the tripple
|
||||
* slash doc-comment marker and the rest.
|
||||
*/
|
||||
void root(void);
|
||||
|
||||
|
@ -12,6 +12,14 @@
|
||||
* # Hint
|
||||
*
|
||||
* Always ensure that everything is properly documented, even if you feel lazy.
|
||||
* Sometimes** it is also helpful to include some markdown formatting.
|
||||
* **Sometimes** it is also helpful to include some markdown formatting.
|
||||
*
|
||||
* ////////////////////////////////////////////////////////////////////////////
|
||||
*
|
||||
* # Attention
|
||||
*
|
||||
* Rust is going to trim all leading `/` symbols. If you want to use them as a
|
||||
* marker you need to add at least a single whitespace inbetween the tripple
|
||||
* slash doc-comment marker and the rest.
|
||||
*/
|
||||
void root(void);
|
||||
|
@ -16,7 +16,15 @@ extern "C" {
|
||||
* # Hint
|
||||
*
|
||||
* Always ensure that everything is properly documented, even if you feel lazy.
|
||||
* Sometimes** it is also helpful to include some markdown formatting.
|
||||
* **Sometimes** it is also helpful to include some markdown formatting.
|
||||
*
|
||||
* ////////////////////////////////////////////////////////////////////////////
|
||||
*
|
||||
* # Attention
|
||||
*
|
||||
* Rust is going to trim all leading `/` symbols. If you want to use them as a
|
||||
* marker you need to add at least a single whitespace inbetween the tripple
|
||||
* slash doc-comment marker and the rest.
|
||||
*/
|
||||
void root(void);
|
||||
|
||||
|
@ -13,7 +13,15 @@ extern "C" {
|
||||
/// # Hint
|
||||
///
|
||||
/// Always ensure that everything is properly documented, even if you feel lazy.
|
||||
/// Sometimes** it is also helpful to include some markdown formatting.
|
||||
/// **Sometimes** it is also helpful to include some markdown formatting.
|
||||
///
|
||||
/// ////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// # Attention
|
||||
///
|
||||
/// Rust is going to trim all leading `/` symbols. If you want to use them as a
|
||||
/// marker you need to add at least a single whitespace inbetween the tripple
|
||||
/// slash doc-comment marker and the rest.
|
||||
void root();
|
||||
|
||||
} // extern "C"
|
||||
|
@ -12,6 +12,14 @@
|
||||
* # Hint
|
||||
*
|
||||
* Always ensure that everything is properly documented, even if you feel lazy.
|
||||
* Sometimes** it is also helpful to include some markdown formatting.
|
||||
* **Sometimes** it is also helpful to include some markdown formatting.
|
||||
*
|
||||
* ////////////////////////////////////////////////////////////////////////////
|
||||
*
|
||||
* # Attention
|
||||
*
|
||||
* Rust is going to trim all leading `/` symbols. If you want to use them as a
|
||||
* marker you need to add at least a single whitespace inbetween the tripple
|
||||
* slash doc-comment marker and the rest.
|
||||
*/
|
||||
void root(void);
|
||||
|
@ -16,7 +16,15 @@ extern "C" {
|
||||
* # Hint
|
||||
*
|
||||
* Always ensure that everything is properly documented, even if you feel lazy.
|
||||
* Sometimes** it is also helpful to include some markdown formatting.
|
||||
* **Sometimes** it is also helpful to include some markdown formatting.
|
||||
*
|
||||
* ////////////////////////////////////////////////////////////////////////////
|
||||
*
|
||||
* # Attention
|
||||
*
|
||||
* Rust is going to trim all leading `/` symbols. If you want to use them as a
|
||||
* marker you need to add at least a single whitespace inbetween the tripple
|
||||
* slash doc-comment marker and the rest.
|
||||
*/
|
||||
void root(void);
|
||||
|
||||
|
@ -7,6 +7,14 @@
|
||||
///
|
||||
/// Always ensure that everything is properly documented, even if you feel lazy.
|
||||
/// **Sometimes** it is also helpful to include some markdown formatting.
|
||||
///
|
||||
/// ////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// # Attention
|
||||
///
|
||||
/// Rust is going to trim all leading `/` symbols. If you want to use them as a
|
||||
/// marker you need to add at least a single whitespace inbetween the tripple
|
||||
/// slash doc-comment marker and the rest.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn root() {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user