Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions hack/update-doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ ROOT_DIR="$SCRIPT_DIR"/..

cd "$ROOT_DIR"

for i in $(ls pkg/)
do $(go env GOPATH)/bin/gomarkdoc \
--repository.url=https://github.com/dashjay/xiter \
--repository.default-branch=main \
./pkg/$i/... \
--output \
./pkg/$i/README.md
done
while IFS= read -r -d '' dir; do
i=$(basename "$dir")
[[ "$i" == "hack" || "$i" == "doc" || "$i" == ".git" ]] && continue
$(go env GOPATH)/bin/gomarkdoc \
--repository.url=https://github.com/dashjay/xiter \
--repository.default-branch=main \
./$i/... \
--output \
./$i/README.md
done < <(find . -maxdepth 1 -type d -not -name '.' -print0)
36 changes: 36 additions & 0 deletions hack/verify-doc.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail
set -o errtrace

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
ROOT_DIR="$SCRIPT_DIR"/..

cd "$ROOT_DIR"

# Generate docs into a temp directory and diff against committed docs
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT

while IFS= read -r -d '' dir; do
i=$(basename "$dir")
[[ "$i" == "hack" || "$i" == "doc" || "$i" == ".git" ]] && continue
mkdir -p "$tmpdir/$i"
$(go env GOPATH)/bin/gomarkdoc \
--repository.url=https://github.com/dashjay/xiter \
--repository.default-branch=main \
./$i/... \
--output \
"$tmpdir/$i/README.md"
if [ -f "$tmpdir/$i/README.md" ]; then
if ! diff -q "./$i/README.md" "$tmpdir/$i/README.md" &>/dev/null; then
echo "ERROR: $i/README.md is out of date. Run hack/update-doc.sh to regenerate."
diff "./$i/README.md" "$tmpdir/$i/README.md"
exit 1
fi
fi
done < <(find . -maxdepth 1 -type d -not -name '.' -print0)

echo "All docs are up to date."
18 changes: 9 additions & 9 deletions pkg/internal/README.md → internal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# constraints

```go
import "github.com/dashjay/xiter/pkg/internal/constraints"
import "github.com/dashjay/xiter/internal/constraints"
```

Package constraints defined constraints for generics tools
Expand All @@ -17,7 +17,7 @@ Package constraints defined constraints for generics tools


<a name="Float"></a>
## type [Float](<https://github.com/dashjay/xiter/blob/main/pkg/internal/constraints/constraints.go#L4-L6>)
## type [Float](<https://github.com/dashjay/xiter/blob/main/internal/constraints/constraints.go#L4-L6>)



