Skip to content

Commit

Permalink
Summary improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
maximehamm committed Mar 25, 2021
1 parent 7162516 commit e838fe2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,12 @@ class TzExportAction : AnAction(), DumbAware {

override fun actionPerformed(event: AnActionEvent) {

//TODO : Customiser le titre du sommaire : "Table of contents"
//TODO : Parametrer ou faire des break : feature / rule /

//TODO : Numéroter / renuméroter les features
//TODO : Imprimer les features dans l'ordre de la numérotation
//TODO : Choisir et ordonner les features à exporter en PDF ?

//TODO Later : Set a parameter to decide whether or not to print the comments
//TODO Later : Traduire les mots clef au moment d'editer
//TODO Later : Renuméroter les scénario comme le plugin bidule

val project = event.getData(CommonDataKeys.PROJECT) ?: return
val vfiles = event.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY) ?: return
Expand Down
10 changes: 7 additions & 3 deletions plugin/src/main/kotlin/io/nimbly/tzatziki/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.intellij.openapi.updateSettings.impl.UpdateChecker.getNotificationGro
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiManager
import io.nimbly.tzatziki.pdf.ESummaryDepth
import io.nimbly.tzatziki.pdf.PdfStyle
import io.nimbly.tzatziki.pdf.Picture
import io.nimbly.tzatziki.util.TzatzikiException
Expand Down Expand Up @@ -300,13 +301,14 @@ fun createConfiguration(
bottomFontSize = get("export.bottomFontSize"),
dateFormat = get("export.dateFormat"),
summaryTitle = get("export.summary.title"),
summaryDepth = ESummaryDepth.valueOf(get("export.summary.depth")),
css = css,
picture = Picture("Tzatziki", picture, "svg"),
template = template,
frontpage = frontpage)
}

open class Config(
class Config(
val topFontSize: String,
val bottomFontSize: String,

Expand All @@ -325,6 +327,7 @@ open class Config(
val picture: Picture,
val template: String,
val summaryTitle: String,
val summaryDepth: ESummaryDepth,

val frontpage: Map<String, String>) {

Expand All @@ -341,15 +344,16 @@ open class Config(
bottomRight = tune(bottomRight),
dateFormat = tune(dateFormat),
contentStyle = css,
summaryDepth = summaryDepth,
first = PdfStyle(
topLeft = "", topCenter="", topRight = "",
bottomLeft = "", bottomCenter = "", bottomRight = "",
topFontSize = tune(bottomFontSize), bottomFontSize = tune(bottomFontSize), bodyFontSize = "32px",
summaryDepth = summaryDepth,
dateFormat = tune(dateFormat), contentStyle = css)
)
}

private fun tune(field: String) =
field.replace("now()", now().format(DateTimeFormatter.ofPattern(dateFormat)))
}

}
3 changes: 2 additions & 1 deletion plugin/src/main/kotlin/io/nimbly/tzatziki/pdf/PdfBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PdfBuilder(private val style: PdfStyle) {
private var sb = StringBuilder()
private var out = StringBuilder()
private var isSummaryInserted = false
private val summary = PdfSummary()
private val summary = PdfSummary(style.summaryDepth)

fun addSummaryEntry(level: Int, label: String) {
summary.addEntry(level, label)
Expand Down Expand Up @@ -114,6 +114,7 @@ open class PdfStyle(
var bottomRight: String,
var dateFormat: String,
var contentStyle: String,
val summaryDepth: ESummaryDepth,
var first: PdfStyle? = null) {

private val defaultPagePdfStyle = """
Expand Down
17 changes: 12 additions & 5 deletions plugin/src/main/kotlin/io/nimbly/tzatziki/pdf/PdfSummary.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ package io.nimbly.tzatziki.pdf

import io.nimbly.tzatziki.util.pop

class PdfSummary(
private val idName: String = "t",
private val initialIndent: String = "",
private val indent: String = " ")
{
class PdfSummary(val depth: ESummaryDepth) {
private val idName: String = "t"
private val initialIndent: String = ""
private val indent: String = " "
private var table = mutableListOf<TableEntry>()
private var output = StringBuilder()
private var idIndex = 0
Expand All @@ -41,6 +40,8 @@ class PdfSummary(
}

fun addEntry(level: Int, label: String) {
if (level > depth.value)
return
when {
level > table.size ->
throw Exception("Missing table of contents level : " +
Expand Down Expand Up @@ -88,4 +89,10 @@ private class TableEntry(val label: String, val id: String) {
override fun toString(): String {
return "$id - $label"
}
}

enum class ESummaryDepth(val value: Int) {
Feature(1),
Rule(2),
Scenario(3)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export.frontpage.description=Lorem ipsum dolor sit amet, consectetur adipiscing
# Export to Pdf summary
export.summary.title=<br/><h3>Table of contents :</h3><br/><br/>

# Export to Pdf summary depth : Feature, Rule, Scenario
export.summary.depth=Scenario

# Export to Pdf header
export.topLeft=Nimbly
export.topCenter=
Expand Down

0 comments on commit e838fe2

Please sign in to comment.