Skip to content

Commit 286dfcb

Browse files
committed
cue: add more godoc links
I was looking at some of the deprecation notices and it took me a bit of effort to find the referenced APIs. Use godoc links so they are trivial to find. While here, I noticed that hiddenValue.Value referenced a missing type, which seems to have been a mistake when InstanceOrValue was added. Also add a note to Instance about it being phased out, which was documented in its constructors, but not the type itself. We don't want to deprecate the type right away, as it's still used in some of our user-facing APIs. Signed-off-by: Daniel Martí <[email protected]> Change-Id: Ibb1b7de6a1e4a27f4417158559d5857014d922c0 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1171218 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Roger Peppe <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 05ceba6 commit 286dfcb

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

cue/build.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,22 @@ func (r *hiddenRuntime) CompileExpr(expr ast.Expr) (*Instance, error) {
102102
// provided as a string, byte slice, or io.Reader. The name is used as the file
103103
// name in position information. The source may import builtin packages.
104104
//
105-
// Deprecated: use CompileString or CompileBytes. The use of Instance is being
106-
// phased out.
105+
// Deprecated: use [Context.CompileString] or [Context.CompileBytes].
106+
// The use of [Instance] is being phased out.
107107
func (r *hiddenRuntime) Parse(name string, source interface{}) (*Instance, error) {
108108
return r.Compile(name, source)
109109
}
110110

111111
// Build creates an Instance from the given build.Instance. A returned Instance
112112
// may be incomplete, in which case its Err field is set.
113113
//
114-
// Deprecated: use Context.BuildInstance. The use of Instance is being phased
115-
// out.
114+
// Deprecated: use [Context.BuildInstance]. The use of [Instance] is being phased out.
116115
func (r *hiddenRuntime) Build(p *build.Instance) (*Instance, error) {
117116
v, _ := r.runtime().Build(nil, p)
118117
return r.complete(p, v)
119118
}
120119

121-
// Deprecated: use cuecontext.Context.BuildInstances. The use of Instance is
122-
// being phased out.
120+
// Deprecated: [Context.BuildInstances]. The use of [Instance] is being phased out.
123121
func Build(instances []*build.Instance) []*Instance {
124122
if len(instances) == 0 {
125123
panic("cue: list of instances must not be empty")

cue/instance.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"cuelang.org/go/internal/core/runtime"
2525
)
2626

27-
// An InstanceOrValue is implemented by Value and *Instance.
27+
// An InstanceOrValue is implemented by [Value] and *[Instance].
2828
//
2929
// This is a placeholder type that is used to allow Instance-based APIs to
3030
// transition to Value-based APIs. The goals is to get rid of the Instance
@@ -38,11 +38,15 @@ type InstanceOrValue interface {
3838
func (Value) internal() {}
3939
func (*Instance) internal() {}
4040

41-
// Value implements value.Instance.
41+
// Value implements [InstanceOrValue].
4242
func (v hiddenValue) Value() Value { return v }
4343

4444
// An Instance defines a single configuration based on a collection of
4545
// underlying CUE files.
46+
//
47+
// Use of this type is being phased out in favor of [Value].
48+
// Any APIs currently taking an Instance should use [InstanceOrValue]
49+
// to transition to the new type without breaking users.
4650
type Instance struct {
4751
index *runtime.Runtime
4852

cue/types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ func (v Value) Doc() []*ast.CommentGroup {
10551055
// split values may fail if actually unified.
10561056
// Source returns a non-nil value.
10571057
//
1058-
// Deprecated: use Expr.
1058+
// Deprecated: use [Value.Expr].
10591059
func (v hiddenValue) Split() []Value {
10601060
if v.v == nil {
10611061
return nil
@@ -1947,7 +1947,7 @@ func (v Value) instance() *Instance {
19471947
// a reference. If a reference contains index selection (foo[bar]), it will
19481948
// only return a reference if the index resolves to a concrete value.
19491949
//
1950-
// Deprecated: use ReferencePath
1950+
// Deprecated: use [Value.ReferencePath]
19511951
func (v hiddenValue) Reference() (inst *Instance, path []string) {
19521952
root, p := v.ReferencePath()
19531953
if !root.Exists() {

0 commit comments

Comments
 (0)