Skip to content

Commit 51955d2

Browse files
committed
remove x/net codegen dependency
1 parent 494f482 commit 51955d2

File tree

19 files changed

+136
-156
lines changed

19 files changed

+136
-156
lines changed

go.mod

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,4 @@ module github.com/aws/aws-sdk-go
22

33
go 1.19
44

5-
require (
6-
github.com/jmespath/go-jmespath v0.4.0
7-
golang.org/x/net v0.17.0
8-
)
9-
10-
require golang.org/x/text v0.13.0 // indirect
5+
require github.com/jmespath/go-jmespath v0.4.0

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC
77
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
88
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
99
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
10-
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
11-
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
12-
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
13-
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
1410
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1511
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
1612
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

private/model/api/docstring.go

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ package api
66
import (
77
"bufio"
88
"encoding/json"
9+
"encoding/xml"
910
"fmt"
1011
"html"
1112
"io"
1213
"log"
1314
"os"
1415
"regexp"
1516
"strings"
16-
17-
xhtml "golang.org/x/net/html"
18-
"golang.org/x/net/html/atom"
1917
)
2018

2119
type apiDocumentation struct {
@@ -225,12 +223,17 @@ func getLeadingWhitespace(v string) string {
225223

226224
// generateDoc will generate the proper doc string for html encoded or plain text doc entries.
227225
func generateDoc(htmlSrc string) string {
228-
tokenizer := xhtml.NewTokenizer(strings.NewReader(htmlSrc))
226+
tokenizer := xml.NewDecoder(strings.NewReader(htmlSrc))
227+
tokenizer.Strict = false
228+
tokenizer.AutoClose = xml.HTMLAutoClose
229+
tokenizer.Entity = xml.HTMLEntity
230+
231+
// Some service docstrings are hopelessly malformed. Rather than throwing
232+
// up our hands, the converter will map over as much as it can. If it
233+
// returns an error, we stop there and go with whatever it was able to
234+
// produce.
229235
var builder strings.Builder
230-
if err := encodeHTMLToText(&builder, tokenizer); err != nil {
231-
panic(fmt.Sprintf("failed to generated docs, %v", err))
232-
}
233-
236+
encodeHTMLToText(&builder, tokenizer)
234237
return wrap(strings.Trim(builder.String(), "\n"), 72)
235238
}
236239

@@ -241,31 +244,30 @@ type stringWriter interface {
241244
WriteString(string) (int, error)
242245
}
243246

244-
func encodeHTMLToText(w stringWriter, z *xhtml.Tokenizer) error {
247+
func encodeHTMLToText(w stringWriter, z *xml.Decoder) error {
245248
encoder := newHTMLTokenEncoder(w)
246249
defer encoder.Flush()
247250

248251
for {
249-
tt := z.Next()
250-
if tt == xhtml.ErrorToken {
251-
if err := z.Err(); err == io.EOF {
252-
return nil
253-
} else if err != nil {
254-
return err
255-
}
252+
tt, err := z.Token()
253+
if err == io.EOF {
254+
return nil
255+
}
256+
if err != nil {
257+
return err
256258
}
257259

258-
if err := encoder.Encode(z.Token()); err != nil {
260+
if err := encoder.Encode(tt); err != nil {
259261
return err
260262
}
261263
}
262264
}
263265

264266
type htmlTokenHandler interface {
265-
OnStartTagToken(xhtml.Token) htmlTokenHandler
266-
OnEndTagToken(xhtml.Token, bool)
267-
OnSelfClosingTagToken(xhtml.Token)
268-
OnTextTagToken(xhtml.Token)
267+
OnStartTagToken(xml.StartElement) htmlTokenHandler
268+
OnEndTagToken(xml.Token, bool)
269+
OnSelfClosingTagToken(xml.Token)
270+
OnTextTagToken(xml.CharData)
269271
}
270272

271273
type htmlTokenEncoder struct {
@@ -293,29 +295,29 @@ func newHTMLTokenEncoder(w stringWriter) *htmlTokenEncoder {
293295
}
294296

295297
func (e *htmlTokenEncoder) Flush() error {
296-
e.baseHandler.handler.OnEndTagToken(xhtml.Token{Type: xhtml.TextToken}, true)
298+
e.baseHandler.handler.OnEndTagToken(xml.CharData([]byte{}), true)
297299
return nil
298300
}
299301

300-
func (e *htmlTokenEncoder) Encode(token xhtml.Token) error {
302+
func (e *htmlTokenEncoder) Encode(token xml.Token) error {
301303
h := e.baseHandler
302304
if len(e.handlers) != 0 {
303305
h = e.handlers[len(e.handlers)-1]
304306
}
305307

306-
switch token.Type {
307-
case xhtml.StartTagToken:
308+
switch v := token.(type) {
309+
case xml.StartElement:
308310
e.depth++
309311

310-
next := h.handler.OnStartTagToken(token)
312+
next := h.handler.OnStartTagToken(v)
311313
if next != nil {
312314
e.handlers = append(e.handlers, tokenHandlerItem{
313315
handler: next,
314316
depth: e.depth,
315317
})
316318
}
317319

318-
case xhtml.EndTagToken:
320+
case xml.EndElement:
319321
handlerBlockClosing := e.depth == h.depth
320322

321323
h.handler.OnEndTagToken(token, handlerBlockClosing)
@@ -330,11 +332,12 @@ func (e *htmlTokenEncoder) Encode(token xhtml.Token) error {
330332
e.depth = 0
331333
}
332334

333-
case xhtml.SelfClosingTagToken:
334-
h.handler.OnSelfClosingTagToken(token)
335+
// TODO
336+
////case xml.SelfClosingTagToken:
337+
//// h.handler.OnSelfClosingTagToken(token)
335338

336-
case xhtml.TextToken:
337-
h.handler.OnTextTagToken(token)
339+
case xml.CharData:
340+
h.handler.OnTextTagToken(v)
338341
}
339342

340343
return nil
@@ -344,11 +347,11 @@ type baseTokenHandler struct {
344347
w stringWriter
345348
}
346349

347-
func (e *baseTokenHandler) OnStartTagToken(token xhtml.Token) htmlTokenHandler { return nil }
348-
func (e *baseTokenHandler) OnEndTagToken(token xhtml.Token, blockClosing bool) {}
349-
func (e *baseTokenHandler) OnSelfClosingTagToken(token xhtml.Token) {}
350-
func (e *baseTokenHandler) OnTextTagToken(token xhtml.Token) {
351-
e.w.WriteString(token.Data)
350+
func (e *baseTokenHandler) OnStartTagToken(token xml.StartElement) htmlTokenHandler { return nil }
351+
func (e *baseTokenHandler) OnEndTagToken(token xml.Token, blockClosing bool) {}
352+
func (e *baseTokenHandler) OnSelfClosingTagToken(token xml.Token) {}
353+
func (e *baseTokenHandler) OnTextTagToken(token xml.CharData) {
354+
e.w.WriteString(string(token))
352355
}
353356

354357
type blockTokenHandler struct {
@@ -372,27 +375,27 @@ func newBlockTokenHandler(w stringWriter) *blockTokenHandler {
372375
},
373376
}
374377
}
375-
func (e *blockTokenHandler) OnStartTagToken(token xhtml.Token) htmlTokenHandler {
378+
func (e *blockTokenHandler) OnStartTagToken(token xml.StartElement) htmlTokenHandler {
376379
e.started = true
377380
if e.newlineBeforeNextBlock {
378381
e.w.WriteString("\n")
379382
e.newlineBeforeNextBlock = false
380383
}
381384

382-
switch token.DataAtom {
383-
case atom.A:
385+
switch token.Name.Local {
386+
case "a":
384387
return newLinkTokenHandler(e.w, token)
385-
case atom.Ul:
388+
case "ul":
386389
e.w.WriteString("\n")
387390
e.newlineBeforeNextBlock = true
388391
return newListTokenHandler(e.w)
389392

390-
case atom.Div, atom.Dt, atom.P, atom.H1, atom.H2, atom.H3, atom.H4, atom.H5, atom.H6:
393+
case "div", "dt", "p", "h1", "h2", "h3", "h4", "h5", "h6":
391394
e.w.WriteString("\n")
392395
e.newlineBeforeNextBlock = true
393396
return newBlockTokenHandler(e.w)
394397

395-
case atom.Pre, atom.Code:
398+
case "pre", "code":
396399
if e.rootBlock {
397400
e.w.WriteString("\n")
398401
e.w.WriteString(indent)
@@ -403,7 +406,7 @@ func (e *blockTokenHandler) OnStartTagToken(token xhtml.Token) htmlTokenHandler
403406

404407
return nil
405408
}
406-
func (e *blockTokenHandler) OnEndTagToken(token xhtml.Token, blockClosing bool) {
409+
func (e *blockTokenHandler) OnEndTagToken(token xml.Token, blockClosing bool) {
407410
if !blockClosing {
408411
return
409412
}
@@ -417,34 +420,34 @@ func (e *blockTokenHandler) OnEndTagToken(token xhtml.Token, blockClosing bool)
417420
e.strBuilder.Reset()
418421
}
419422

420-
func (e *blockTokenHandler) OnTextTagToken(token xhtml.Token) {
423+
func (e *blockTokenHandler) OnTextTagToken(token xml.CharData) {
421424
if e.newlineBeforeNextBlock {
422425
e.w.WriteString("\n")
423426
e.newlineBeforeNextBlock = false
424427
}
425428
if !e.started {
426-
token.Data = strings.TrimLeft(token.Data, " \t\n")
429+
token = xml.CharData(strings.TrimLeft(string(token), " \t\n"))
427430
}
428-
if len(token.Data) != 0 {
431+
if len(token) != 0 {
429432
e.started = true
430433
}
431434
e.baseTokenHandler.OnTextTagToken(token)
432435
}
433436

434437
type linkTokenHandler struct {
435438
baseTokenHandler
436-
linkToken xhtml.Token
439+
linkToken xml.StartElement
437440
}
438441

439-
func newLinkTokenHandler(w stringWriter, token xhtml.Token) *linkTokenHandler {
442+
func newLinkTokenHandler(w stringWriter, token xml.StartElement) *linkTokenHandler {
440443
return &linkTokenHandler{
441444
baseTokenHandler: baseTokenHandler{
442445
w: w,
443446
},
444447
linkToken: token,
445448
}
446449
}
447-
func (e *linkTokenHandler) OnEndTagToken(token xhtml.Token, blockClosing bool) {
450+
func (e *linkTokenHandler) OnEndTagToken(token xml.Token, blockClosing bool) {
448451
if !blockClosing {
449452
return
450453
}
@@ -467,9 +470,9 @@ func newListTokenHandler(w stringWriter) *listTokenHandler {
467470
},
468471
}
469472
}
470-
func (e *listTokenHandler) OnStartTagToken(token xhtml.Token) htmlTokenHandler {
471-
switch token.DataAtom {
472-
case atom.Li:
473+
func (e *listTokenHandler) OnStartTagToken(token xml.StartElement) htmlTokenHandler {
474+
switch token.Name.Local {
475+
case "li":
473476
if e.items >= 1 {
474477
e.w.WriteString("\n\n")
475478
}
@@ -479,7 +482,7 @@ func (e *listTokenHandler) OnStartTagToken(token xhtml.Token) htmlTokenHandler {
479482
return nil
480483
}
481484

482-
func (e *listTokenHandler) OnTextTagToken(token xhtml.Token) {
485+
func (e *listTokenHandler) OnTextTagToken(token xml.CharData) {
483486
// Squash whitespace between list and items
484487
}
485488

@@ -500,14 +503,14 @@ func newListItemTokenHandler(w stringWriter) *listItemTokenHandler {
500503
},
501504
}
502505
}
503-
func (e *listItemTokenHandler) OnStartTagToken(token xhtml.Token) htmlTokenHandler {
504-
switch token.DataAtom {
505-
case atom.P:
506+
func (e *listItemTokenHandler) OnStartTagToken(token xml.StartElement) htmlTokenHandler {
507+
switch token.Name.Local {
508+
case "p":
506509
return newBlockTokenHandler(e.w)
507510
}
508511
return nil
509512
}
510-
func (e *listItemTokenHandler) OnEndTagToken(token xhtml.Token, blockClosing bool) {
513+
func (e *listItemTokenHandler) OnEndTagToken(token xml.Token, blockClosing bool) {
511514
if !blockClosing {
512515
return
513516
}
@@ -533,18 +536,18 @@ func newTrimSpaceTokenHandler(w stringWriter) *trimSpaceTokenHandler {
533536
},
534537
}
535538
}
536-
func (e *trimSpaceTokenHandler) OnEndTagToken(token xhtml.Token, blockClosing bool) {
539+
func (e *trimSpaceTokenHandler) OnEndTagToken(token xml.Token, blockClosing bool) {
537540
if !blockClosing {
538541
return
539542
}
540543

541544
e.origWriter.WriteString(strings.TrimSpace(e.strBuilder.String()))
542545
}
543546

544-
func getHTMLTokenAttr(attr []xhtml.Attribute, name string) (string, bool) {
547+
func getHTMLTokenAttr(attr []xml.Attr, name string) (string, bool) {
545548
for _, a := range attr {
546-
if strings.EqualFold(a.Key, name) {
547-
return a.Val, true
549+
if strings.EqualFold(a.Name.Local, name) {
550+
return a.Value, true
548551
}
549552
}
550553
return "", false

private/protocol/eventstream/eventstreamtest/setup_server.go

Lines changed: 0 additions & 15 deletions
This file was deleted.

private/protocol/eventstream/eventstreamtest/testing.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ const (
3333
http2StreamError = "stream error: stream ID"
3434
)
3535

36+
func setupServer(server *httptest.Server, useH2 bool) *http.Client {
37+
server.Start()
38+
39+
return nil
40+
}
41+
3642
// ServeEventStream provides serving EventStream messages from a HTTP server to
3743
// the client. The events are sent sequentially to the client without delay.
3844
type ServeEventStream struct {

service/acmpca/api.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)