Skip to content

Commit

Permalink
fix(templ): cssxref and jsxref double issue reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed Nov 20, 2024
1 parent c970527 commit c20851b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
24 changes: 17 additions & 7 deletions crates/rari-doc/src/templ/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,27 @@ impl RariApi {
pub fn live_sample_base_url() -> &'static str {
&settings().live_samples_base_url
}
pub fn get_page_nowarn(url: &str) -> Result<Page, DocError> {
RariApi::get_page_internal(url, false)
}

pub fn get_page(url: &str) -> Result<Page, DocError> {
RariApi::get_page_internal(url, true)
}

fn get_page_internal(url: &str, warn: bool) -> Result<Page, DocError> {
let redirect = resolve_redirect(url);
let url = match redirect.as_ref() {
Some(redirect) => {
let ic = get_issue_couter();
tracing::warn!(
source = "macro-redirected-link",
ic = ic,
url = url,
href = redirect.as_ref()
);
if warn {
let ic = get_issue_couter();
tracing::warn!(
source = "macro-redirected-link",
ic = ic,
url = url,
href = redirect.as_ref()
);
}
if deny_warnings() {
return Err(DocError::RedirectedLink {
from: url.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion crates/rari-doc/src/templ/templs/links/cssxref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn cssxref_internal(

let display_name = if display_name.is_some() {
maybe_display_name.to_string()
} else if let Ok(doc) = RariApi::get_page(&url) {
} else if let Ok(doc) = RariApi::get_page_nowarn(&url) {
match doc.page_type() {
PageType::CssFunction if !maybe_display_name.ends_with("()") => {
format!("{maybe_display_name}()")
Expand Down
4 changes: 2 additions & 2 deletions crates/rari-doc/src/templ/templs/links/jsxref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ pub fn jsxref(
let page_url = format!("{url}{slug}");
let object_page_url = format!("{url}{global_objects}/{slug}");

let page = RariApi::get_page(&page_url);
let object_page = RariApi::get_page(&object_page_url);
let page = RariApi::get_page_nowarn(&page_url);
let object_page = RariApi::get_page_nowarn(&object_page_url);
if let Ok(_page) = page {
url.push_str(&slug)
} else if let Ok(_object_page) = object_page {
Expand Down

0 comments on commit c20851b

Please sign in to comment.