Skip to content

Commit 0ed088b

Browse files
committed
Fix links, mention slice & map support
1 parent 85862f7 commit 0ed088b

5 files changed

Lines changed: 24 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ All notable changes to this project will be documented in this file. It uses the
2626
* Upgraded to `golangci-lint` v2.11.4 and made suggested slice allocation
2727
optimizations.
2828

29+
### 📚 Documentation
30+
31+
* Fixed some broken Go Doc links.
32+
2933
[v0.11.1]: https://github.com/theory/jsonpath/compare/v0.11.0...v0.11.1
3034
[Go blog post]: https://go.dev/blog/allocation-optimizations
3135
"The Go Blog: Allocating on the Stack"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ RFC 9535 JSONPath in Go
44
[![⚖️ MIT]][mit] [![📚 Docs]][docs] [![🗃️ Report Card]][card] [![🛠️ Build Status]][ci] [![📊 Coverage]][cov]
55

66
The jsonpath package provides [RFC 9535 JSONPath] functionality in Go.
7+
It operates on any type of slice or string-keyed map.
78

89
## Learn More
910

path.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Package jsonpath implements RFC 9535 JSONPath query expressions.
2+
// It operates on any type of slice or string-keyed map.
23
package jsonpath
34

45
import (
@@ -160,7 +161,7 @@ func (list NodeList) All() iter.Seq[any] {
160161
}
161162

162163
// LocatedNodeList is a list of nodes selected by a JSONPath query, along with
163-
// their [NormalizedPath] locations. Returned by [Path.SelectLocated].
164+
// their [spec.NormalizedPath] locations. Returned by [Path.SelectLocated].
164165
type LocatedNodeList []*spec.LocatedNode
165166

166167
// All returns an iterator over all the nodes in list.
@@ -188,7 +189,8 @@ func (list LocatedNodeList) Nodes() iter.Seq[any] {
188189
}
189190
}
190191

191-
// Paths returns an iterator over all the [NormalizedPath] values in list.
192+
// Paths returns an iterator over all the [spec.NormalizedPath] values in
193+
// list.
192194
func (list LocatedNodeList) Paths() iter.Seq[spec.NormalizedPath] {
193195
return func(yield func(spec.NormalizedPath) bool) {
194196
for _, v := range list {
@@ -199,10 +201,10 @@ func (list LocatedNodeList) Paths() iter.Seq[spec.NormalizedPath] {
199201
}
200202
}
201203

202-
// Deduplicate deduplicates the nodes in list based on their [NormalizedPath]
203-
// values, modifying the contents of list. It returns the modified list, which
204-
// may have a shorter length, and zeroes the elements between the new length
205-
// and the original length.
204+
// Deduplicate deduplicates the nodes in list based on their
205+
// [spec.NormalizedPath] values, modifying the contents of list. It returns
206+
// the modified list, which may have a shorter length, and zeroes the elements
207+
// between the new length and the original length.
206208
func (list LocatedNodeList) Deduplicate() LocatedNodeList {
207209
if len(list) <= 1 {
208210
return list
@@ -221,7 +223,7 @@ func (list LocatedNodeList) Deduplicate() LocatedNodeList {
221223
return slices.Clip(uniq)
222224
}
223225

224-
// Sort sorts list by the [NormalizedPath] of each node.
226+
// Sort sorts list by the [spec.NormalizedPath] of each node.
225227
func (list LocatedNodeList) Sort() {
226228
slices.SortFunc(list, func(a, b *spec.LocatedNode) int {
227229
return a.Path.Compare(b.Path)

registry/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func New() *Registry {
4646
}
4747
}
4848

49-
// ErrRegister errors are returned by [Register].
49+
// ErrRegister errors are returned by [Registry.Register].
5050
var ErrRegister = errors.New("register")
5151

5252
// Register registers a function extension. The parameters are:

spec/function.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ type PathValue interface {
4646
// NodesType defines a node list (a list of JSON values) for a function
4747
// expression parameters or results, as defined by [RFC 9535 Section 2.4.1].
4848
// It can also be used in filter expressions. The underlying types should be
49-
// string, integer, float, [json.Number], nil, true, false, []any, or
50-
// map[string]any. Interfaces implemented:
49+
// string, integer, float, [json.Number], nil, true, false, slice, or
50+
// string-keyed map. Interfaces implemented:
5151
//
5252
// - [PathValue]
5353
// - [fmt.Stringer]
@@ -57,7 +57,7 @@ type NodesType []any
5757

5858
// Nodes creates a NodesType that contains val, all of which should be the Go
5959
// equivalent of the JSON data types: string, integer, float, [json.Number],
60-
// nil, true, false, []any, or map[string]any.
60+
// nil, true, false, slice, or string-keyed map.
6161
func Nodes(val ...any) NodesType {
6262
return NodesType(val)
6363
}
@@ -137,8 +137,8 @@ func (LogicalType) FuncType() FuncType { return FuncLogical }
137137
// LogicalFrom converts value to a [LogicalType] and panics if it cannot. Use
138138
// in [github.com/theory/jsonpath/registry.Registry.Register] [Evaluator]
139139
// functions. Avoid the panic by returning an error from the accompanying
140-
// [Validator] function when [FuncExprArg.ConvertsToLogical] returns false for
141-
// the [FuncExprArg] that returns value.
140+
// [Validator] function when [FuncExprArg.ConvertsTo] returns false for the
141+
// [FuncExprArg] that returns value.
142142
//
143143
// Converts each implementation of [PathValue] as follows:
144144
// - [LogicalType]: returns value
@@ -170,7 +170,7 @@ func (lt LogicalType) writeTo(buf *strings.Builder) {
170170
// ValueType encapsulates a JSON value for a function expression parameter or
171171
// result, as defined by [RFC 9535 Section 2.4.1]. It can also be used as in
172172
// filter expression. The underlying value should be a string, integer,
173-
// [json.Number], float, nil, true, false, []any, or map[string]any. A nil
173+
// [json.Number], float, nil, true, false, slice, or string-keyed map. A nil
174174
// ValueType pointer indicates no value. Interfaces implemented:
175175
//
176176
// - [PathValue]
@@ -184,7 +184,7 @@ type ValueType struct {
184184

185185
// Value returns a new [ValueType] for val, which must be the Go equivalent of
186186
// a JSON data type: string, integer, float, [json.Number], nil, true, false,
187-
// []any, or map[string]any.
187+
// slice, or string-keyed map.
188188
func Value(val any) *ValueType {
189189
return &ValueType{val}
190190
}
@@ -201,8 +201,8 @@ func (*ValueType) FuncType() FuncType { return FuncValue }
201201
// ValueFrom converts value to a [ValueType] and panics if it cannot. Use in
202202
// [github.com/theory/jsonpath/registry.Registry.Register] [Evaluator]
203203
// functions. Avoid the panic by returning an error from the accompanying
204-
// [Validator] function when [FuncExprArg.ConvertsToValue] returns false for
205-
// the [FuncExprArg] that returns value.
204+
// [Validator] function when [FuncExprArg.ConvertsTo] returns false for the
205+
// [FuncExprArg] that returns value.
206206
//
207207
// Converts each implementation of [PathValue] as follows:
208208
// - [ValueType]: returns value

0 commit comments

Comments
 (0)