Skip to content

Commit 4f6b025

Browse files
committed
small tidy up
1 parent 187f6cc commit 4f6b025

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

tools/sitegen/docs.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ func generateDocs(ctx context.Context) ([]Article, error) {
7070
return nil, err
7171
}
7272
for path, rel := range docs {
73-
dest := filepath.Join(destFolder, rel)
7473
filename := filepath.Base(path)
7574
filename = strings.ToLower(filename[:len(filename)-2] + "html")
76-
dest = filepath.Join(destFolder, filepath.Dir(rel), filename)
75+
dest := filepath.Join(destFolder, filepath.Dir(rel), filename)
7776
destFilename := filepath.Join(filepath.Dir(rel), filename)
7877
err := g.parseArticleSource(ctx, destFilename, dest, path)
7978
if err != nil {
@@ -153,7 +152,7 @@ func newDocsGenerator() (*docsGenerator, error) {
153152
return g, nil
154153
}
155154

156-
func (g *docsGenerator) parseArticleSource(ctx context.Context, path, dest, src string) error {
155+
func (g *docsGenerator) parseArticleSource(_ context.Context, path, dest, src string) error {
157156
fmt.Printf("parsing: %s\n", path)
158157
pathSegs := strings.Split(path, string(filepath.Separator))
159158
yearStr := pathSegs[0]

tools/sitegen/main.go

+20-17
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ func run(ctx context.Context, args []string) error {
3737
fmt.Println("xbarapp.com site generator", version)
3838
flags := flag.NewFlagSet(args[0], flag.ContinueOnError)
3939
var (
40-
out = flags.String("out", "../../xbarapp.com/public/docs", "output folder")
41-
small = flags.Bool("small", false, "run only a small sample (default is to process all)")
42-
skipdata = flags.Bool("skipdata", false, "skip the data - just render the index template")
43-
errs = flags.Bool("errs", false, "print out error details")
44-
nodocs = flags.Bool("nodocs", false, "skip docs generation")
45-
verbose = flags.Bool("verbose", false, "verbose output")
40+
out = flags.String("out", "../../xbarapp.com/public/docs", "output folder")
41+
small = flags.Bool("small", false, "run only a small sample (default is to process all)")
42+
skipdata = flags.Bool("skipdata", false, "skip the data - just render the index template")
43+
shouldPrintErrs = flags.Bool("errs", false, "print out error details")
44+
nodocs = flags.Bool("nodocs", false, "skip docs generation")
45+
verbose = flags.Bool("verbose", false, "verbose output")
4646
)
4747
if err := flags.Parse(args[1:]); err != nil {
4848
return err
@@ -80,7 +80,7 @@ func run(ctx context.Context, args []string) error {
8080
EachPluginFn: eachPlugin,
8181
GitHubAccessToken: os.Getenv("XBAR_GITHUB_ACCESS_TOKEN"),
8282
SmallSample: *small,
83-
PrintErrors: *errs,
83+
PrintErrors: *shouldPrintErrs,
8484
}
8585
if !*skipdata {
8686
if err := reader.All(ctx); err != nil {
@@ -145,7 +145,7 @@ func run(ctx context.Context, args []string) error {
145145
go func() {
146146
defer wg.Done()
147147
if err := g.generatePluginsIndexPage(categories, pluginsByPath, featuredPlugins); err != nil {
148-
if *errs == true {
148+
if *shouldPrintErrs {
149149
log.Println(errors.Wrap(err, "generatePluginsIndexPage"))
150150
}
151151
}
@@ -154,7 +154,7 @@ func run(ctx context.Context, args []string) error {
154154
go func() {
155155
defer wg.Done()
156156
if err := g.generateCategoriesJSON(categories); err != nil {
157-
if *errs == true {
157+
if *shouldPrintErrs {
158158
log.Println(errors.Wrap(err, "generateCategoriesJSON"))
159159
}
160160
}
@@ -163,7 +163,7 @@ func run(ctx context.Context, args []string) error {
163163
go func() {
164164
defer wg.Done()
165165
if err := g.generateCategoryPluginsJSONFiles(categories, pluginsByPath); err != nil {
166-
if *errs == true {
166+
if *shouldPrintErrs {
167167
log.Println(errors.Wrap(err, "generateCategoryPluginsJSONFiles"))
168168
}
169169
}
@@ -172,7 +172,7 @@ func run(ctx context.Context, args []string) error {
172172
go func() {
173173
defer wg.Done()
174174
if err := g.generateCategoryPages(categories, categories, pluginsByPath); err != nil {
175-
if *errs == true {
175+
if *shouldPrintErrs {
176176
log.Println(errors.Wrap(err, "generateCategoryPages"))
177177
}
178178
}
@@ -181,7 +181,7 @@ func run(ctx context.Context, args []string) error {
181181
go func() {
182182
defer wg.Done()
183183
if err := g.generatePluginPages(categories, plugins); err != nil {
184-
if *errs == true {
184+
if *shouldPrintErrs {
185185
log.Println(errors.Wrap(err, "generatePluginPages"))
186186
}
187187
}
@@ -190,7 +190,7 @@ func run(ctx context.Context, args []string) error {
190190
go func() {
191191
defer wg.Done()
192192
if err := g.generateContributorPages(categories, pluginsByPath); err != nil {
193-
if *errs == true {
193+
if *shouldPrintErrs {
194194
log.Println(errors.Wrap(err, "generateContributorPages"))
195195
}
196196
}
@@ -199,7 +199,7 @@ func run(ctx context.Context, args []string) error {
199199
go func() {
200200
defer wg.Done()
201201
if err := g.generateFeaturedPluginsJSON(featuredPlugins); err != nil {
202-
if *errs == true {
202+
if *shouldPrintErrs {
203203
log.Println(errors.Wrap(err, "generateFeaturedPluginsJSON"))
204204
}
205205
}
@@ -208,7 +208,7 @@ func run(ctx context.Context, args []string) error {
208208
go func() {
209209
defer wg.Done()
210210
if err := g.generateContributorsPage(categories, plugins); err != nil {
211-
if *errs == true {
211+
if *shouldPrintErrs {
212212
log.Println(errors.Wrap(err, "generateContributorsPage"))
213213
}
214214
}
@@ -227,13 +227,13 @@ func run(ctx context.Context, args []string) error {
227227
if !*nodocs {
228228
articles, err = generateDocs(ctx)
229229
if err != nil {
230-
if *errs == true {
230+
if *shouldPrintErrs {
231231
log.Println(errors.Wrap(err, "generateDocs"))
232232
}
233233
}
234234
}
235235
if err := g.generateSitemap(categories, pluginsByPath, articles, *out); err != nil {
236-
if *errs == true {
236+
if *shouldPrintErrs {
237237
log.Println(errors.Wrap(err, "generateSitemap"))
238238
}
239239
}
@@ -423,6 +423,9 @@ func (g *generator) generateContributorPage(categories map[string]metadata.Categ
423423
return err
424424
}
425425
g.peopleCycleIndex, err = peopleCycle.Print(os.Stdout, g.peopleCycleIndex)
426+
if err != nil {
427+
return err
428+
}
426429
fmt.Print()
427430
return nil
428431
}

0 commit comments

Comments
 (0)