1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-04-11 11:41:53 +02:00

Modify document generator to include GHA (#5190)

* include GHA in documentation

* add some missing GHA places

* add some missing GHA places

* Correct step description
This commit is contained in:
Ashly Mathew 2024-12-03 11:01:48 +01:00 committed by GitHub
parent 28fb2b77bf
commit e8d745052a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 5 deletions

View File

@ -32,12 +32,13 @@ func main() {
var docTemplatePath string
var customLibraryStepFile string
var customDefaultFiles sliceFlags
var includeAzure bool
var includeAzure, includeGHA bool
flag.StringVar(&metadataPath, "metadataDir", "./resources/metadata", "The directory containing the step metadata. Default points to \\'resources/metadata\\'.")
flag.StringVar(&docTemplatePath, "docuDir", "./documentation/docs/steps/", "The directory containing the docu stubs. Default points to \\'documentation/docs/steps/\\'.")
flag.StringVar(&customLibraryStepFile, "customLibraryStepFile", "", "")
flag.Var(&customDefaultFiles, "customDefaultFile", "Path to a custom default configuration file.")
flag.BoolVar(&includeAzure, "includeAzure", false, "Include Azure-specifics in step documentation.")
flag.BoolVar(&includeGHA, "includeGHA", false, "Include GitHub Actions-specifics in step documentation.")
// flags for stage documentation
var generateStageConfig bool
@ -85,7 +86,7 @@ func main() {
OpenDocTemplateFile: openDocTemplateFile,
DocFileWriter: writeFile,
OpenFile: openFile,
}, includeAzure)
}, includeAzure, includeGHA)
checkError(err)
}
}

View File

@ -13,7 +13,8 @@ const (
headlineUsage = "## Usage\n\n"
headlineJenkinsPipeline = " === \"Jenkins\"\n\n"
headlineCommandLine = " === \"Command Line\"\n\n"
headlineAzure = " === \"Azure\"\n\n"
headlineAzure = " === \"Azure DevOps\"\n\n"
headlineGHA = " === \"GitHub Actions\"\n\n"
spacingTabBox = " "
)
@ -67,6 +68,19 @@ func createDescriptionSection(stepData *config.StepData) string {
description += fmt.Sprintf("%v```\n\n", spacingTabBox)
}
// add GiHub Actions specific information if activated
if includeGHA {
description += headlineGHA
description += fmt.Sprintf("%v```\n", spacingTabBox)
description += fmt.Sprintf("%vsteps:\n", spacingTabBox)
description += fmt.Sprintf("%v - name: your preferred name for the step\n", spacingTabBox)
description += fmt.Sprintf("%v uses: SAP/project-piper-action@main\n", spacingTabBox)
description += fmt.Sprintf("%v with:\n", spacingTabBox)
description += fmt.Sprintf("%v step-name: %v\n", spacingTabBox, stepData.Metadata.Name)
description += fmt.Sprintf("%v flags: --anyStepParameter\n", spacingTabBox)
description += fmt.Sprintf("%v```\n\n", spacingTabBox)
}
// add command line information
description += headlineCommandLine
description += fmt.Sprintf("%v```sh\n", spacingTabBox)

View File

@ -25,7 +25,7 @@ type DocuHelperData struct {
}
var stepParameterNames []string
var includeAzure bool
var includeAzure, includeGHA bool
func readStepConfiguration(stepMetadata config.StepData, customDefaultFiles []string, docuHelperData DocuHelperData) config.StepConfig {
filters := stepMetadata.GetParameterFilters()
@ -58,8 +58,9 @@ func readStepConfiguration(stepMetadata config.StepData, customDefaultFiles []st
}
// GenerateStepDocumentation generates step coding based on step configuration provided in yaml files
func GenerateStepDocumentation(metadataFiles []string, customDefaultFiles []string, docuHelperData DocuHelperData, azure bool) error {
func GenerateStepDocumentation(metadataFiles []string, customDefaultFiles []string, docuHelperData DocuHelperData, azure bool, githubAction bool) error {
includeAzure = azure
includeGHA = githubAction
for key := range metadataFiles {
stepMetadata := readStepMetadata(metadataFiles[key], docuHelperData)