diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-03-13 03:14:00 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-03-13 03:14:00 +0000 |
commit | d297a0797d1c0955ceb923ca38ce0dfb13236337 (patch) | |
tree | b95e3ce4ddcfbfca070b4b78acceafd1e52e3fe5 | |
parent | 57379bd47411fff6b580260c90110fe221f608a6 (diff) | |
parent | 12bcfa5e9b104e2fceaf6a5207af0f718b01d96a (diff) | |
download | blueprint-android10-security-release.tar.gz |
Snap for 5370966 from 12bcfa5e9b104e2fceaf6a5207af0f718b01d96a to qt-releaseandroid-vts-10.0_r9android-vts-10.0_r8android-vts-10.0_r7android-vts-10.0_r6android-vts-10.0_r5android-vts-10.0_r4android-vts-10.0_r3android-vts-10.0_r2android-vts-10.0_r16android-vts-10.0_r15android-vts-10.0_r14android-vts-10.0_r13android-vts-10.0_r12android-vts-10.0_r11android-vts-10.0_r10android-vts-10.0_r1android-security-10.0.0_r75android-security-10.0.0_r74android-security-10.0.0_r73android-security-10.0.0_r72android-security-10.0.0_r71android-security-10.0.0_r70android-security-10.0.0_r69android-security-10.0.0_r68android-security-10.0.0_r67android-security-10.0.0_r66android-security-10.0.0_r65android-security-10.0.0_r64android-security-10.0.0_r63android-security-10.0.0_r62android-security-10.0.0_r61android-security-10.0.0_r60android-security-10.0.0_r59android-security-10.0.0_r58android-security-10.0.0_r57android-security-10.0.0_r56android-security-10.0.0_r55android-security-10.0.0_r54android-security-10.0.0_r53android-security-10.0.0_r52android-security-10.0.0_r51android-security-10.0.0_r50android-security-10.0.0_r49android-security-10.0.0_r48android-mainline-10.0.0_r3android-mainline-10.0.0_r2android-mainline-10.0.0_r1android-cts-10.0_r9android-cts-10.0_r8android-cts-10.0_r7android-cts-10.0_r6android-cts-10.0_r5android-cts-10.0_r4android-cts-10.0_r3android-cts-10.0_r2android-cts-10.0_r16android-cts-10.0_r15android-cts-10.0_r14android-cts-10.0_r13android-cts-10.0_r12android-cts-10.0_r11android-cts-10.0_r10android-cts-10.0_r1android-10.0.0_r6android-10.0.0_r5android-10.0.0_r47android-10.0.0_r46android-10.0.0_r4android-10.0.0_r3android-10.0.0_r2android-10.0.0_r17android-10.0.0_r11android-10.0.0_r10android-10.0.0_r1android10-tests-releaseandroid10-security-releaseandroid10-s3-releaseandroid10-s2-releaseandroid10-s1-releaseandroid10-releaseandroid10-mainline-releaseandroid10-mainline-a-release
Change-Id: I211848c40f27672e0217eed95251fa21b526c6c7
-rw-r--r-- | bootstrap/bpdoc/bpdoc.go | 2 | ||||
-rw-r--r-- | bootstrap/bpdoc/properties.go | 43 | ||||
-rw-r--r-- | bootstrap/bpdoc/reader.go | 2 | ||||
-rw-r--r-- | bootstrap/bpdoc/reader_test.go | 2 |
4 files changed, 26 insertions, 23 deletions
diff --git a/bootstrap/bpdoc/bpdoc.go b/bootstrap/bpdoc/bpdoc.go index ffb2cc0..8ce41cf 100644 --- a/bootstrap/bpdoc/bpdoc.go +++ b/bootstrap/bpdoc/bpdoc.go @@ -36,7 +36,7 @@ type ModuleType struct { PkgPath string // Text is the contents of the comment documenting the module type. - Text string + Text template.HTML // PropertyStructs is a list of PropertyStruct objects that contain information about each // property struct that is used by the module type, containing all properties that are valid diff --git a/bootstrap/bpdoc/properties.go b/bootstrap/bpdoc/properties.go index 1126752..23b1ffd 100644 --- a/bootstrap/bpdoc/properties.go +++ b/bootstrap/bpdoc/properties.go @@ -224,30 +224,11 @@ func structProperties(structType *ast.StructType) (props []Property, err error) typ = fmt.Sprintf("%T", f.Type) } - var html template.HTML - - lines := strings.Split(text, "\n") - preformatted := false - for _, line := range lines { - r, _ := utf8.DecodeRuneInString(line) - indent := unicode.IsSpace(r) - if indent && !preformatted { - html += "<pre>\n" - } else if !indent && preformatted { - html += "</pre>\n" - } - preformatted = indent - html += template.HTML(template.HTMLEscapeString(line)) + "\n" - } - if preformatted { - html += "</pre>\n" - } - props = append(props, Property{ Name: name, Type: typ, Tag: reflect.StructTag(tag), - Text: html, + Text: formatText(text), Properties: innerProps, }) } @@ -279,3 +260,25 @@ func filterPropsByTag(props *[]Property, key, value string, exclude bool) { *props = filtered } + +func formatText(text string) template.HTML { + var html template.HTML + lines := strings.Split(text, "\n") + preformatted := false + for _, line := range lines { + r, _ := utf8.DecodeRuneInString(line) + indent := unicode.IsSpace(r) + if indent && !preformatted { + html += "<pre>\n\n" + preformatted = true + } else if !indent && line != "" && preformatted { + html += "</pre>\n" + preformatted = false + } + html += template.HTML(template.HTMLEscapeString(line)) + "\n" + } + if preformatted { + html += "</pre>\n" + } + return html +} diff --git a/bootstrap/bpdoc/reader.go b/bootstrap/bpdoc/reader.go index 0a77844..a39ee3c 100644 --- a/bootstrap/bpdoc/reader.go +++ b/bootstrap/bpdoc/reader.go @@ -77,7 +77,7 @@ func (r *Reader) ModuleType(name string, factory reflect.Value) (*ModuleType, er return &ModuleType{ Name: name, PkgPath: pkgPath, - Text: text, + Text: formatText(text), }, nil } diff --git a/bootstrap/bpdoc/reader_test.go b/bootstrap/bpdoc/reader_test.go index 8545ac6..b8ff109 100644 --- a/bootstrap/bpdoc/reader_test.go +++ b/bootstrap/bpdoc/reader_test.go @@ -59,7 +59,7 @@ func TestModuleTypeDocs(t *testing.T) { t.Fatal(err) } - if mt.Text != "foo docs.\n" { + if mt.Text != "foo docs.\n\n" { t.Errorf("unexpected docs %q", mt.Text) } |