Expand All @@ -28,7 +28,7 @@ type Float interface {
```

<a name="Integer"></a>
## type [Integer](<https://github.com/dashjay/xiter/blob/main/pkg/internal/constraints/constraints.go#L8-L10>)
## type [Integer](<https://github.com/dashjay/xiter/blob/main/internal/constraints/constraints.go#L8-L10>)



Expand All @@ -39,7 +39,7 @@ type Integer interface {
```

<a name="Number"></a>
## type [Number](<https://github.com/dashjay/xiter/blob/main/pkg/internal/constraints/constraints.go#L12-L14>)
## type [Number](<https://github.com/dashjay/xiter/blob/main/internal/constraints/constraints.go#L12-L14>)



Expand All @@ -50,7 +50,7 @@ type Number interface {
```

<a name="Ordered"></a>
## type [Ordered](<https://github.com/dashjay/xiter/blob/main/pkg/internal/constraints/constraints.go#L16-L18>)
## type [Ordered](<https://github.com/dashjay/xiter/blob/main/internal/constraints/constraints.go#L16-L18>)



Expand All @@ -63,7 +63,7 @@ type Ordered interface {
# utils

```go
import "github.com/dashjay/xiter/pkg/internal/utils"
import "github.com/dashjay/xiter/internal/utils"
```

## Index
Expand All @@ -72,7 +72,7 @@ import "github.com/dashjay/xiter/pkg/internal/utils"


<a name="IsZero"></a>
## func [IsZero](<https://github.com/dashjay/xiter/blob/main/pkg/internal/utils/utils.go#L3>)
## func [IsZero](<https://github.com/dashjay/xiter/blob/main/internal/utils/utils.go#L3>)

```go
func IsZero[T comparable](v T) bool
Expand All @@ -83,7 +83,7 @@ func IsZero[T comparable](v T) bool
# xassert

```go
import "github.com/dashjay/xiter/pkg/internal/xassert"
import "github.com/dashjay/xiter/internal/xassert"
```

## Index
Expand All @@ -92,7 +92,7 @@ import "github.com/dashjay/xiter/pkg/internal/xassert"


<a name="MustBePositive"></a>
## func [MustBePositive](<https://github.com/dashjay/xiter/blob/main/pkg/internal/xassert/xassert.go#L9>)
## func [MustBePositive](<https://github.com/dashjay/xiter/blob/main/internal/xassert/xassert.go#L9>)

```go
func MustBePositive[T constraints.Number](in T)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package xassert
import (
"fmt"

"github.com/dashjay/xiter/pkg/internal/constraints"
"github.com/dashjay/xiter/internal/constraints"
)

func MustBePositive[T constraints.Number](in T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package xassert_test
import (
"testing"

"github.com/dashjay/xiter/pkg/internal/xassert"
"github.com/dashjay/xiter/internal/xassert"
"github.com/stretchr/testify/assert"
)

Expand Down
20 changes: 10 additions & 10 deletions pkg/optional/README.md → optional/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# optional

```go
import "github.com/dashjay/xiter/pkg/optional"
import "github.com/dashjay/xiter/optional"
```

Package optional provides a type which can be used to represent a value that may or may not be present like option in Rust.
Expand All @@ -22,7 +22,7 @@ Package optional provides a type which can be used to represent a value that may


<a name="O"></a>
## type [O](<https://github.com/dashjay/xiter/blob/main/pkg/optional/optional.go#L5-L8>)
## type [O](<https://github.com/dashjay/xiter/blob/main/optional/optional.go#L5-L8>)



Expand All @@ -33,7 +33,7 @@ type O[T any] struct {
```

<a name="Empty"></a>
### func [Empty](<https://github.com/dashjay/xiter/blob/main/pkg/optional/optional.go#L27>)
### func [Empty](<https://github.com/dashjay/xiter/blob/main/optional/optional.go#L27>)

```go
func Empty[T any]() O[T]
Expand All @@ -42,7 +42,7 @@ func Empty[T any]() O[T]
Empty creates an empty Optional with no value.

<a name="FromValue"></a>
### func [FromValue](<https://github.com/dashjay/xiter/blob/main/pkg/optional/optional.go#L11>)
### func [FromValue](<https://github.com/dashjay/xiter/blob/main/optional/optional.go#L11>)

```go
func FromValue[T any](v T) O[T]
Expand All @@ -51,7 +51,7 @@ func FromValue[T any](v T) O[T]
FromValue creates an Optional from a value.

<a name="FromValue2"></a>
### func [FromValue2](<https://github.com/dashjay/xiter/blob/main/pkg/optional/optional.go#L22>)
### func [FromValue2](<https://github.com/dashjay/xiter/blob/main/optional/optional.go#L22>)

```go
func FromValue2[T any](v T, ok bool) O[T]
Expand All @@ -68,7 +68,7 @@ if v, ok := fn(); ok { FromValue(v) } else { Empty[T]() }
```

<a name="O[T].Must"></a>
### func \(O\[T\]\) [Must](<https://github.com/dashjay/xiter/blob/main/pkg/optional/optional.go#L48>)
### func \(O\[T\]\) [Must](<https://github.com/dashjay/xiter/blob/main/optional/optional.go#L48>)

```go
func (o O[T]) Must() T
Expand All @@ -79,7 +79,7 @@ Must directly return the value of the Optional.
❌WARNING: Panic if the Optional has no value.

<a name="O[T].Ok"></a>
### func \(O\[T\]\) [Ok](<https://github.com/dashjay/xiter/blob/main/pkg/optional/optional.go#L41>)
### func \(O\[T\]\) [Ok](<https://github.com/dashjay/xiter/blob/main/optional/optional.go#L41>)

```go
func (o O[T]) Ok() bool
Expand All @@ -88,7 +88,7 @@ func (o O[T]) Ok() bool
Ok returns whether the Optional has a valid value.

<a name="O[T].Ptr"></a>
### func \(O\[T\]\) [Ptr](<https://github.com/dashjay/xiter/blob/main/pkg/optional/optional.go#L33>)
### func \(O\[T\]\) [Ptr](<https://github.com/dashjay/xiter/blob/main/optional/optional.go#L33>)

```go
func (o O[T]) Ptr() *T
Expand All @@ -97,7 +97,7 @@ func (o O[T]) Ptr() *T
Ptr returns a pointer to the value of the Optional. return nil if the Optional has no value.

<a name="O[T].ValueOr"></a>
### func \(O\[T\]\) [ValueOr](<https://github.com/dashjay/xiter/blob/main/pkg/optional/optional.go#L56>)
### func \(O\[T\]\) [ValueOr](<https://github.com/dashjay/xiter/blob/main/optional/optional.go#L56>)

```go
func (o O[T]) ValueOr(dft T) T
Expand All @@ -106,7 +106,7 @@ func (o O[T]) ValueOr(dft T) T
ValueOr returns the value of the Optional if it has a valid value, otherwise returns the given default value.

<a name="O[T].ValueOrZero"></a>
### func \(O\[T\]\) [ValueOrZero](<https://github.com/dashjay/xiter/blob/main/pkg/optional/optional.go#L64>)
### func \(O\[T\]\) [ValueOrZero](<https://github.com/dashjay/xiter/blob/main/optional/optional.go#L64>)

```go
func (o O[T]) ValueOrZero() T
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package optional_test
import (
"testing"

"github.com/dashjay/xiter/pkg/optional"
"github.com/dashjay/xiter/optional"
"github.com/stretchr/testify/assert"
)

Expand Down
22 changes: 11 additions & 11 deletions pkg/union/README.md → union/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# union

```go
import "github.com/dashjay/xiter/pkg/union"
import "github.com/dashjay/xiter/union"
```

## Index
Expand All @@ -21,7 +21,7 @@ import "github.com/dashjay/xiter/pkg/union"


<a name="U10"></a>
## type [U10](<https://github.com/dashjay/xiter/blob/main/pkg/union/union.go#L71-L82>)
## type [U10](<https://github.com/dashjay/xiter/blob/main/union/union.go#L71-L82>)



Expand All @@ -41,7 +41,7 @@ type U10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any] struct {
```

<a name="U11"></a>
## type [U11](<https://github.com/dashjay/xiter/blob/main/pkg/union/union.go#L84-L96>)
## type [U11](<https://github.com/dashjay/xiter/blob/main/union/union.go#L84-L96>)



Expand All @@ -62,7 +62,7 @@ type U11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any] struct {
```

<a name="U2"></a>
## type [U2](<https://github.com/dashjay/xiter/blob/main/pkg/union/union.go#L3-L6>)
## type [U2](<https://github.com/dashjay/xiter/blob/main/union/union.go#L3-L6>)



Expand All @@ -74,7 +74,7 @@ type U2[T1, T2 any] struct {
```

<a name="U3"></a>
## type [U3](<https://github.com/dashjay/xiter/blob/main/pkg/union/union.go#L8-L12>)
## type [U3](<https://github.com/dashjay/xiter/blob/main/union/union.go#L8-L12>)



Expand All @@ -87,7 +87,7 @@ type U3[T1, T2, T3 any] struct {
```

<a name="U4"></a>
## type [U4](<https://github.com/dashjay/xiter/blob/main/pkg/union/union.go#L14-L19>)
## type [U4](<https://github.com/dashjay/xiter/blob/main/union/union.go#L14-L19>)



Expand All @@ -101,7 +101,7 @@ type U4[T1, T2, T3, T4 any] struct {
```

<a name="U5"></a>
## type [U5](<https://github.com/dashjay/xiter/blob/main/pkg/union/union.go#L21-L27>)
## type [U5](<https://github.com/dashjay/xiter/blob/main/union/union.go#L21-L27>)



Expand All @@ -116,7 +116,7 @@ type U5[T1, T2, T3, T4, T5 any] struct {
```

<a name="U6"></a>
## type [U6](<https://github.com/dashjay/xiter/blob/main/pkg/union/union.go#L29-L36>)
## type [U6](<https://github.com/dashjay/xiter/blob/main/union/union.go#L29-L36>)



Expand All @@ -132,7 +132,7 @@ type U6[T1, T2, T3, T4, T5, T6 any] struct {
```

<a name="U7"></a>
## type [U7](<https://github.com/dashjay/xiter/blob/main/pkg/union/union.go#L38-L46>)
## type [U7](<https://github.com/dashjay/xiter/blob/main/union/union.go#L38-L46>)



Expand All @@ -149,7 +149,7 @@ type U7[T1, T2, T3, T4, T5, T6, T7 any] struct {
```

<a name="U8"></a>
## type [U8](<https://github.com/dashjay/xiter/blob/main/pkg/union/union.go#L48-L57>)
## type [U8](<https://github.com/dashjay/xiter/blob/main/union/union.go#L48-L57>)



Expand All @@ -167,7 +167,7 @@ type U8[T1, T2, T3, T4, T5, T6, T7, T8 any] struct {
```

<a name="U9"></a>
## type [U9](<https://github.com/dashjay/xiter/blob/main/pkg/union/union.go#L59-L69>)
## type [U9](<https://github.com/dashjay/xiter/blob/main/union/union.go#L59-L69>)



Expand Down
File renamed without changes.
Loading
Loading