Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Use Jinja2 templates for HTML generator #234
Previously, the HTML generator used
This adds Jinja2 as a hard dependency! However, that shouldn't be a problem when installing normally through pip or manually using the
The templates were moved to the
The row-level templates were folded into their main templates, and are no longer rendered separately.
Jinja does slow gcovr down a bit. When running the test suite on my computer, this went from ~21s to ~28s. Initializing Jinja lazily reduced this to ~23s which is probably an acceptable tradeoff. Note that the test suite is not representative of real-world use as it covers many small projects and probably over-emphasizes startup time.
Based on this change, improving the HTML should be easier. E.g. I want to add an option to store the CSS in a separate file and remove the inline CSS which (a) simplifies the HTML tests and (b) solves the Jenkins CSP problem (#125).
@@ Coverage Diff @@ ## master #234 +/- ## ========================================== + Coverage 84% 84.08% +0.07% ========================================== Files 11 11 Lines 1194 1200 +6 Branches 248 248 ========================================== + Hits 1003 1009 +6 Misses 131 131 Partials 60 60
Mar 18, 2018
added a commit
this pull request
Mar 18, 2018
Hi @fletort, the templates are not currently exposed to users but are loaded from the package data that is included in gcovr. Because all of this is internal, there is no documentation.
I'd be open to a PR that makes the templates configurable, but the HTML generation code is a bit of a mess. We'd have to define a clear and stable data model that is made available to the templates. I don't want to do that right now because I'm likely to change this data model in the medium future, e.g. to make the reports more themable via CSS (compare #25, #125, #277).
Related to this, the default templates need some love anyway. E.g. they are still using table-based layout. So far I have shied away from fixing that because a very large number of integration tests would have to be updated. The current templates were written to introduce the minimal amount of test changes. They were not designed to be extensible.
If you'd like to work on user-defined templates, please open an issue to discuss the proposed design of the command line flags, the template structure, and what kind of variables should be made available to the templates.