1
0
mirror of https://github.com/go-task/task.git synced 2025-11-23 22:24:45 +02:00

docs: package api docs (#2169)

* refactor: pass Node into Read method instead of Reader type

* docs: add "key packages" and "Reading Taskfiles" sections to package doc
This commit is contained in:
Pete Davison
2025-04-19 11:58:31 +01:00
committed by GitHub
parent 8885d9e4f7
commit 04df108fb5
3 changed files with 144 additions and 13 deletions

View File

@@ -40,7 +40,6 @@ type (
// [ast.TaskfileGraph] from them.
Reader struct {
graph *ast.TaskfileGraph
node Node
insecure bool
download bool
offline bool
@@ -54,13 +53,9 @@ type (
// NewReader constructs a new Taskfile [Reader] using the given Node and
// options.
func NewReader(
node Node,
opts ...ReaderOption,
) *Reader {
func NewReader(opts ...ReaderOption) *Reader {
r := &Reader{
graph: ast.NewTaskfileGraph(),
node: node,
insecure: false,
download: false,
offline: false,
@@ -191,8 +186,8 @@ func (o *promptFuncOption) ApplyToReader(r *Reader) {
// through any [ast.Includes] it finds, reading each included Taskfile and
// building an [ast.TaskfileGraph] as it goes. If any errors occur, they will be
// returned immediately.
func (r *Reader) Read() (*ast.TaskfileGraph, error) {
if err := r.include(r.node); err != nil {
func (r *Reader) Read(node Node) (*ast.TaskfileGraph, error) {
if err := r.include(node); err != nil {
return nil, err
}
return r.graph, nil