Skip to content

Commit f29efa9

Browse files
Added minimal lines length for documentation generation
1 parent b67b9c6 commit f29efa9

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

cli/cli.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func (c *Cli) parseGenerateArgs() {
113113
lang := generateDocsCmd.String("language", "", "Programming language: JavaScript, Java, Kotlin")
114114
replace := generateDocsCmd.Bool("replace", false, "Determines if the existing documentations are replaced")
115115
codePath := generateDocsCmd.String("codepath", "", "The codepath to match.")
116+
minimalLinesLength := generateDocsCmd.Int("minimal-lines-length", 0, "The minimal lines complexity.")
116117
endpoint := generateDocsCmd.String("endpoint", "", "The endpoint name.")
117118
failFast := generateDocsCmd.Bool("fail-fast", true, "Whether to stop on error.")
118119

@@ -142,7 +143,7 @@ func (c *Cli) parseGenerateArgs() {
142143

143144
files := generateDocsCmd.Args()[0:]
144145

145-
if err := c.generateDocumentation(cl, lang, replace, codePath, failFast, files); err != nil {
146+
if err := c.generateDocumentation(cl, lang, replace, codePath, minimalLinesLength, failFast, files); err != nil {
146147
c.logger.Errorf("Could not generate the documentation %v", err)
147148
}
148149
break
@@ -224,7 +225,7 @@ func (c *Cli) generateCode(cl client.Client, lang *string, replace *bool, codePa
224225
return err
225226
}
226227

227-
output, err := c.process(cl, client.ModeCode, *lang, *replace, codePath, model, source)
228+
output, err := c.process(cl, client.ModeCode, *lang, *replace, codePath, nil, model, source)
228229
if err != nil {
229230
if !c.isFailFast(failFast) {
230231
c.logger.Errorf("Failed to process file %s %v", file, err)
@@ -245,7 +246,7 @@ func (c *Cli) generateCode(cl client.Client, lang *string, replace *bool, codePa
245246
})
246247
}
247248

248-
func (c *Cli) generateDocumentation(cl client.Client, lang *string, replace *bool, codePath *string, failFast *bool, files []string) error {
249+
func (c *Cli) generateDocumentation(cl client.Client, lang *string, replace *bool, codePath *string, minimalLinesLength *int, failFast *bool, files []string) error {
249250
return c.walkPath(files, func(file string) error {
250251
if lang == nil || len(*lang) == 0 {
251252
actLang, err := languageFromExtension(filepath.Ext(file))
@@ -269,7 +270,7 @@ func (c *Cli) generateDocumentation(cl client.Client, lang *string, replace *boo
269270
return err
270271
}
271272

272-
output, err := c.process(cl, client.ModeDocument, *lang, *replace, codePath, nil, source)
273+
output, err := c.process(cl, client.ModeDocument, *lang, *replace, codePath, minimalLinesLength, nil, source)
273274
if err != nil {
274275
if !c.isFailFast(failFast) {
275276
c.logger.Errorf("Failed to process file %s %v", file, err)
@@ -314,7 +315,7 @@ func (c *Cli) fixSyntax(cl client.Client, lang *string, failFast *bool, files []
314315
return nil
315316
}
316317

317-
output, err := c.process(cl, client.ModeFixSyntax, *lang, false, nil, nil, source)
318+
output, err := c.process(cl, client.ModeFixSyntax, *lang, false, nil, nil, nil, source)
318319
if err != nil {
319320
if !c.isFailFast(failFast) {
320321
c.logger.Errorf("Failed to process file %s %v", file, err)
@@ -334,7 +335,7 @@ func (c *Cli) fixSyntax(cl client.Client, lang *string, failFast *bool, files []
334335
})
335336
}
336337

337-
func (c *Cli) process(cl client.Client, mode string, lang string, replace bool, codePath *string, model *string, source string) (*string, error) {
338+
func (c *Cli) process(cl client.Client, mode string, lang string, replace bool, codePath *string, minimalLinesLength *int, model *string, source string) (*string, error) {
338339
ctx := context.Background()
339340

340341
modify := client.ModifyNone
@@ -346,16 +347,23 @@ func (c *Cli) process(cl client.Client, mode string, lang string, replace bool,
346347
codePath = nil
347348
}
348349

350+
var optMinimalLinesLength *int32 = nil
351+
if minimalLinesLength != nil && *minimalLinesLength != 0 {
352+
val := int32(*minimalLinesLength)
353+
optMinimalLinesLength = &val
354+
}
355+
349356
process, err := cl.Process(ctx, &client.ProcessRequest{
350357
Mode: mode,
351358
Language: lang,
352359
Input: client.Input{
353360
Source: source,
354361
},
355362
Options: &client.Options{
356-
Modify: &modify,
357-
CodePath: codePath,
358-
Model: model,
363+
Modify: &modify,
364+
CodePath: codePath,
365+
Model: model,
366+
MinimalLinesLength: optMinimalLinesLength,
359367
},
360368
})
361369
if err != nil {

0 commit comments

Comments
 (0)