Open callendorph opened 1 year ago
Hi Carl,
Anything that goes in the header should be straight forward to add. If you look at the top of Report2Html, the file copy
below copies the file OsvvmLibraries/Scripts/summary_header_report.html to the the file FileName. Immediately after the file copy
additional header information could be added. The information added could be done by searching for ReportBuildName.css (or other name) in either the ${CurrentSimulationDirectory}
or in OsvvmLibraries/Scripts.
proc Report2Html {ReportFile} {
variable ResultsFile
variable ReportBuildName
set ReportFileRoot [file rootname $ReportFile]
set ReportBuildName [file tail $ReportFileRoot]
set FileName ${ReportFileRoot}.html
set Report2HtmlDict [::yaml::yaml2dict -file ${ReportFile}]
set ReportHeaderHtmlFile [file join ${::osvvm::OsvvmScriptDirectory} summary_header_report.html]
file copy -force ${ReportHeaderHtmlFile} ${FileName}
set ResultsFile [open ${FileName} a]
I am open to either collaborating or pull requests to add features such as this. We should hash through them here and perhaps prototype them (using manual edits to files) so we agree on the result.
I have not used a template engine before. Open to using one if it gets us something better than what we currently have. What is currently there is based on figuring out what I could do in the time that I had. I would need help with that.
I am on travel until July 7, so my response may be slow during this time.
Cheers, Jim
OK - I put together a very limited proof of concept here:
https://github.com/callendorph/OSVVM-Scripts/tree/issues/47_HTML_templating
With tcllib
installed, you should be able to run:
tclsh ReportTemplate.tcl > report.html
Keep in mind that:
textutil::expander
works but I didn't find too many examples.
expander
is probably not a trivial task.TEMPLATE_PATH
that would be searched for files matching a particular file name. Then the OSVMM-Scripts
directory could be the last directory searched so that the default template would always render.expander
configured to output an error message if there is a macro problem: <body>
<p> The answer is:
=================================
*** Error in macro at line 6, column 23:
*** [var_error msg]
--> invalid command name "var_error"
=================================
</p>
<H1> List Example </H1>
But there are other options.
I imagine it being something like this:
header_report.thtml
(note the t
for template), in the OSVVM-Scripts
repo.
Report2Html.tcl
changes a little
puts $ResultsFiles "<h2>$Report..."
gets moved to the template.Report2Html
passes a content
dict to the ApplyTemplate
function.
Report2HtmlDict
directly.content
dict.header_report.thtml
- it would look for user_report.thtml
.TEMPLATE_PATH
that contains:
OSVVM-Scripts
so that we can override those files. I think maybe the less ambitious feature would be:
Report2Html.tcl
at around line 59 some code to copy some user provided content into the <head>
section of the HTML file like you were mentioning at the top.<body>
as well if javascript is enabled in the viewer's browser.Hi Carl, I think we should start with the less ambitious feature and then pursue the additional features.
I have been on a 3 week business trip. I will be able to test out the code you pushed to your repository when I get back to the office on Monday.
Cheers, Jim
Hi Carl,
The 2023.07 release adds a less ambitious feature
. Additional HTML files were added, so the header files were renamed to get a clear association of their purpose. They are now named:
The default ones are in the OsvvmLibraries/Scripts directory. You can put replacement ones in your simulation directory. A prefix of the following form can be added to the above files to make them specific to a particular item: \<BuildName>_build_report_header.html \<TestCaseName>_simulation_header.html \<ReportName>_requirements_header.html
In the requirements header, ReportName
is either TestSuiteName
or BuildName
depending on the level of the report.
Best Regards, Jim
I checked the code of livejs. It doesn't support auto reload of local files (file://...
).
The 2024.0XDev (dev branch) updates this again. The files buil/d_report_header.html, simulation_header.html, and requirements_header.html have been replaced by CssOsvvmStyle.css.
In addition a user may add a file. Currently the name of the file is in Custom-Style.css, however, this is a work in progress.
Hi,
First - this whole project is great. It took some time to get up to speed but super impressive what you have put together.
I would like to customize the output HTML report. Things I would like to do are:
head
section.With the current implementation of
Report2Html.tcl
- I don't see a clear way to do that without modifying it and adding a bunch of code. Maybe I missed something ?In my ideal world - I would be to keep these project specific customizations in the Parent project that is leveraging this repo as a submodule or library.
Have you considered using a template engine for generating the HTML? Coming from Python, there are several template engines for generating HTML content formats (for example, Jinja). They do a really nice job of separating out the presentation layer from the data.
I'm not an expert in TCL but google seems to indicate there are a couple of TCL-based template engine options:
tcllib
(I've checked it is present intcllib
v1.20 package on ubuntu 22.04)Thoughts? Is this a reasonable path or have you tried this already and hic sunt dracones?