diff options
author | Russ Cox <rsc@golang.org> | 2022-02-03 14:12:08 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2022-04-11 16:34:30 +0000 |
commit | 19309779ac5e2f5a2fd3cbb34421dafb2855ac21 (patch) | |
tree | 67dfd3e5d96250325e383183f95b6f5fe1968514 /src/text | |
parent | 017933163ab6a2b254f0310c61b57db65cded92e (diff) | |
download | go-19309779ac5e2f5a2fd3cbb34421dafb2855ac21.tar.gz go-19309779ac5e2f5a2fd3cbb34421dafb2855ac21.zip |
all: gofmt main repo
[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]
Run the updated gofmt, which reformats doc comments,
on the main repository. Vendored files are excluded.
For #51082.
Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407
Reviewed-on: https://go-review.googlesource.com/c/go/+/384268
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/text')
-rw-r--r-- | src/text/template/funcs.go | 2 | ||||
-rw-r--r-- | src/text/template/helper.go | 1 | ||||
-rw-r--r-- | src/text/template/option.go | 1 | ||||
-rw-r--r-- | src/text/template/parse/parse.go | 30 |
4 files changed, 34 insertions, 0 deletions
diff --git a/src/text/template/funcs.go b/src/text/template/funcs.go index 1f63b361f8..390d47ebbb 100644 --- a/src/text/template/funcs.go +++ b/src/text/template/funcs.go @@ -751,7 +751,9 @@ func URLQueryEscaper(args ...any) string { } // evalArgs formats the list of arguments into a string. It is therefore equivalent to +// // fmt.Sprint(args...) +// // except that each argument is indirected (if a pointer), as required, // using the same rules as the default string evaluation during template // execution. diff --git a/src/text/template/helper.go b/src/text/template/helper.go index 57905e613a..48af3928b3 100644 --- a/src/text/template/helper.go +++ b/src/text/template/helper.go @@ -19,6 +19,7 @@ import ( // Must is a helper that wraps a call to a function returning (*Template, error) // and panics if the error is non-nil. It is intended for use in variable // initializations such as +// // var t = template.Must(template.New("name").Parse("text")) func Must(t *Template, err error) *Template { if err != nil { diff --git a/src/text/template/option.go b/src/text/template/option.go index 8d7d436bd0..ea2fd80c06 100644 --- a/src/text/template/option.go +++ b/src/text/template/option.go @@ -30,6 +30,7 @@ type option struct { // // missingkey: Control the behavior during execution if a map is // indexed with a key that is not present in the map. +// // "missingkey=default" or "missingkey=invalid" // The default behavior: Do nothing and continue execution. // If printed, the result of the index operation is the string diff --git a/src/text/template/parse/parse.go b/src/text/template/parse/parse.go index ce548b0886..67e2f5b2f4 100644 --- a/src/text/template/parse/parse.go +++ b/src/text/template/parse/parse.go @@ -341,7 +341,9 @@ func (t *Tree) parseDefinition() { } // itemList: +// // textOrAction* +// // Terminates at {{end}} or {{else}}, returned separately. func (t *Tree) itemList() (list *ListNode, next Node) { list = t.newList(t.peekNonSpace().pos) @@ -358,6 +360,7 @@ func (t *Tree) itemList() (list *ListNode, next Node) { } // textOrAction: +// // text | comment | action func (t *Tree) textOrAction() Node { switch token := t.nextNonSpace(); token.typ { @@ -380,8 +383,10 @@ func (t *Tree) clearActionLine() { } // Action: +// // control // command ("|" command)* +// // Left delim is past. Now get actions. // First word could be a keyword such as range. func (t *Tree) action() (n Node) { @@ -412,7 +417,9 @@ func (t *Tree) action() (n Node) { } // Break: +// // {{break}} +// // Break keyword is past. func (t *Tree) breakControl(pos Pos, line int) Node { if token := t.nextNonSpace(); token.typ != itemRightDelim { @@ -425,7 +432,9 @@ func (t *Tree) breakControl(pos Pos, line int) Node { } // Continue: +// // {{continue}} +// // Continue keyword is past. func (t *Tree) continueControl(pos Pos, line int) Node { if token := t.nextNonSpace(); token.typ != itemRightDelim { @@ -438,6 +447,7 @@ func (t *Tree) continueControl(pos Pos, line int) Node { } // Pipeline: +// // declarations? command ('|' command)* func (t *Tree) pipeline(context string, end itemType) (pipe *PipeNode) { token := t.peekNonSpace() @@ -549,16 +559,20 @@ func (t *Tree) parseControl(allowElseIf bool, context string) (pos Pos, line int } // If: +// // {{if pipeline}} itemList {{end}} // {{if pipeline}} itemList {{else}} itemList {{end}} +// // If keyword is past. func (t *Tree) ifControl() Node { return t.newIf(t.parseControl(true, "if")) } // Range: +// // {{range pipeline}} itemList {{end}} // {{range pipeline}} itemList {{else}} itemList {{end}} +// // Range keyword is past. func (t *Tree) rangeControl() Node { r := t.newRange(t.parseControl(false, "range")) @@ -566,22 +580,28 @@ func (t *Tree) rangeControl() Node { } // With: +// // {{with pipeline}} itemList {{end}} // {{with pipeline}} itemList {{else}} itemList {{end}} +// // If keyword is past. func (t *Tree) withControl() Node { return t.newWith(t.parseControl(false, "with")) } // End: +// // {{end}} +// // End keyword is past. func (t *Tree) endControl() Node { return t.newEnd(t.expect(itemRightDelim, "end").pos) } // Else: +// // {{else}} +// // Else keyword is past. func (t *Tree) elseControl() Node { // Special case for "else if". @@ -595,7 +615,9 @@ func (t *Tree) elseControl() Node { } // Block: +// // {{block stringValue pipeline}} +// // Block keyword is past. // The name must be something that can evaluate to a string. // The pipeline is mandatory. @@ -623,7 +645,9 @@ func (t *Tree) blockControl() Node { } // Template: +// // {{template stringValue pipeline}} +// // Template keyword is past. The name must be something that can evaluate // to a string. func (t *Tree) templateControl() Node { @@ -654,7 +678,9 @@ func (t *Tree) parseTemplateName(token item, context string) (name string) { } // command: +// // operand (space operand)* +// // space-separated arguments up to a pipeline character or right delimiter. // we consume the pipe character but leave the right delim to terminate the action. func (t *Tree) command() *CommandNode { @@ -684,7 +710,9 @@ func (t *Tree) command() *CommandNode { } // operand: +// // term .Field* +// // An operand is a space-separated component of a command, // a term possibly followed by field accesses. // A nil return means the next item is not an operand. @@ -718,12 +746,14 @@ func (t *Tree) operand() Node { } // term: +// // literal (number, string, nil, boolean) // function (identifier) // . // .Field // $ // '(' pipeline ')' +// // A term is a simple "expression". // A nil return means the next item is not a term. func (t *Tree) term() Node { |