Skip to content

Commit 1dd69c1

Browse files
committed
added html comments to custom css/js tags
1 parent 77d5790 commit 1dd69c1

3 files changed

Lines changed: 39 additions & 4 deletions

File tree

TestStack.BDDfy/Processors/Reporters/Html/HtmlReportBuilder.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private void HtmlHead()
4141
{
4242
AddLine("<meta charset='utf-8'/>");
4343
EmbedCssFile(HtmlReportResources.BDDfy_css);
44-
EmbedCssFile(_viewModel.CustomStylesheet);
44+
EmbedCssFile(_viewModel.CustomStylesheet, HtmlReportResources.CustomStylesheetComment);
4545

4646
AddLine(string.Format("<title>BDDfy Test Result {0}</title>", DateTime.Now.ToShortDateString()));
4747
}
@@ -139,7 +139,7 @@ private void Footer()
139139

140140
AddLine("<script type='text/javascript' src='https://code.jquery.com/jquery-1.11.0.min.js'></script>");
141141
EmbedJavascriptFile(HtmlReportResources.BDDfy_js);
142-
EmbedJavascriptFile(_viewModel.CustomJavascript);
142+
EmbedJavascriptFile(_viewModel.CustomJavascript, HtmlReportResources.CustomJavascriptComment);
143143
}
144144

145145
private void AddStory(Story story)
@@ -264,20 +264,31 @@ private void AddLine(string line)
264264
_html.AppendLine(string.Empty.PadLeft(tabWidth) + line);
265265
}
266266

267-
private void EmbedCssFile(string cssContent)
267+
private void EmbedCssFile(string cssContent, string htmlComment = null)
268268
{
269269
using (OpenTag("<style type='text/css'>", HtmlTag.style))
270270
{
271+
AddHtmlComment(htmlComment);
271272
_html.AppendLine(cssContent);
272273
}
273274
}
274275

275-
private void EmbedJavascriptFile(string javascriptContent)
276+
private void EmbedJavascriptFile(string javascriptContent, string htmlComment = null)
276277
{
277278
using (OpenTag(HtmlTag.script))
278279
{
280+
AddHtmlComment(htmlComment);
279281
_html.AppendLine(javascriptContent);
280282
}
281283
}
284+
285+
private void AddHtmlComment(string htmlComment)
286+
{
287+
if (string.IsNullOrWhiteSpace(htmlComment))
288+
return;
289+
290+
_html.AppendFormat("/*{0}*/", htmlComment);
291+
_html.AppendLine();
292+
}
282293
}
283294
}

TestStack.BDDfy/Processors/Reporters/Html/HtmlReportResources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TestStack.BDDfy/Processors/Reporters/Html/HtmlReportResources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,10 @@
124124
<data name="BDDfy_js" type="System.Resources.ResXFileRef, System.Windows.Forms">
125125
<value>BDDfy.js;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
126126
</data>
127+
<data name="CustomJavascriptComment" xml:space="preserve">
128+
<value>If you drop a custom Javascript named BDDfyCustom.js in your output folder it gets embedded here. This way you can apply some custom Javascript logic to your html report.</value>
129+
</data>
130+
<data name="CustomStylesheetComment" xml:space="preserve">
131+
<value>If you drop a custom stylesheet named BDDfyCustom.css in your output folder it gets embedded here. This way you can apply some custom styles over your html report.</value>
132+
</data>
127133
</root>

0 commit comments

Comments
 (0)