Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glossary created as part of the report building, additional glossary … #34

Merged
merged 2 commits into from
Feb 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Requirements
------------
* Java 8

1.0.5
-----
* Single Maven plugin, glossary functionality moved into the same plugin that provides execution and report building,
original glossary-builder kept in place to avoid breakages. Removed XML variant of the Glossary in favour of json.


1.0.4
-----
* Added a checkbox to the report to optionally hide skipped steps
Expand Down
1 change: 1 addition & 0 deletions api/src/main/java/org/substeps/report/IReportBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
public interface IReportBuilder {

void buildFromDirectory(File sourceDataDir);
void buildFromDirectory(File sourceDataDir, File stepImplsJson);

}

This file was deleted.

7 changes: 7 additions & 0 deletions core/src/main/resources/static/css/glossary.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.dataTables_filter{
visibility:hidden;
}

#glossary-table_wrapper div.row-fluid:nth-of-type(1) {
display:none;
}
55 changes: 55 additions & 0 deletions core/src/main/resources/static/js/glossary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
$(document).ready(function() {

var glossaryTable = $('#glossary-table').DataTable({
paging: false,
searching: true,
"data": glossary,
"columns": [
{data: 'section', title: "Section"},
{data: 'expression', title: "Expression"},
{data: 'description', title: "Description"},
{data: 'example', title: "Example"}
],
"dom" : "<'row-fluid'<'col-sm-6'l><'col-sm-6'f>>" +
"<'row-fluid'<'col-sm-12'tr>>" +
"<'row-fluid'<'col-sm-5'i><'col-sm-7'p>>"
// ,
// sDom: '<"search-box"r><"H"lf>t<"F"ip>'
});

$('#glossarySearchField').keyup(function(){
glossaryTable.search($(this).val()).draw() ;
})




});





$('#substep-usage-show-hide').on('click', function () {

toggleShowHide(this);

});

$('#stepimpl-usage-show-hide').on('click', function () {

toggleShowHide(this);

});

function toggleShowHide(elem){
if ($(elem).text() == 'Hide') {
$(elem).text('Show')
}
else {
$(elem).text('Hide');
}
}



102 changes: 102 additions & 0 deletions core/src/main/scala/org/substeps/report/GlossaryTemplate.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package org.substeps.report

