Skip to content

Commit

Permalink
syntax,repl: improve docs for deprecated functions (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed May 10, 2024
1 parent 35fe9f2 commit cec2ad9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
8 changes: 6 additions & 2 deletions repl/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import (
var interrupted = make(chan os.Signal, 1)

// REPL calls [REPLOptions] using [syntax.LegacyFileOptions].
// Deprecated: relies on legacy global variables.
//
// Deprecated: use [REPLOptions] with [syntax.FileOptions] instead,
// because this function relies on legacy global variables.
func REPL(thread *starlark.Thread, globals starlark.StringDict) {
REPLOptions(syntax.LegacyFileOptions(), thread, globals)
}
Expand Down Expand Up @@ -153,7 +155,9 @@ func PrintError(err error) {
}

// MakeLoad calls [MakeLoadOptions] using [syntax.LegacyFileOptions].
// Deprecated: relies on legacy global variables.
//
// Deprecated: use [MakeLoadOptions] with [syntax.FileOptions] instead,
// because this function relies on legacy global variables.
func MakeLoad() func(thread *starlark.Thread, module string) (starlark.StringDict, error) {
return MakeLoadOptions(syntax.LegacyFileOptions())
}
Expand Down
4 changes: 3 additions & 1 deletion resolve/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ func REPLChunk(file *syntax.File, isGlobal, isPredeclared, isUniversal func(name
}

// Expr calls [ExprOptions] using [syntax.LegacyFileOptions].
// Deprecated: relies on legacy global variables.
//
// Deprecated: use [ExprOptions] with [syntax.FileOptions] instead,
// because this function relies on legacy global variables.
func Expr(expr syntax.Expr, isPredeclared, isUniversal func(name string) bool) ([]*Binding, error) {
return ExprOptions(syntax.LegacyFileOptions(), expr, isPredeclared, isUniversal)
}
Expand Down
20 changes: 15 additions & 5 deletions starlark/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ func (prog *Program) Write(out io.Writer) error {
}

// ExecFile calls [ExecFileOptions] using [syntax.LegacyFileOptions].
// Deprecated: relies on legacy global variables.
//
// Deprecated: use [ExecFileOptions] with [syntax.FileOptions] instead,
// because this function relies on legacy global variables.
func ExecFile(thread *Thread, filename string, src interface{}, predeclared StringDict) (StringDict, error) {
return ExecFileOptions(syntax.LegacyFileOptions(), thread, filename, src, predeclared)
}
Expand Down Expand Up @@ -360,7 +362,9 @@ func ExecFileOptions(opts *syntax.FileOptions, thread *Thread, filename string,
}

// SourceProgram calls [SourceProgramOptions] using [syntax.LegacyFileOptions].
// Deprecated: relies on legacy global variables.
//
// Deprecated: use [SourceProgramOptions] with [syntax.FileOptions] instead,
// because this function relies on legacy global variables.
func SourceProgram(filename string, src interface{}, isPredeclared func(string) bool) (*syntax.File, *Program, error) {
return SourceProgramOptions(syntax.LegacyFileOptions(), filename, src, isPredeclared)
}
Expand Down Expand Up @@ -524,7 +528,9 @@ func makeToplevelFunction(prog *compile.Program, predeclared StringDict) *Functi
}

// Eval calls [EvalOptions] using [syntax.LegacyFileOptions].
// Deprecated: relies on legacy global variables.
//
// Deprecated: use [EvalOptions] with [syntax.FileOptions] instead,
// because this function relies on legacy global variables.
func Eval(thread *Thread, filename string, src interface{}, env StringDict) (Value, error) {
return EvalOptions(syntax.LegacyFileOptions(), thread, filename, src, env)
}
Expand Down Expand Up @@ -552,7 +558,9 @@ func EvalOptions(opts *syntax.FileOptions, thread *Thread, filename string, src
}

// EvalExpr calls [EvalExprOptions] using [syntax.LegacyFileOptions].
// Deprecated: relies on legacy global variables.
//
// Deprecated: use [EvalExprOptions] with [syntax.FileOptions] instead,
// because this function relies on legacy global variables.
func EvalExpr(thread *Thread, expr syntax.Expr, env StringDict) (Value, error) {
return EvalExprOptions(syntax.LegacyFileOptions(), thread, expr, env)
}
Expand All @@ -578,7 +586,9 @@ func EvalExprOptions(opts *syntax.FileOptions, thread *Thread, expr syntax.Expr,
}

// ExprFunc calls [ExprFuncOptions] using [syntax.LegacyFileOptions].
// Deprecated: relies on legacy global variables.
//
// Deprecated: use [ExprFuncOptions] with [syntax.FileOptions] instead,
// because this function relies on legacy global variables.
func ExprFunc(filename string, src interface{}, env StringDict) (*Function, error) {
return ExprFuncOptions(syntax.LegacyFileOptions(), filename, src, env)
}
Expand Down
12 changes: 9 additions & 3 deletions syntax/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const (
)

// Parse calls the Parse method of LegacyFileOptions().
// Deprecated: relies on legacy global variables.
//
// Deprecated: use [FileOptions.Parse] instead,
// because this function relies on legacy global variables.
func Parse(filename string, src interface{}, mode Mode) (f *File, err error) {
return LegacyFileOptions().Parse(filename, src, mode)
}
Expand Down Expand Up @@ -54,7 +56,9 @@ func (opts *FileOptions) Parse(filename string, src interface{}, mode Mode) (f *
}

// ParseCompoundStmt calls the ParseCompoundStmt method of LegacyFileOptions().
// Deprecated: relies on legacy global variables.
//
// Deprecated: use [FileOptions.ParseCompoundStmt] instead,
// because this function relies on legacy global variables.
func ParseCompoundStmt(filename string, readline func() ([]byte, error)) (f *File, err error) {
return LegacyFileOptions().ParseCompoundStmt(filename, readline)
}
Expand Down Expand Up @@ -95,7 +99,9 @@ func (opts *FileOptions) ParseCompoundStmt(filename string, readline func() ([]b
}

// ParseExpr calls the ParseExpr method of LegacyFileOptions().
// Deprecated: relies on legacy global variables.
//
// Deprecated: use [FileOptions.ParseExpr] instead,
// because this function relies on legacy global variables.
func ParseExpr(filename string, src interface{}, mode Mode) (expr Expr, err error) {
return LegacyFileOptions().ParseExpr(filename, src, mode)
}
Expand Down

0 comments on commit cec2ad9

Please sign in to comment.