Skip to content

Commit

Permalink
chore: apply suggestions from code review (batch 1)
Browse files Browse the repository at this point in the history
Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
Signed-off-by: Atomys <contact@atomys.fr>
  • Loading branch information
42atomys and ccoVeille authored Nov 27, 2024
1 parent 26c7b38 commit 8139211
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
11 changes: 5 additions & 6 deletions tools/docvalidator/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package main provides a utility to process markdown documentation files,
// extract code examples, execute them, and verify their outputs.
// extracts code examples, executes them, and verifies their outputs.
package main

import (
Expand Down Expand Up @@ -82,8 +82,8 @@ func run(fs FileSystem) error {
})

if len(files) == 0 {
slog.Error("No markdown files found in docs directory.")
return fmt.Errorf("no markdown files found in docs directory")
slog.Error("No Markdown files found in docs directory.")
return fmt.Errorf("no Markdown files found in docs directory")
}

var examples []Example
Expand Down Expand Up @@ -118,10 +118,9 @@ func run(fs FileSystem) error {
if errCount > 0 {
slog.Error("Failed to process some examples", "count", errCount)
return fmt.Errorf("failed to process %d examples", errCount)
} else {
slog.Info("All examples processed successfully")
return nil
}
slog.Info("All examples processed successfully")
return nil
}

// filterFiles filters out unwanted files from the provided list of files.
Expand Down
4 changes: 2 additions & 2 deletions tools/docvalidator/parsing.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

// extractExamples scans the content of a markdown file and extracts code examples.
// It returns a slice of Example structs, each representing a code example found in the content.
// This function is used to parse markdown files and find code examples under specific headings.
// It returns a slice of [Example] structs, each representing a code example found in the content.
// This function is used to parse Markdown files and find code examples under specific headings.
func extractExamples(content, filePath string) []Example {
var examples []Example

Expand Down
3 changes: 0 additions & 3 deletions tools/docvalidator/processing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func TestProcessExample_ErrorExceptedButNoError(t *testing.T) {
Expected: "Error",
}
err := processExample(example)
require.Error(t, err)
assert.ErrorContains(t, err, "expected an error but the template executed successfully")
}

Expand All @@ -85,7 +84,6 @@ func TestProcessExample_ErrorUnexpected(t *testing.T) {
Expected: "1",
}
err := processExample(example)
require.Error(t, err)
assert.ErrorContains(t, err, "unexpected error during template execution")
}

Expand All @@ -100,6 +98,5 @@ func TestProcessExample_OutputMismatch(t *testing.T) {
Expected: "Hello, World!",
}
err := processExample(example)
require.Error(t, err)
assert.ErrorContains(t, err, "output mismatch")
}

0 comments on commit 8139211

Please sign in to comment.