/**
* Created by ian on 06/02/17.
*/
trait GlossaryTemplate {

def buildGlossaryReport(dateTimeString :String) ={

s"""
<!DOCTYPE html>
<html lang="en">

<head>
<title>Substeps Glossary</title>
<meta charset="UTF-8">
<link href="css/bootstrap.min.css" rel="stylesheet"/>
<link href="css/bootstrap-responsive.min.css" rel="stylesheet"/>
<link href="css/datatables.css" rel="stylesheet"/>
<link href="css/substeps.css" rel="stylesheet"/>
<link href="css/glossary.css" rel="stylesheet"/>

</head>

<body>

<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">

<div class="navbar-header">
<span class="navbar-brand" href="#">Stepimplementations in scope</span>
<span class="navbar-brand" >${dateTimeString}</span>
</div>

<div class="collapse navbar-collapse">

<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="report_frame.html">Results Summary</a></li>
<li><a href="usage-tree.html">Usage <span class="label label-warning">Beta</span></a></li>
</ul>
</div>
</div>
</nav>

<noscript>
<h3>Please enable Javascript to view Test details</h3>
<p>Non java script variants of this report were not viable, sorry. We found that there was simply too much data to display and page load times were approaching unacceptable.</p>
<p>Please enable javascript and reload this page</p>
</noscript>

<div class="container-fluid" style="padding-top:10px">

<div class="panel panel-default">
<div class="panel-heading">

<div class="row-fluid">
<div class="col-md-3">
<h3 class="panel-title">Glossary</h3>
</div>
<div class="col-md-9">
<div class="row-fluid">
<div class="col-sm-2">
<label for="glossarySearchField">Search</label>
</div>
<div class="col-sm-10">
<input type="text" class="form-control" id="glossarySearchField" placeholder="search glossary">

</div>
</div>
</div>
</div>
</div>

<div class="panel-body">

<table class="table table-striped table-bordered display" id="glossary-table">
<thead>
<tr>
<th>Section</th>
<th>Expression</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
</table>
</div>
</div>
</div>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/datatables.min.js"></script>
<script type="text/javascript" src="glossary-data.js"></script>
<script type="text/javascript" src="js/glossary.js"></script>

</body>
</html>
"""

}
}
22 changes: 22 additions & 0 deletions core/src/main/scala/org/substeps/report/Model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,25 @@ case object State {
case class JsTreeNode(id : String, text: String, icon : String, children : Option[List[JsTreeNode]], state : State, li_attr : Option[Map[String,String]] = None)


case class StepImplDesc(expressions : List[StepDesc],className: String )

case class StepDesc(expression: String ,
regex: String ,
example: String ,
section: String ,
description: String ,
parameterNames: List[String] ,
parameterClassNames: List[String]
)

case class GlossaryElement(
section: String ,
expression: String ,

className: String,
regex: String ,
example: String ,
description: String ,
parameterNames: List[String] ,
parameterClassNames: List[String]
)
51 changes: 48 additions & 3 deletions core/src/main/scala/org/substeps/report/ReportBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ object ReportBuilder {
/**
* Created by ian on 30/06/16.
*/
class ReportBuilder extends IReportBuilder with ReportFrameTemplate with UsageTreeTemplate {
class ReportBuilder extends IReportBuilder with ReportFrameTemplate with UsageTreeTemplate with GlossaryTemplate {

@BeanProperty
var reportDir : File = new File(".")
Expand All @@ -89,8 +89,26 @@ class ReportBuilder extends IReportBuilder with ReportFrameTemplate with UsageTr
}
}

def buildGlossaryData(sourceJsonFile : File) = {
implicit val formats = Serialization.formats(NoTypeHints)

val data = read[List[StepImplDesc]](sourceJsonFile)

val glossaryElements =
data.map(sid => sid.expressions.map(sd => {
GlossaryElement(sd.section, sd.expression, sid.className, sd.regex, sd.example, sd.description, sd.parameterNames, sd.parameterClassNames)
})).flatten

glossaryElements
}

def buildFromDirectory(sourceDataDir: File): Unit = {
buildFromDirectory(sourceDataDir, null)
}

def buildFromDirectory(sourceDataDir: File, stepImplsJson : File): Unit = {



reportDir.mkdir()

Expand All @@ -116,10 +134,12 @@ class ReportBuilder extends IReportBuilder with ReportFrameTemplate with UsageTr

val stats : ExecutionStats = buildExecutionStats(srcData)

val localDate = LocalDateTime.ofInstant(Instant.ofEpochMilli(srcData._1.timestamp), ZoneId.systemDefault());
val dateTimeString = localDate.format(DateTimeFormatter.ofPattern("dd MMM yyyy HH:mm:ss"))



val reportFrameHtml = buildReportFrame(srcData._1, stats
)
val reportFrameHtml = buildReportFrame(srcData._1, stats, dateTimeString)


withWriter(reportFrameHTML, writer => writer.append(reportFrameHtml))
Expand All @@ -142,10 +162,35 @@ class ReportBuilder extends IReportBuilder with ReportFrameTemplate with UsageTr

withWriter(usgaeTreeHTMLFile, writer => writer.append(usageTreeHtml) )

createGlossary(stepImplsJson, dateTimeString)
}

def createGlossary(stepImplsJson : File, dateTimeString :String) = {

if (Option(stepImplsJson).isDefined) {
val glossaryHTML = createFile("glossary.html")
val glossaryContent = buildGlossaryReport(dateTimeString)

// TODO - pass in the path to step impls.json
val srcJsonFile = new File("/home/ian/projects/github/substeps-webdriver/target/classes/stepimplementations.json")

val glossaryData = buildGlossaryData(srcJsonFile)
val glossaryJsFile = createFile("glossary-data.js")
writeGlossaryJs(glossaryJsFile, glossaryData)

withWriter(glossaryHTML, writer => writer.append(glossaryContent))
}
}

def writeGlossaryJs(glossaryJSFile : File, glossaryData : List[GlossaryElement]) = {

withWriter(glossaryJSFile, writer => {
implicit val formats = Serialization.formats(NoTypeHints)
writer.append("var glossary=")
writer.append(writePretty(glossaryData))
writer.append(";\n")
})
}

def writeStatsJs(statsJsFile: File, stats: (List[Counters], List[Counters])) = {

Expand Down
Loading