Skip to content

Commit ae49b1c

Browse files
committed
improve doc comments using links
1 parent 53b2c09 commit ae49b1c

10 files changed

+26
-26
lines changed

compiler.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ type Code struct {
3030
}
3131

3232
// Run runs the code with the variable values (which should be in the
33-
// same order as the given variables using WithVariables) and returns
33+
// same order as the given variables using [WithVariables]) and returns
3434
// a result iterator.
3535
//
36-
// It is safe to call this method of a *Code in multiple goroutines.
36+
// It is safe to call this method in goroutines, to reuse a compiled [*Code].
3737
func (c *Code) Run(v interface{}, values ...interface{}) Iter {
3838
return c.RunWithContext(context.Background(), v, values...)
3939
}

error.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "strconv"
55
// ValueError is an interface for errors with a value for internal function.
66
// Return an error implementing this interface when you want to catch error
77
// values (not error messages) by try-catch, just like built-in error function.
8-
// Refer to WithFunction to add a custom internal function.
8+
// Refer to [WithFunction] to add a custom internal function.
99
type ValueError interface {
1010
error
1111
Value() interface{}

gojq.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Package gojq provides the parser and interpreter of gojq.
1+
// Package gojq provides the parser and the interpreter of gojq.
2+
// Please refer to [Usage as a library] for introduction.
23
//
3-
// Please refer to https://github.com/itchyny/gojq#usage-as-a-library for
4-
// introduction of the usage as a library.
4+
// [Usage as a library]: https://github.com/itchyny/gojq#usage-as-a-library
55
package gojq

iter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type Iter interface {
55
Next() (interface{}, bool)
66
}
77

8-
// NewIter creates a new Iter from values.
8+
// NewIter creates a new [Iter] from values.
99
func NewIter(values ...interface{}) Iter {
1010
switch len(values) {
1111
case 0:

module_loader.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
// ModuleLoader is the interface for loading modules.
1313
//
14-
// Implement following optional methods. Use NewModuleLoader to load local modules.
14+
// Implement following optional methods. Use [NewModuleLoader] to load local modules.
1515
//
1616
// LoadModule(string) (*Query, error)
1717
// LoadModuleWithMeta(string, map[string]interface{}) (*Query, error)
@@ -20,7 +20,7 @@ import (
2020
// LoadJSONWithMeta(string, map[string]interface{}) (interface{}, error)
2121
type ModuleLoader interface{}
2222

23-
// NewModuleLoader creates a new ModuleLoader reading local modules in the paths.
23+
// NewModuleLoader creates a new [ModuleLoader] reading local modules in the paths.
2424
func NewModuleLoader(paths []string) ModuleLoader {
2525
return &moduleLoader{expandHomeDir(paths)}
2626
}

operator.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const (
3737
OpUpdateAlt
3838
)
3939

40-
// String implements Stringer.
40+
// String implements [fmt.Stringer].
4141
func (op Operator) String() string {
4242
switch op {
4343
case OpPipe:
@@ -93,7 +93,7 @@ func (op Operator) String() string {
9393
}
9494
}
9595

96-
// GoString implements GoStringer.
96+
// GoString implements [fmt.GoStringer].
9797
func (op Operator) GoString() (str string) {
9898
defer func() { str = "gojq." + str }()
9999
switch op {

option.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import "fmt"
66
type CompilerOption func(*compiler)
77

88
// WithModuleLoader is a compiler option for module loader.
9-
// If you want to load modules from the filesystem, use NewModuleLoader.
9+
// If you want to load modules from the filesystem, use [NewModuleLoader].
1010
func WithModuleLoader(moduleLoader ModuleLoader) CompilerOption {
1111
return func(c *compiler) {
1212
c.moduleLoader = moduleLoader
@@ -15,15 +15,15 @@ func WithModuleLoader(moduleLoader ModuleLoader) CompilerOption {
1515

1616
// WithEnvironLoader is a compiler option for environment variables loader.
1717
// The OS environment variables are not accessible by default due to security
18-
// reason. You can pass os.Environ if you allow to access it.
18+
// reasons. You can specify [os.Environ] as argument if you allow to access.
1919
func WithEnvironLoader(environLoader func() []string) CompilerOption {
2020
return func(c *compiler) {
2121
c.environLoader = environLoader
2222
}
2323
}
2424

2525
// WithVariables is a compiler option for variable names. The variables can be
26-
// used in the query. You have to give the values to code.Run in the same order.
26+
// used in the query. You have to give the values to [*Code.Run] in the same order.
2727
func WithVariables(variables []string) CompilerOption {
2828
return func(c *compiler) {
2929
c.variables = variables
@@ -35,20 +35,20 @@ func WithVariables(variables []string) CompilerOption {
3535
// values should satisfy 0 <= minarity <= maxarity <= 30, otherwise panics.
3636
// On handling numbers, you should take account to int, float64 and *big.Int.
3737
// These are the number types you are allowed to return, so do not return int64.
38-
// Refer to ValueError to return a value error just like built-in error function.
39-
// If you want to emit multiple values, call the empty function, accept a filter
40-
// for its argument, or call another built-in function, then use LoadInitModules
41-
// of the module loader.
38+
// Refer to [ValueError] to return a value error just like built-in error
39+
// function. If you want to emit multiple values, call the empty function,
40+
// accept a filter for its argument, or call another built-in function, then
41+
// use LoadInitModules of the module loader.
4242
func WithFunction(name string, minarity, maxarity int,
4343
f func(interface{}, []interface{}) interface{}) CompilerOption {
4444
return withFunction(name, minarity, maxarity, false, f)
4545
}
4646

4747
// WithIterFunction is a compiler option for adding a custom iterator function.
48-
// This is like the WithFunction option, but you can add a function which
48+
// This is like the [WithFunction] option, but you can add a function which
4949
// returns an Iter to emit multiple values. You cannot define both iterator and
5050
// non-iterator functions of the same name (with possibly different arities).
51-
// See also NewIter, which can be used to convert values or an error to an Iter.
51+
// See also [NewIter], which can be used to convert values or an error to an Iter.
5252
func WithIterFunction(name string, minarity, maxarity int,
5353
f func(interface{}, []interface{}) Iter) CompilerOption {
5454
return withFunction(name, minarity, maxarity, true,
@@ -91,7 +91,7 @@ func withFunction(name string, minarity, maxarity int, iter bool,
9191
// Note that input and inputs functions are not allowed by default. We have
9292
// to distinguish the query input and the values for input(s) functions. For
9393
// example, consider using inputs with --null-input. If you want to allow
94-
// input(s) functions, create an Iter and use WithInputIter option.
94+
// input(s) functions, create an [Iter] and use WithInputIter option.
9595
func WithInputIter(inputIter Iter) CompilerOption {
9696
return func(c *compiler) {
9797
c.inputIter = inputIter

preview.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package gojq
33
import "unicode/utf8"
44

55
// Preview returns the preview string of v. The preview string is basically the
6-
// same as the jq-flavored JSON encoding returned by Marshal, but is truncated
7-
// by 30 bytes, and more efficient than truncating the result of Marshal.
6+
// same as the jq-flavored JSON encoding returned by [Marshal], but is truncated
7+
// by 30 bytes, and more efficient than truncating the result of [Marshal].
88
//
99
// This method is used by error messages of built-in operators and functions,
1010
// and accepts only limited types (nil, bool, int, float64, *big.Int, string,

query.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Query struct {
1919

2020
// Run the query.
2121
//
22-
// It is safe to call this method of a *Query in multiple goroutines.
22+
// It is safe to call this method in goroutines, to reuse a parsed [*Query].
2323
func (e *Query) Run(v interface{}) Iter {
2424
return e.RunWithContext(context.Background(), v)
2525
}

term_type.go

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

3-
// TermType represents the type of Term.
3+
// TermType represents the type of [Term].
44
type TermType int
55

66
// TermType list.
@@ -27,7 +27,7 @@ const (
2727
TermTypeQuery
2828
)
2929

30-
// GoString implements GoStringer.
30+
// GoString implements [fmt.GoStringer].
3131
func (termType TermType) GoString() (str string) {
3232
defer func() { str = "gojq." + str }()
3333
switch termType {

0 commit comments

Comments
 (0)