diff --git a/codegen/src/css.rs b/codegen/src/css.rs index 00029d5009..eae2d9cb63 100644 --- a/codegen/src/css.rs +++ b/codegen/src/css.rs @@ -1,6 +1,7 @@ use crate::workspace_path; use anyhow::Result; use indoc::{formatdoc, indoc}; +use std::cmp::Ordering; use std::fs; use syn_codegen::Definitions; @@ -30,17 +31,36 @@ pub fn generate(defs: &Definitions) -> Result<()> { } "}; for (ty, repr) in &defs.tokens { - let padding = ".".repeat((repr.len() + 8).saturating_sub(ty.len())); - styles += &formatdoc! {" + let macro_len = "Token![]".len() + repr.len(); + let ty_len = ty.len(); + styles.push('\n'); + styles += &match Ord::cmp(¯o_len, &ty_len) { + Ordering::Less => { + formatdoc! {" + a.struct[title=\"struct syn::token::{ty}\"] {{ + \tfont-size: calc(100% * {macro_len} / {ty_len}); + }} - a.struct[title=\"struct syn::token::{ty}\"]::before {{ - \tcontent: \"Token![{repr}]\"; - }} + a.struct[title=\"struct syn::token::{ty}\"]::before {{ + \tcontent: \"Token![{repr}]\"; + \tfont-size: calc(100% * {ty_len} / {macro_len}); + }} + "} + } + Ordering::Equal => unreachable!(), + Ordering::Greater => { + let padding = ".".repeat(macro_len.saturating_sub(ty.len())); + formatdoc! {" + a.struct[title=\"struct syn::token::{ty}\"]::before {{ + \tcontent: \"Token![{repr}]\"; + }} - a.struct[title=\"struct syn::token::{ty}\"]::after {{ - \tcontent: \"{padding}\"; - }} - "}; + a.struct[title=\"struct syn::token::{ty}\"]::after {{ + \tcontent: \"{padding}\"; + }} + "} + } + }; } let css_path = workspace_path::get("src/gen/token.css"); diff --git a/src/gen/token.css b/src/gen/token.css index 544319074c..7eb2cd6738 100644 --- a/src/gen/token.css +++ b/src/gen/token.css @@ -936,12 +936,13 @@ a.struct[title="struct syn::token::Typeof"]::after { content: "........"; } -a.struct[title="struct syn::token::Underscore"]::before { - content: "Token![_]"; +a.struct[title="struct syn::token::Underscore"] { + font-size: calc(100% * 9 / 10); } -a.struct[title="struct syn::token::Underscore"]::after { - content: ""; +a.struct[title="struct syn::token::Underscore"]::before { + content: "Token![_]"; + font-size: calc(100% * 10 / 9); } a.struct[title="struct syn::token::Union"]::before {