1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

docs: remove dangling whitespaces (#1459)

* omit <nil> in parameter table

* remove additional whitespaces

* add newline

* remove whitespaces

* adjust test cases

* fix whitespaces
This commit is contained in:
Christopher Fenner 2020-04-24 21:48:28 +02:00 committed by GitHub
parent a728416e12
commit 1660f4df48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View File

@ -104,7 +104,7 @@ func readAndAdjustTemplate(docFile io.ReadCloser) string {
// Replaces the docGenDescription placeholder with content from the yaml
func docGenDescription(stepData config.StepData) string {
desc := "Description \n\n"
desc := "Description\n\n"
desc += stepData.Metadata.LongDescription
@ -129,7 +129,7 @@ func docGenParameters(stepData config.StepData) string {
// Replaces the docGenConfiguration placeholder with the content from the yaml
func docGenConfiguration(stepData config.StepData) string {
var conf = "We recommend to define values of step parameters via [config.yml file](../configuration.md). \n\n"
var conf = "We recommend to define values of step parameters via [config.yml file](../configuration.md).\n\n"
conf += "In following sections of the config.yml the configuration is possible:\n\n"
// create step configuration table
@ -141,13 +141,13 @@ func docGenConfiguration(stepData config.StepData) string {
func createParametersTable(parameters []config.StepParameters) string {
var table = "| name | mandatory | default | possible values |\n"
table += "| ------- | --------- | ------- | ------- |\n"
table += "| ---- | --------- | ------- | --------------- |\n"
m := combineEqualParametersTogether(parameters)
for _, param := range parameters {
if v, ok := m[param.Name]; ok {
table += fmt.Sprintf(" | %v | %v | %v | %v |\n ", param.Name, ifThenElse(param.Mandatory && param.Default == nil, "Yes", "No"), ifThenElse(v == "<nil>", "", v), possibleValuesToString(param.PossibleValues))
table += fmt.Sprintf("| %v | %v | %v | %v |\n", param.Name, ifThenElse(param.Mandatory && param.Default == nil, "Yes", "No"), ifThenElse(v == "<nil>", "", v), possibleValuesToString(param.PossibleValues))
delete(m, param.Name)
}
}
@ -162,7 +162,7 @@ func createParametersDetail(parameters []config.StepParameters) string {
for _, param := range parameters {
if _, ok := m[param.Name]; !ok {
if len(param.Description) > 0 {
detail += fmt.Sprintf(" * ` %v ` : %v \n ", param.Name, param.Description)
detail += fmt.Sprintf(" * `%v`: %v\n", param.Name, param.Description)
m[param.Name] = true
}
}
@ -192,7 +192,7 @@ func addExistingParameterWithCondition(param config.StepParameters, m map[string
for _, con := range param.Conditions {
if con.Params != nil {
for _, p := range con.Params {
m[param.Name] = fmt.Sprintf("%v <br> %v=%v:%v ", m[param.Name], p.Name, p.Value, param.Default)
m[param.Name] = fmt.Sprintf("%v<br>%v=%v: %v ", m[param.Name], p.Name, p.Value, param.Default)
}
}
}
@ -205,7 +205,7 @@ func addNewParameterWithCondition(param config.StepParameters, m map[string]stri
for _, con := range param.Conditions {
if con.Params != nil {
for _, p := range con.Params {
m[param.Name] += fmt.Sprintf("%v=%v:%v ", p.Name, p.Value, param.Default)
m[param.Name] += fmt.Sprintf("%v=%v: %v ", p.Name, p.Value, param.Default)
}
}
}
@ -215,14 +215,14 @@ func addNewParameterWithCondition(param config.StepParameters, m map[string]stri
func createConfigurationTable(parameters []config.StepParameters) string {
var table = "| parameter | general | step/stage |\n"
table += "|-----------|---------|------------|\n"
table += "| --------- | ------- | ---------- |\n"
for _, param := range parameters {
if len(param.Scope) > 0 {
general := contains(param.Scope, "GENERAL")
step := contains(param.Scope, "STEPS")
table += fmt.Sprintf(" | %v | %v | %v | \n ", param.Name, ifThenElse(general, "X", ""), ifThenElse(step, "X", ""))
table += fmt.Sprintf("| %v | %v | %v |\n", param.Name, ifThenElse(general, "X", ""), ifThenElse(step, "X", ""))
}
}

View File

@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/assert"
)
var expectedResultDocument string = "# testStep\n\n\t## Description \n\nLong Test description\n\n\t\n\t## Prerequisites\n\t\n\tnone\n\n\t\n\t\n\t## Parameters\n\n| name | mandatory | default | possible values |\n| ------- | --------- | ------- | ------- |\n | param0 | No | val0 | |\n | param1 | No | | |\n | param2 | Yes | | |\n \n\n## Details\n\n * ` param0 ` : param0 description \n * ` param1 ` : param1 description \n * ` param2 ` : param1 description \n \n\t\n\t## We recommend to define values of step parameters via [config.yml file](../configuration.md). \n\nIn following sections of the config.yml the configuration is possible:\n\n| parameter | general | step/stage |\n|-----------|---------|------------|\n | param0 | X | | \n | param1 | | | \n | param2 | | | \n \n\t\n\t## Side effects\n\t\n\tnone\n\t\n\t## Exceptions\n\t\n\tnone\n\t\n\t## Example\n\n\tnone\n"
var expectedResultDocument string = "# testStep\n\n\t## Description\n\nLong Test description\n\n\t\n\t## Prerequisites\n\t\n\tnone\n\n\t\n\t\n\t## Parameters\n\n| name | mandatory | default | possible values |\n| ---- | --------- | ------- | --------------- |\n| param0 | No | val0 | |\n| param1 | No | | |\n| param2 | Yes | | |\n\n\n## Details\n\n * `param0`: param0 description\n * `param1`: param1 description\n * `param2`: param1 description\n\n\t\n\t## We recommend to define values of step parameters via [config.yml file](../configuration.md).\n\nIn following sections of the config.yml the configuration is possible:\n\n| parameter | general | step/stage |\n| --------- | ------- | ---------- |\n| param0 | X | |\n| param1 | | |\n| param2 | | |\n\n\t\n\t## Side effects\n\t\n\tnone\n\t\n\t## Exceptions\n\t\n\tnone\n\t\n\t## Example\n\n\tnone\n"
func configMetaDataMock(name string) (io.ReadCloser, error) {
meta1 := `metadata:
@ -366,8 +366,8 @@ func TestAddNewParameterWithCondition(t *testing.T) {
x, want string
i int
}{
{"param0", "name0a=val0a:default0 name0b=val0b:default0", 0},
{"param1", "name1a=val1a:default1", 1},
{"param0", "name0a=val0a: default0 name0b=val0b: default0", 0},
{"param1", "name1a=val1a: default1", 1},
}
for _, c := range cases {
@ -389,7 +389,7 @@ func TestAddExistingParameterWithCondition(t *testing.T) {
cases := []struct {
x, want string
}{
{"param1", "name1a=val1a:default1 <br> name1b=val1b:default1"},
{"param1", "name1a=val1a: default1 <br>name1b=val1b: default1 "},
}
for _, c := range cases {