Skip to content

Commit

Permalink
Modify document generator to include GHA (SAP#5190)
Browse files Browse the repository at this point in the history
* include GHA in documentation

* add some missing GHA places

* add some missing GHA places

* Correct step description
  • Loading branch information
ashlymat authored Dec 3, 2024
1 parent 28fb2b7 commit e8d7450
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pkg/documentation/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -85,7 +86,7 @@ func main() {
OpenDocTemplateFile: openDocTemplateFile,
DocFileWriter: writeFile,
OpenFile: openFile,
}, includeAzure)
}, includeAzure, includeGHA)
checkError(err)
}
}
Expand Down
16 changes: 15 additions & 1 deletion pkg/documentation/generator/description.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = " "
)

Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions pkg/documentation/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit e8d7450

Please sign in to comment.