From: cui fliter Date: Sat, 4 Nov 2023 08:42:48 +0000 (+0800) Subject: unicode: add available godoc link X-Git-Tag: go1.22rc1~421 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=954a9630c96ab2f9987b1952508962be4b06ec72;p=gostls13.git unicode: add available godoc link Change-Id: I2273274249f05b0492950c27dc5a654422cefc79 Reviewed-on: https://go-review.googlesource.com/c/go/+/539856 TryBot-Result: Gopher Robot Reviewed-by: Rob Pike Run-TryBot: shuang cui Reviewed-by: Cherry Mui Reviewed-by: Heschi Kreinick --- diff --git a/src/unicode/graphic.go b/src/unicode/graphic.go index 2af29778bf..aa62f2a4f9 100644 --- a/src/unicode/graphic.go +++ b/src/unicode/graphic.go @@ -32,7 +32,7 @@ var PrintRanges = []*RangeTable{ // IsGraphic reports whether the rune is defined as a Graphic by Unicode. // Such characters include letters, marks, numbers, punctuation, symbols, and -// spaces, from categories L, M, N, P, S, Zs. +// spaces, from categories [L], [M], [N], [P], [S], [Zs]. func IsGraphic(r rune) bool { // We convert to uint32 to avoid the extra test for negative, // and in the index we convert to uint8 to avoid the range check. @@ -44,8 +44,8 @@ func IsGraphic(r rune) bool { // IsPrint reports whether the rune is defined as printable by Go. Such // characters include letters, marks, numbers, punctuation, symbols, and the -// ASCII space character, from categories L, M, N, P, S and the ASCII space -// character. This categorization is the same as IsGraphic except that the +// ASCII space character, from categories [L], [M], [N], [P], [S] and the ASCII space +// character. This categorization is the same as [IsGraphic] except that the // only spacing character is ASCII space, U+0020. func IsPrint(r rune) bool { if uint32(r) <= MaxLatin1 { @@ -76,8 +76,8 @@ func In(r rune, ranges ...*RangeTable) bool { } // IsControl reports whether the rune is a control character. -// The C (Other) Unicode category includes more code points -// such as surrogates; use Is(C, r) to test for them. +// The [C] ([Other]) Unicode category includes more code points +// such as surrogates; use [Is](C, r) to test for them. func IsControl(r rune) bool { if uint32(r) <= MaxLatin1 { return properties[uint8(r)]&pC != 0 @@ -86,7 +86,7 @@ func IsControl(r rune) bool { return false } -// IsLetter reports whether the rune is a letter (category L). +// IsLetter reports whether the rune is a letter (category [L]). func IsLetter(r rune) bool { if uint32(r) <= MaxLatin1 { return properties[uint8(r)]&(pLmask) != 0 @@ -94,13 +94,13 @@ func IsLetter(r rune) bool { return isExcludingLatin(Letter, r) } -// IsMark reports whether the rune is a mark character (category M). +// IsMark reports whether the rune is a mark character (category [M]). func IsMark(r rune) bool { // There are no mark characters in Latin-1. return isExcludingLatin(Mark, r) } -// IsNumber reports whether the rune is a number (category N). +// IsNumber reports whether the rune is a number (category [N]). func IsNumber(r rune) bool { if uint32(r) <= MaxLatin1 { return properties[uint8(r)]&pN != 0 @@ -109,7 +109,7 @@ func IsNumber(r rune) bool { } // IsPunct reports whether the rune is a Unicode punctuation character -// (category P). +// (category [P]). func IsPunct(r rune) bool { if uint32(r) <= MaxLatin1 { return properties[uint8(r)]&pP != 0 @@ -124,7 +124,7 @@ func IsPunct(r rune) bool { // '\t', '\n', '\v', '\f', '\r', ' ', U+0085 (NEL), U+00A0 (NBSP). // // Other definitions of spacing characters are set by category -// Z and property Pattern_White_Space. +// Z and property [Pattern_White_Space]. func IsSpace(r rune) bool { // This property isn't the same as Z; special-case it. if uint32(r) <= MaxLatin1 { diff --git a/src/unicode/letter.go b/src/unicode/letter.go index f64dfc9af5..9e2cead631 100644 --- a/src/unicode/letter.go +++ b/src/unicode/letter.go @@ -76,9 +76,9 @@ const ( type d [MaxCase]rune // to make the CaseRanges text shorter -// If the Delta field of a CaseRange is UpperLower, it means +// If the Delta field of a [CaseRange] is UpperLower, it means // this CaseRange represents a sequence of the form (say) -// Upper Lower Upper Lower. +// [Upper] [Lower] [Upper] [Lower]. const ( UpperLower = MaxRune + 1 // (Cannot be a valid delta.) ) @@ -244,7 +244,7 @@ func to(_case int, r rune, caseRange []CaseRange) (mappedRune rune, foundMapping return r, false } -// To maps the rune to the specified case: UpperCase, LowerCase, or TitleCase. +// To maps the rune to the specified case: [UpperCase], [LowerCase], or [TitleCase]. func To(_case int, r rune) rune { r, _ = to(_case, r, CaseRanges) return r diff --git a/src/unicode/utf8/utf8.go b/src/unicode/utf8/utf8.go index 1e9f666e23..71d6bf18d0 100644 --- a/src/unicode/utf8/utf8.go +++ b/src/unicode/utf8/utf8.go @@ -141,7 +141,7 @@ func FullRuneInString(s string) bool { } // DecodeRune unpacks the first UTF-8 encoding in p and returns the rune and -// its width in bytes. If p is empty it returns (RuneError, 0). Otherwise, if +// its width in bytes. If p is empty it returns ([RuneError], 0). Otherwise, if // the encoding is invalid, it returns (RuneError, 1). Both are impossible // results for correct, non-empty UTF-8. // @@ -188,8 +188,8 @@ func DecodeRune(p []byte) (r rune, size int) { return rune(p0&mask4)<<18 | rune(b1&maskx)<<12 | rune(b2&maskx)<<6 | rune(b3&maskx), 4 } -// DecodeRuneInString is like DecodeRune but its input is a string. If s is -// empty it returns (RuneError, 0). Otherwise, if the encoding is invalid, it +// DecodeRuneInString is like [DecodeRune] but its input is a string. If s is +// empty it returns ([RuneError], 0). Otherwise, if the encoding is invalid, it // returns (RuneError, 1). Both are impossible results for correct, non-empty // UTF-8. // @@ -237,7 +237,7 @@ func DecodeRuneInString(s string) (r rune, size int) { } // DecodeLastRune unpacks the last UTF-8 encoding in p and returns the rune and -// its width in bytes. If p is empty it returns (RuneError, 0). Otherwise, if +// its width in bytes. If p is empty it returns ([RuneError], 0). Otherwise, if // the encoding is invalid, it returns (RuneError, 1). Both are impossible // results for correct, non-empty UTF-8. // @@ -276,8 +276,8 @@ func DecodeLastRune(p []byte) (r rune, size int) { return r, size } -// DecodeLastRuneInString is like DecodeLastRune but its input is a string. If -// s is empty it returns (RuneError, 0). Otherwise, if the encoding is invalid, +// DecodeLastRuneInString is like [DecodeLastRune] but its input is a string. If +// s is empty it returns ([RuneError], 0). Otherwise, if the encoding is invalid, // it returns (RuneError, 1). Both are impossible results for correct, // non-empty UTF-8. // @@ -337,7 +337,7 @@ func RuneLen(r rune) int { } // EncodeRune writes into p (which must be large enough) the UTF-8 encoding of the rune. -// If the rune is out of range, it writes the encoding of RuneError. +// If the rune is out of range, it writes the encoding of [RuneError]. // It returns the number of bytes written. func EncodeRune(p []byte, r rune) int { // Negative values are erroneous. Making it unsigned addresses the problem. @@ -371,7 +371,7 @@ func EncodeRune(p []byte, r rune) int { // AppendRune appends the UTF-8 encoding of r to the end of p and // returns the extended buffer. If the rune is out of range, -// it appends the encoding of RuneError. +// it appends the encoding of [RuneError]. func AppendRune(p []byte, r rune) []byte { // This function is inlineable for fast handling of ASCII. if uint32(r) <= rune1Max { @@ -433,7 +433,7 @@ func RuneCount(p []byte) int { return n } -// RuneCountInString is like RuneCount but its input is a string. +// RuneCountInString is like [RuneCount] but its input is a string. func RuneCountInString(s string) (n int) { ns := len(s) for i := 0; i < ns; n++ {