(functionName, functionFile string, flagRef reflect.Type, partialImports *[]string, pageContent string)
| 179 | } |
| 180 | |
| 181 | func getFlagReference(functionName, functionFile string, flagRef reflect.Type, partialImports *[]string, pageContent string) string { |
| 182 | flagPartialContent := "" |
| 183 | |
| 184 | for i := 0; i < flagRef.NumField(); i++ { |
| 185 | flag := flagRef.Field(i) |
| 186 | if flag.Anonymous { |
| 187 | flagPartialContent = flagPartialContent + getFlagReference(functionName, functionFile, flag.Type, partialImports, pageContent) |
| 188 | continue |
| 189 | } |
| 190 | |
| 191 | long := flag.Tag.Get("long") |
| 192 | if long == "" { |
| 193 | continue |
| 194 | } |
| 195 | |
| 196 | short := flag.Tag.Get("short") |
| 197 | description := flag.Tag.Get("description") |
| 198 | |
| 199 | if short != "" { |
| 200 | short = " / -" + short |
| 201 | } |
| 202 | |
| 203 | anchorName := functionName + "-" + long |
| 204 | flagContent := fmt.Sprintf(util.TemplateFunctionRef, false, "", "#### ", "--"+long+short, flag.Type.String(), "", "", false, anchorName, description, "") |
| 205 | |
| 206 | flagFile := fmt.Sprintf(functionPartialBasePath+"%s/%s.mdx", functionName, long) |
| 207 | err := os.MkdirAll(filepath.Dir(flagFile), os.ModePerm) |
| 208 | if err != nil { |
| 209 | panic(err) |
| 210 | } |
| 211 | |
| 212 | err = os.WriteFile(flagFile, []byte(flagContent), os.ModePerm) |
| 213 | if err != nil { |
| 214 | panic(err) |
| 215 | } |
| 216 | |
| 217 | flagPartialContent = flagPartialContent + fmt.Sprintf(util.TemplatePartialUse, util.GetPartialImportName(flagFile)) |
| 218 | *partialImports = append(*partialImports, flagFile) |
| 219 | } |
| 220 | |
| 221 | return flagPartialContent |
| 222 | } |
| 223 | |
| 224 | const groupImages = "Images" |
| 225 | const groupDeployments = "Deployments" |
no test coverage detected