Skip to content

Commit

Permalink
disable respace
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Oct 25, 2024
1 parent 92ff0c7 commit 91f11d1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
36 changes: 18 additions & 18 deletions src/generate/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
let p_ty = ident(&name, config, "peripheral", span);
let name_str = p_ty.to_string();
let address = util::hex(p.base_address + config.base_address_shift);
let description = util::respace(p.description.as_ref().unwrap_or(&p.name));
let doc = util::respace(p.description.as_ref().unwrap_or(&name));
let doc = util::escape_special_chars(&doc);

let mod_ty = ident(&name, config, "peripheral_mod", span);
let (derive_regs, base, path) = if let Some(path) = path {
Expand Down Expand Up @@ -88,12 +89,12 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result

let per_to_tokens = |out: &mut TokenStream,
feature_attribute: &TokenStream,
description: &str,
doc: &str,
p_ty: &Ident,
doc_alias: Option<TokenStream>,
address: LitInt| {
out.extend(quote! {
#[doc = #description]
#[doc = #doc]
#phtml
#doc_alias
#feature_attribute
Expand Down Expand Up @@ -140,7 +141,8 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
let mut feature_names = Vec::with_capacity(dim.dim as _);
for pi in svd::peripheral::expand(p, dim) {
let name = &pi.name;
let description = pi.description.as_deref().unwrap_or(&p.name);
let doc = util::respace(pi.description.as_ref().unwrap_or(&pi.name));
let doc = util::escape_special_chars(&doc);
let p_ty = ident(name, config, "peripheral", span);
let name_str = p_ty.to_string();
let doc_alias = (&name_str != name).then(|| quote!(#[doc(alias = #name)]));
Expand All @@ -155,7 +157,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
per_to_tokens(
&mut out,
&feature_attribute_n,
description,
&doc,
&p_ty,
doc_alias,
address,
Expand All @@ -169,7 +171,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
if derive_regs {
// re-export the base module to allow deriveFrom this one
out.extend(quote! {
#[doc = #description]
#[doc = #doc]
#feature_any_attribute
pub use self::#base as #mod_ty;
});
Expand All @@ -185,7 +187,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
per_to_tokens(
&mut out,
&feature_attribute,
&description,
&doc,
&p_ty,
None,
address,
Expand All @@ -196,7 +198,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
if derive_regs {
// re-export the base module to allow deriveFrom this one
out.extend(quote! {
#[doc = #description]
#[doc = #doc]
#feature_attribute
pub use self::#base as #mod_ty;
});
Expand All @@ -205,9 +207,6 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
}
}

let description = util::respace(p.description.as_ref().unwrap_or(&name));
let description = util::escape_special_chars(&description);

// Build up an alternate erc list by expanding any derived registers/clusters
// erc: *E*ither *R*egister or *C*luster
let mut ercs = p.registers.take().unwrap_or_default();
Expand Down Expand Up @@ -246,7 +245,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
register_or_cluster_block(&ercs, &derive_infos, None, "Register block", None, config)?;

out.extend(quote! {
#[doc = #description]
#[doc = #doc]
#feature_attribute
pub mod #mod_ty
});
Expand Down Expand Up @@ -1381,8 +1380,9 @@ fn cluster_block(
index: &Index,
config: &Config,
) -> Result<TokenStream> {
let description = util::respace(c.description.as_ref().unwrap_or(&c.name));
let description = util::escape_special_chars(&description);
let doc = c.description.as_ref().unwrap_or(&c.name);
let doc = util::respace(doc);
let doc = util::escape_special_chars(&doc);
let mod_name = c.name.remove_dim().to_string();

// name_snake_case needs to take into account array type.
Expand All @@ -1409,7 +1409,7 @@ fn cluster_block(
.push(path_segment(ident(&dname, config, "cluster_mod", span)));

Ok(quote! {
#[doc = #description]
#[doc = #doc]
pub use self::#derived as #block_ty;
pub use self::#mod_derived as #mod_ty;
})
Expand All @@ -1429,7 +1429,7 @@ fn cluster_block(
&c.children,
&mod_derive_infos,
Some(&mod_name),
&description,
&doc,
cluster_size,
config,
)?;
Expand All @@ -1441,11 +1441,11 @@ fn cluster_block(
};

Ok(quote! {
#[doc = #description]
#[doc = #doc]
pub use self::#mod_ty::#block_ty;

///Cluster
#[doc = #description]
#[doc = #doc]
pub mod #mod_ty {
#mod_items
}
Expand Down
6 changes: 3 additions & 3 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ pub fn sanitize_keyword(sc: Cow<str>) -> Cow<str> {
}

pub fn respace(s: &str) -> String {
s.split_whitespace()
.collect::<Vec<_>>()
.join(" ")
s//.split_whitespace()
// .collect::<Vec<_>>()
// .join(" ")
.replace(r"\n", "\n")
}

Expand Down

0 comments on commit 91f11d1

Please sign in to comment.