Skip to content

Commit fbf58ef

Browse files
committed
Refresh documentation (#39)
* minor documentation fixes * fix Hugo warnings * add openssf badge
1 parent fbbd039 commit fbf58ef

File tree

15 files changed

+22
-15
lines changed

15 files changed

+22
-15
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[![Go version](https://img.shields.io/github/go-mod/go-version/rjNemo/underscore?style=for-the-badge&logo=go)](https://pkg.go.dev/github.com/rjNemo/underscore)
55
![Go report](https://goreportcard.com/badge/github.com/rjNemo/underscore?style=for-the-badge)
66
![test coverage](https://img.shields.io/codecov/c/github/rjNemo/underscore?style=for-the-badge&logo=codecov)
7+
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9726/badge?style=for-the-badge)](https://www.bestpractices.dev/projects/9726)
78

89
![underscore](https://socialify.git.ci/rjNemo/underscore/image?description=1&font=KoHo&language=1&logo=https%3A%2F%2Fraw.githubusercontent.com%2FrjNemo%2Funderscore%2Fmain%2Fdocs%2Fstatic%2Flogo.png&owner=1&pattern=Floating%20Cogs&stargazers=1&theme=Dark)
910

docs/themes/hugo-geekdoc/layouts/partials/language.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{ if .Site.IsMultiLingual }}
1+
{{ if hugo.IsMultilingual }}
22
<span class="gdoc-language">
33
<ul class="gdoc-language__selector" role="button" aria-pressed="false" tabindex="0">
44
<li>

docs/themes/hugo-geekdoc/layouts/partials/microformats/opengraph.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@
6363
{{- end }}
6464

6565
{{- /* Facebook Page Admin ID for Domain Insights */}}
66-
{{- with .Site.Social.facebook_admin }}
66+
{{- with .Site.Params.facebook.adminID }}
6767
<meta property="fb:admins" content="{{ . }}" />
6868
{{- end }}

docs/themes/hugo-geekdoc/layouts/partials/microformats/twitter_cards.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
{{- with partial "utils/description" . }}
1111
<meta name="twitter:description" content="{{ . | plainify | htmlUnescape | chomp }}" />
1212
{{- end }}
13-
{{- with .Site.Social.twitter -}}
13+
{{- with .Site.Params.twitter -}}
1414
<meta name="twitter:site" content="@{{ . }}" />
1515
{{- end }}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/rjNemo/underscore
22

3-
go 1.23
3+
go 1.23.3
44

55
require (
66
github.com/stretchr/testify v1.8.4

join.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package underscore
22

3-
// Joins two slices together and returns a Tuple of [T, []P], the selectors allow you to pick the
3+
// Join joins two slices together and returns a Tuple of [T, []P], the selectors allow you to pick the
44
// keys you want to use from your struct's to join the sets together
55
func Join[T, P any, S comparable](
66
left []T,
@@ -18,7 +18,7 @@ func Join[T, P any, S comparable](
1818
return results
1919
}
2020

21-
// Joins two slices together and returns a []O where O is defined by the output
21+
// JoinProject joins two slices together and returns a []O where O is defined by the output
2222
// of your projection function
2323
// The selectors allow you to pick the keys from your structure to use as the join keys
2424
// While the projection functions allows you to reformat joined datasets

orderBy.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package underscore
22

3-
// Orders a slice by a field value within a struct, the predicate allows you
3+
// OrderBy orders a slice by a field value within a struct, the predicate allows you
44
// to pick the fields you want to orderBy. Use > for ASC or < for DESC
5-
// func (left Person, right Person) bool { return left.Age > right.Age }
5+
//
6+
// func (left Person, right Person) bool { return left.Age > right.Age }
67
func OrderBy[T any](list []T, predicate func(T, T) bool) []T {
78
swaps := true
89
var tmp T

pointers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package underscore
22

3-
// Convert values to pointers
3+
// ToPointer Convert values to pointers
44
//
55
// Instead of:
66
// v := "value"

range.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package underscore
22

3-
// Creates a sequence of numbers, i.e. u.Range(0, 3) = [0 1 2 3], while u.Range(3, 0) = [3 2 1 0]
3+
// Range creates a sequence of numbers, i.e. u.Range(0, 3) = [0 1 2 3], while u.Range(3, 0) = [3 2 1 0]
44
func Range(start int, end int) (result []int) {
55
if start < end {
66
for i := start; i <= end; i++ {

slices.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import (
66
"golang.org/x/exp/constraints"
77
)
88

9-
// sort any slice ASENDING
9+
// SortSliceASC sorts any slice ASCENDING
1010
func SortSliceASC[T constraints.Ordered](s []T) {
1111
sort.SliceStable(s, func(i, j int) bool {
1212
return s[i] < s[j]
1313
})
1414
}
1515

16-
// sort any slice DESCENDING
16+
// SortSliceDESC sorts any slice DESCENDING
1717
func SortSliceDESC[T constraints.Ordered](s []T) {
1818
sort.SliceStable(s, func(i, j int) bool {
1919
return s[i] > s[j]

sum.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ func Sum[T constraints.Ordered](values []T) (sum T) {
1010
return sum
1111
}
1212

13-
// Sums the values you select from your struct, basically a sort cut instead of
14-
// having to perform a u.Map followed by a u.Sum
13+
// SumMap sums the values you select from your struct, basically a sort cut instead of
14+
// having to perform a [Map] followed by a [Sum].
1515
func SumMap[T any, R constraints.Ordered](list []T, selector func(T) R) (sum R) {
1616
for _, v := range list {
1717
sum += selector(v)

ternary.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package underscore
22

3+
// Ternary returns the first argument if the condition is true, otherwise the second argument.
4+
// Ternary is a special form of the if statement. It allows you to write code that is more concise and less verbose.
35
func Ternary[T any](condition bool, pos, neg T) T {
46
if condition {
57
return pos

tuple.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package underscore
22

3+
// Tuple is a generic tuple type.
4+
// It is used to return multiple values from a function.
35
type Tuple[L, R any] struct {
46
Left L
57
Right R

unique.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package underscore
22

3+
// Unique returns a slice of unique values from the given slice.
34
func Unique[T comparable](values []T) (uniques []T) {
45
seen := make(map[T]bool, 0)
56
for _, v := range values {

zip.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package underscore
22

3-
// Zips two slices togther so all the elements of left slice are attached to the corresponding
3+
// Zip joins two slices together so all the elements of left slice are attached to the corresponding
44
// elements of the right slice, i.e. [one two three] [1 2 3 4] = [{one, 1} {two, 2} {three, 3}]
55
// the returned data will be the size of the smallest slice
66
func Zip[L any, R any](left []L, right []R) []Tuple[L, R] {

0 commit comments

Comments
 (0)