From 242959c9daf80306450dc48c23797c38cf3ded78 Mon Sep 17 00:00:00 2001 From: Katrina Owen Date: Sun, 30 Jul 2017 12:54:24 -0600 Subject: [PATCH] Fix linting complaints --- cmd/version.go | 1 + track/exercise_readme.go | 5 +++++ track/problem_specification.go | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/cmd/version.go b/cmd/version.go index 22ff751..47e1346 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -6,6 +6,7 @@ import ( "github.com/spf13/cobra" ) +// Version is the current version of the tool. const Version = "3.1.0" // versionCmd represents the version command diff --git a/track/exercise_readme.go b/track/exercise_readme.go index 9bce389..310aae8 100644 --- a/track/exercise_readme.go +++ b/track/exercise_readme.go @@ -22,6 +22,8 @@ var ( pathExerciseInsertDeprecated = "HINTS.md" ) +// ExerciseReadme contains the data necessary to generate a README +// for an Exercism exercise. type ExerciseReadme struct { Spec *ProblemSpecification Hints string @@ -31,6 +33,7 @@ type ExerciseReadme struct { dir string } +// NewExerciseReadme locates and reads all the data to create an ExerciseReadme. func NewExerciseReadme(root, trackID, slug string) (ExerciseReadme, error) { readme := ExerciseReadme{ trackDir: filepath.Join(root, trackID), @@ -58,6 +61,7 @@ func NewExerciseReadme(root, trackID, slug string) (ExerciseReadme, error) { return readme, nil } +// Generate produces a README from the template and data. func (readme ExerciseReadme) Generate() (string, error) { t, err := template.New("readme").Parse(readme.template) if err != nil { @@ -69,6 +73,7 @@ func (readme ExerciseReadme) Generate() (string, error) { return bb.String(), nil } +// Write generates and writes the README to a file. func (readme ExerciseReadme) Write() error { s, err := readme.Generate() if err != nil { diff --git a/track/problem_specification.go b/track/problem_specification.go index 20f02d6..6834de4 100644 --- a/track/problem_specification.go +++ b/track/problem_specification.go @@ -19,6 +19,7 @@ var ( ProblemSpecificationsPath string ) +// ProblemSpecification contains metadata describing an exercise. type ProblemSpecification struct { Slug string Description string @@ -31,6 +32,9 @@ type ProblemSpecification struct { specPath string } +// NewProblemSpecification loads the specification from files on disk. +// It will default to a custom specification, falling back to the generic specification +// if no custom one is found. func NewProblemSpecification(root, trackID, slug string) (*ProblemSpecification, error) { spec := &ProblemSpecification{ root: root, @@ -53,6 +57,7 @@ func (spec *ProblemSpecification) Name() string { return strings.Title(strings.Join(strings.Split(spec.Slug, "-"), " ")) } +// Credits are a markdown-formatted version of the source of the exercise. func (spec *ProblemSpecification) Credits() string { if spec.SourceURL == "" { return spec.Source