Skip to content

Commit

Permalink
small tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
matryer committed Aug 6, 2024
1 parent 187f6cc commit 4f6b025
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
5 changes: 2 additions & 3 deletions tools/sitegen/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ func generateDocs(ctx context.Context) ([]Article, error) {
return nil, err
}
for path, rel := range docs {
dest := filepath.Join(destFolder, rel)
filename := filepath.Base(path)
filename = strings.ToLower(filename[:len(filename)-2] + "html")
dest = filepath.Join(destFolder, filepath.Dir(rel), filename)
dest := filepath.Join(destFolder, filepath.Dir(rel), filename)
destFilename := filepath.Join(filepath.Dir(rel), filename)
err := g.parseArticleSource(ctx, destFilename, dest, path)
if err != nil {
Expand Down Expand Up @@ -153,7 +152,7 @@ func newDocsGenerator() (*docsGenerator, error) {
return g, nil
}

func (g *docsGenerator) parseArticleSource(ctx context.Context, path, dest, src string) error {
func (g *docsGenerator) parseArticleSource(_ context.Context, path, dest, src string) error {
fmt.Printf("parsing: %s\n", path)
pathSegs := strings.Split(path, string(filepath.Separator))
yearStr := pathSegs[0]
Expand Down
37 changes: 20 additions & 17 deletions tools/sitegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ func run(ctx context.Context, args []string) error {
fmt.Println("xbarapp.com site generator", version)
flags := flag.NewFlagSet(args[0], flag.ContinueOnError)
var (
out = flags.String("out", "../../xbarapp.com/public/docs", "output folder")
small = flags.Bool("small", false, "run only a small sample (default is to process all)")
skipdata = flags.Bool("skipdata", false, "skip the data - just render the index template")
errs = flags.Bool("errs", false, "print out error details")
nodocs = flags.Bool("nodocs", false, "skip docs generation")
verbose = flags.Bool("verbose", false, "verbose output")
out = flags.String("out", "../../xbarapp.com/public/docs", "output folder")
small = flags.Bool("small", false, "run only a small sample (default is to process all)")
skipdata = flags.Bool("skipdata", false, "skip the data - just render the index template")
shouldPrintErrs = flags.Bool("errs", false, "print out error details")
nodocs = flags.Bool("nodocs", false, "skip docs generation")
verbose = flags.Bool("verbose", false, "verbose output")
)
if err := flags.Parse(args[1:]); err != nil {
return err
Expand Down Expand Up @@ -80,7 +80,7 @@ func run(ctx context.Context, args []string) error {
EachPluginFn: eachPlugin,
GitHubAccessToken: os.Getenv("XBAR_GITHUB_ACCESS_TOKEN"),
SmallSample: *small,
PrintErrors: *errs,
PrintErrors: *shouldPrintErrs,
}
if !*skipdata {
if err := reader.All(ctx); err != nil {
Expand Down Expand Up @@ -145,7 +145,7 @@ func run(ctx context.Context, args []string) error {
go func() {
defer wg.Done()
if err := g.generatePluginsIndexPage(categories, pluginsByPath, featuredPlugins); err != nil {
if *errs == true {
if *shouldPrintErrs {
log.Println(errors.Wrap(err, "generatePluginsIndexPage"))
}
}
Expand All @@ -154,7 +154,7 @@ func run(ctx context.Context, args []string) error {
go func() {
defer wg.Done()
if err := g.generateCategoriesJSON(categories); err != nil {
if *errs == true {
if *shouldPrintErrs {
log.Println(errors.Wrap(err, "generateCategoriesJSON"))
}
}
Expand All @@ -163,7 +163,7 @@ func run(ctx context.Context, args []string) error {
go func() {
defer wg.Done()
if err := g.generateCategoryPluginsJSONFiles(categories, pluginsByPath); err != nil {
if *errs == true {
if *shouldPrintErrs {
log.Println(errors.Wrap(err, "generateCategoryPluginsJSONFiles"))
}
}
Expand All @@ -172,7 +172,7 @@ func run(ctx context.Context, args []string) error {
go func() {
defer wg.Done()
if err := g.generateCategoryPages(categories, categories, pluginsByPath); err != nil {
if *errs == true {
if *shouldPrintErrs {
log.Println(errors.Wrap(err, "generateCategoryPages"))
}
}
Expand All @@ -181,7 +181,7 @@ func run(ctx context.Context, args []string) error {
go func() {
defer wg.Done()
if err := g.generatePluginPages(categories, plugins); err != nil {
if *errs == true {
if *shouldPrintErrs {
log.Println(errors.Wrap(err, "generatePluginPages"))
}
}
Expand All @@ -190,7 +190,7 @@ func run(ctx context.Context, args []string) error {
go func() {
defer wg.Done()
if err := g.generateContributorPages(categories, pluginsByPath); err != nil {
if *errs == true {
if *shouldPrintErrs {
log.Println(errors.Wrap(err, "generateContributorPages"))
}
}
Expand All @@ -199,7 +199,7 @@ func run(ctx context.Context, args []string) error {
go func() {
defer wg.Done()
if err := g.generateFeaturedPluginsJSON(featuredPlugins); err != nil {
if *errs == true {
if *shouldPrintErrs {
log.Println(errors.Wrap(err, "generateFeaturedPluginsJSON"))
}
}
Expand All @@ -208,7 +208,7 @@ func run(ctx context.Context, args []string) error {
go func() {
defer wg.Done()
if err := g.generateContributorsPage(categories, plugins); err != nil {
if *errs == true {
if *shouldPrintErrs {
log.Println(errors.Wrap(err, "generateContributorsPage"))
}
}
Expand All @@ -227,13 +227,13 @@ func run(ctx context.Context, args []string) error {
if !*nodocs {
articles, err = generateDocs(ctx)
if err != nil {
if *errs == true {
if *shouldPrintErrs {
log.Println(errors.Wrap(err, "generateDocs"))
}
}
}
if err := g.generateSitemap(categories, pluginsByPath, articles, *out); err != nil {
if *errs == true {
if *shouldPrintErrs {
log.Println(errors.Wrap(err, "generateSitemap"))
}
}
Expand Down Expand Up @@ -423,6 +423,9 @@ func (g *generator) generateContributorPage(categories map[string]metadata.Categ
return err
}
g.peopleCycleIndex, err = peopleCycle.Print(os.Stdout, g.peopleCycleIndex)
if err != nil {
return err
}
fmt.Print()
return nil
}
Expand Down

0 comments on commit 4f6b025

Please sign in to comment.