()
| 27 | } |
| 28 | |
| 29 | func main() { |
| 30 | functionRefContent := "\n\n" |
| 31 | globalFunctionRefContent := "\n\n" |
| 32 | pipelineFunctionRefContent := "\n\n" |
| 33 | functionRefFile := functionPartialBasePath + "reference.mdx" |
| 34 | globalFunctionRefFile := functionPartialBasePath + "reference_global.mdx" |
| 35 | pipelineFunctionRefFile := functionPartialBasePath + "reference_pipeline.mdx" |
| 36 | |
| 37 | groups := map[string]*util.Group{} |
| 38 | |
| 39 | for i := range Functions { |
| 40 | function := Functions[i] |
| 41 | |
| 42 | functionFile := fmt.Sprintf(functionPartialBasePath+"%s.mdx", function.Name) |
| 43 | pageContent := []byte{} |
| 44 | |
| 45 | partialImports := &[]string{} |
| 46 | flagContent := "" |
| 47 | |
| 48 | if function.Flags != nil { |
| 49 | flagRef := reflect.ValueOf(function.Flags).Type() |
| 50 | flagContent = getFlagReference(function.Name, functionFile, flagRef, partialImports, string(pageContent)) |
| 51 | } |
| 52 | |
| 53 | importContent := "" |
| 54 | for _, partialImport := range *partialImports { |
| 55 | importContent = importContent + util.GetPartialImport(partialImport, functionFile) |
| 56 | } |
| 57 | |
| 58 | err := os.MkdirAll(filepath.Dir(functionFile), os.ModePerm) |
| 59 | if err != nil { |
| 60 | panic(err) |
| 61 | } |
| 62 | |
| 63 | argEnum := "" |
| 64 | if function.ArgEnum != nil { |
| 65 | argEnum = `<span>` + strings.Join(function.ArgEnum, " ") + `</span>` |
| 66 | } |
| 67 | |
| 68 | anchorName := function.Name |
| 69 | functionContent := importContent + "\n" + fmt.Sprintf(util.TemplateFunctionRef, flagContent != "", "", "### ", function.Name, function.Args, argEnum, function.Return, !function.IsGlobal, anchorName, function.Description, flagContent) |
| 70 | |
| 71 | err = os.WriteFile(functionFile, []byte(functionContent), os.ModePerm) |
| 72 | if err != nil { |
| 73 | panic(err) |
| 74 | } |
| 75 | |
| 76 | partialImport := util.GetPartialImport(functionFile, functionRefFile) |
| 77 | partialUse := fmt.Sprintf(util.TemplatePartialUse, util.GetPartialImportName(function.Name)) |
| 78 | partialImportGlobal := partialImport |
| 79 | partialUseGlobal := partialUse |
| 80 | partialImportPipeline := partialImport |
| 81 | partialUsePipeline := partialUse |
| 82 | writeRef := true |
| 83 | writeGlobalRef := false |
| 84 | writePipelineRef := false |
| 85 | |
| 86 | if function.Group != "" { |
nothing calls this directly
no test coverage detected