rinja-rs / rinja

A template rendering engine based on Jinja, generating type-safe Rust code at compile time.
https://rinja.readthedocs.io
Apache License 2.0
107 stars 9 forks source link

Convert filter tests to use doc tests #185

Open Kijewski opened 5 days ago

Kijewski commented 5 days ago

Most built-in filter tests are invoked as normal functions: builtin.rs#L614-L817. It is good that the functions are tested at all, but it too bad that this kind of test cannot not serve as documentation. Some filters are doc-tested using rinja code blocks builtin.rs#L53-L72, so the user gets a proper usage example in the documentation. Also, many filters contain some logic in the generator, which has to be tested, too.

It would be nice if some, if not all, filters could be tested with doc tests:

Wollaston commented 3 days ago

I'd be interested in helping out with this one!

Please let me know if you are looking for new contributors and if so, if you would like me to just go through your checklist here top to bottom. My understanding is that you would like doctests added to these filters. Are we adding new tests, or just copying the regular tests to doctests? Thank you!

GuillaumeGomez commented 3 days ago

New contributors and contributions are very welcome! From what I can see, in case the filter isn't tested, then you need to create one. If one already exist, I think copying it might be enough.