diff --git a/crates/css-syntax/src/syntax.rs b/crates/css-syntax/src/syntax.rs index b46b8483..56330204 100644 --- a/crates/css-syntax/src/syntax.rs +++ b/crates/css-syntax/src/syntax.rs @@ -337,7 +337,7 @@ impl SyntaxRenderer<'_> { if name.starts_with("<'") && name.ends_with("'>") { let slug = &name[2..name.len() - 2]; format!( - r#"{encoded}"#, + r#"{encoded}"#, self.locale_str ) } else { @@ -349,6 +349,9 @@ impl SyntaxRenderer<'_> { let slug = match name { "" => "color_value", "" => "position_value", + "" => "color_value/contrast-color", + "" => "color_value/device-cmyk", + "" => "color_value/light-dark", name if name.starts_with('<') && name.ends_with('>') => { &name[1..name.find(" [").or(name.find('[')).unwrap_or(name.len() - 1)] } @@ -367,7 +370,7 @@ impl SyntaxRenderer<'_> { } else { // FIXME: this should have the class type but to be compatible we use property format!( - r#"{encoded}"#, + r#"{encoded}"#, self.locale_str ) } @@ -823,7 +826,7 @@ mod test { fn test_render_terms() -> Result<(), SyntaxError> { let renderer = SyntaxRenderer { locale_str: "en-US", - value_definition_url: "/en-US/docs/Web/CSS/CSS_values_and_units/Value_definition_syntax", + value_definition_url: "/en-US/docs/Web/CSS/Guides/Values_and_units/Value_definition_syntax", syntax_tooltip: &TOOLTIPS, constituents: Default::default(), }; @@ -834,7 +837,7 @@ mod test { let rendered = renderer.render_terms(&group.terms, group.combinator)?; assert_eq!( rendered, - " <color-base> |
currentColor |
<system-color> |
<contrast-color()> |
<device-cmyk()> |
<light-dark()>
" + " <color-base> |
currentColor |
<system-color> |
<contrast-color()> |
<device-cmyk()> |
<light-dark()>
" ); } else { panic!("no group node") @@ -844,12 +847,12 @@ mod test { #[test] fn test_render_node() -> Result<(), SyntaxError> { - let expected = "
padding = 
<'padding-top'>{1,4}

<padding-top> =
<length-percentage [0,∞]>

<length-percentage> =
<length> |
<percentage>
"; + let expected = "
padding = 
<'padding-top'>{1,4}

<padding-top> =
<length-percentage [0,∞]>

<length-percentage> =
<length> |
<percentage>
"; let result = render_formal_syntax( SyntaxInput::Css(CssType::Property("padding")), None, "en-US", - "/en-US/docs/Web/CSS/CSS_values_and_units/Value_definition_syntax", + "/en-US/docs/Web/CSS/Guides/Values_and_units/Value_definition_syntax", &TOOLTIPS, None, )?; @@ -859,12 +862,12 @@ mod test { #[test] fn test_render_function() -> Result<(), SyntaxError> { - let expected = "
<hue-rotate()> = 
hue-rotate( [ <angle> | <zero> ]? )
"; + let expected = "
<hue-rotate()> = 
hue-rotate( [ <angle> | <zero> ]? )
"; let result = render_formal_syntax( SyntaxInput::Css(CssType::Function("hue-rotate")), Some("css.types.filter-function.hue-rotate"), "en-US", - "/en-US/docs/Web/CSS/CSS_values_and_units/Value_definition_syntax", + "/en-US/docs/Web/CSS/Guides/Values_and_units/Value_definition_syntax", &TOOLTIPS, None, )?; @@ -874,24 +877,24 @@ mod test { #[test] fn test_render_function_scoped() -> Result<(), SyntaxError> { // rect() from the clip specs - let expected = "
<rect()> = 
rect( <top> , <right> , <bottom> , <left> )
"; + let expected = "
<rect()> = 
rect( <top> , <right> , <bottom> , <left> )
"; let result = render_formal_syntax( SyntaxInput::Css(CssType::Function("rect")), Some("css.properties.clip"), "en-US", - "/en-US/docs/Web/CSS/CSS_values_and_units/Value_definition_syntax", + "/en-US/docs/Web/CSS/Guides/Values_and_units/Value_definition_syntax", &TOOLTIPS, None, )?; assert_eq!(result, expected); // rect() from the shape specs - let expected = "
<rect()> = 
rect( [ <length-percentage> | auto ]{4} [ round <'border-radius'> ]? )

<length-percentage> =
<length> |
<percentage>

<border-radius> =
<length-percentage [0,∞]>{1,4} [ / <length-percentage [0,∞]>{1,4} ]?
"; + let expected = "
<rect()> = 
rect( [ <length-percentage> | auto ]{4} [ round <'border-radius'> ]? )

<length-percentage> =
<length> |
<percentage>

<border-radius> =
<length-percentage [0,∞]>{1,4} [ / <length-percentage [0,∞]>{1,4} ]?
"; let result = render_formal_syntax( SyntaxInput::Css(CssType::Function("rect")), Some("css.types.basic-shape.rect"), "en-US", - "/en-US/docs/Web/CSS/CSS_values_and_units/Value_definition_syntax", + "/en-US/docs/Web/CSS/Guides/Values_and_units/Value_definition_syntax", &TOOLTIPS, None, )?; diff --git a/crates/rari-doc/src/helpers/title.rs b/crates/rari-doc/src/helpers/title.rs index d89bd134..076465a3 100644 --- a/crates/rari-doc/src/helpers/title.rs +++ b/crates/rari-doc/src/helpers/title.rs @@ -70,7 +70,7 @@ mod test { #[test] fn test_root_doc_url() { assert_eq!( - root_doc_url("/en-US/docs/Web/CSS/border"), + root_doc_url("/en-US/docs/Web/CSS/Reference/Properties/border"), Some("/en-US/docs/Web/CSS") ); assert_eq!( diff --git a/crates/rari-doc/src/templ/templs/css_ref.rs b/crates/rari-doc/src/templ/templs/css_ref.rs index 324bf696..63bd7338 100644 --- a/crates/rari-doc/src/templ/templs/css_ref.rs +++ b/crates/rari-doc/src/templ/templs/css_ref.rs @@ -102,7 +102,7 @@ fn initial_letter(s: &str) -> char { /// (e.g., "font-family (@font-face)"). fn label_from_page(page: &Page) -> Cow<'_, str> { if page.page_type() == PageType::CssAtRuleDescriptor { - // Extract at-rule name from slug (e.g., "Web/CSS/@font-face/font-family" → "@font-face") + // Extract at-rule name from slug (e.g., "Web/CSS/Reference/At-rules/@font-face/font-family" → "@font-face") if let Some(at_rule) = page .slug() .rsplit('/') diff --git a/crates/rari-tools/src/sidebars.rs b/crates/rari-tools/src/sidebars.rs index be0d1210..4c3a8994 100644 --- a/crates/rari-tools/src/sidebars.rs +++ b/crates/rari-tools/src/sidebars.rs @@ -431,33 +431,33 @@ mod test { - details: closed title: Backgrounds_and_Borders children: - - /Web/CSS/CSS_Backgrounds_and_Borders/Using_multiple_backgrounds - - link: /Web/CSS/CSS_Backgrounds_and_Borders/Resizing_background_images + - /Web/CSS/Guides/Backgrounds_and_borders/Using_multiple_backgrounds + - link: /Web/CSS/Guides/Backgrounds_and_borders/Resizing_background_images title: Resizing_background_images - details: closed title: Box alignment children: - - link: /Web/CSS/CSS_Box_Alignment/Box_Alignment_In_Block_Abspos_Tables + - link: /Web/CSS/Guides/Box_alignment/In_block_abspos_tables title: Box_alignment_in_block_layout - - /Web/CSS/CSS_Box_Alignment/Box_Alignment_in_Flexbox - - /Web/CSS/CSS_Box_Alignment/Box_Alignment_In_Grid_Layout - - /Web/CSS/CSS_Box_Alignment/Box_Alignment_in_Multi-column_Layout + - /Web/CSS/Guides/Box_alignment/In_flexbox + - /Web/CSS/Guides/Box_alignment/In_grid_layout + - /Web/CSS/Guides/Box_alignment/In_multi-column_layout - details: closed title: Box_model children: - - /Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model - - /Web/CSS/CSS_Box_Model/Mastering_margin_collapsing + - /Web/CSS/Guides/Box_model/Introduction + - /Web/CSS/Guides/Box_model/Margin_collapsing - type: listSubPages path: /en-US/docs/Web/HTTP/Reference/Headers title: Headers tags: [] details: closed - type: listSubPages - path: /en-US/docs/Web/CSS/CSS_Box_Alignment + path: /en-US/docs/Web/CSS/Guides/Box_alignment title: Headers tags: [] details: closed - - link: /Web/CSS/CSS_Box_Alignment + - link: /Web/CSS/Guides/Box_alignment l10n: en-US: @@ -474,22 +474,22 @@ mod test { let _sidebars = SidebarFixtures::new(vec![sb]); let pairs = vec![ ( - Cow::Borrowed("Web/CSS/CSS_Box_Alignment/Box_Alignment_In_Block_Abspos_Tables"), - Some(Cow::Borrowed("Web/CSS/CSS_Box_Alignment/Something_New")), + Cow::Borrowed("Web/CSS/Guides/Box_alignment/In_block_abspos_tables"), + Some(Cow::Borrowed("Web/CSS/Guides/Box_alignment/Something_New")), ), ( - Cow::Borrowed("Web/CSS/CSS_Box_Alignment/Box_Alignment_In_Grid_Layout"), - Some(Cow::Borrowed("Web/CSS/CSS_Box_Alignment/Also_New")), + Cow::Borrowed("Web/CSS/Guides/Box_alignment/In_grid_layout"), + Some(Cow::Borrowed("Web/CSS/Guides/Box_alignment/Also_New")), ), ( Cow::Borrowed("Web/HTTP/Reference/Headers"), Some(Cow::Borrowed("Web/HTTP/Reference/Headers_New")), ), ( - Cow::Borrowed("/Web/CSS/CSS_Box_Alignment/Box_Alignment_in_Multi-column_Layout"), + Cow::Borrowed("/Web/CSS/Guides/Box_alignment/In_multi-column_layout"), None, ), - (Cow::Borrowed("/Web/CSS/CSS_Box_Alignment"), None), + (Cow::Borrowed("/Web/CSS/Guides/Box_alignment"), None), ]; let res = update_sidebars(&pairs); assert!(res.is_ok()); @@ -518,7 +518,10 @@ mod test { } else { panic!("Expected a Link entry"); }; - assert_eq!(link, "/Web/CSS/CSS_Box_Alignment/Something_New".to_string()); + assert_eq!( + link, + "/Web/CSS/Guides/Box_alignment/Something_New".to_string() + ); // replacement of link of the third child in the third item of the sidebar let third_item_third_child = @@ -532,7 +535,7 @@ mod test { } else { panic!("Expected a Link entry"); }; - assert_eq!(link, "/Web/CSS/CSS_Box_Alignment/Also_New".to_string()); + assert_eq!(link, "/Web/CSS/Guides/Box_alignment/Also_New".to_string()); // replacement of the path of the fifth item in the sidebar (listSubPages) if let SidebarEntry::ListSubPages(SubPageEntry { path, .. }) = &sb.sidebar[4] {