matusnovak/doxybook2

Refactor default templates to improve readability and generate less whitespace

brycelelbach opened this issue · 3 comments

Inja has a feature for trimming whitespace which could be used in the default templates. Anything of the form {{% ... -%}} will trim whitespace. Currently, the default templates tend to generate a lot of blank new lines in the generated markdown. This would also potentially make the default templates a bit neater to read as we wouldn't have to stick everything in an if/for block on a single line.

For example, my header.tmpl now looks like this:

---
{% if exists("title") -%}
title: {{title}}
{% else if exists("name") -%}
title: {{name}}
{% endif -%}
{% if exists("summary") -%}
summary: {{summary}}
{% endif -%}
{% include "meta" -%}
---

{% if exists("title") -%}
# {{title}}
{% else if exists("kind") and kind != "page" -%}
# {{name}} {{title(kind)}} Reference
{% endif -%}

Hi @brycelelbach

Yeah, this is something I am currently working on.

I was planning on using that feature, at the time when I started this project, but it was not working properly with inja version <3.0.0. Thankfully it is working fine now. I should be able to refactor this within couple of days.

Awesome!

Done, released here: https://github.com/matusnovak/doxybook2/releases/tag/v1.3.3

Not all unnecessary whitespace is gone, but 95% is fixed. There should be no more large \n gaps.

More work to be done though...