Open jbirnick opened 7 months ago
Good catch, seems to be a bug with the docs generator.
This is mostly an issue in the implementation of the Repr
trait, it gets auto generated for every element and is... not great. We could certainly improve it, I might open a PR doing just that for these specific use cases.
If the goal is to have eval(repr(element)) == element
in most case which I think would be pretty neat then we have a number of problems :
#repr( bool ) == boolean
where it should be bool
#repr( repeat[] ) == repeat(body: [] )
where it should be repeat( [] )emph
, strong
and many builtin functions I assumeThe simplest fix would be to modify
/// Creates the element's `Repr` implementation.
fn create_repr_impl(element: &Elem) -> TokenStream {
let ident = &element.ident;
let repr_format = format!("{}{{}}", element.name);
quote! {
impl #foundations::Repr for #ident {
fn repr(&self) -> ::ecow::EcoString {
let fields = #foundations::NativeElement::fields(self).into_iter()
.map(|(name, value)| ::ecow::eco_format!("{}: {}", name, value.repr()))
.collect::<Vec<_>>();
::ecow::eco_format!(#repr_format, #foundations::repr::pretty_array_like(&fields, false))
}
}
}
}
So as to add an exception when the name of the field is body, and inline that directly instead. I don't really see a reason to not to that?
To fix the types, I would switch to using short_name instead of long name as the output of representation
For
#outline
there is afill
argument. In the docs it says:However,
repeat(body: [.])
appears to be not valid Typst syntax. (I get an error that the argument is positional.) I think it should berepeat[.]
.