Skip to content

Commit

Permalink
ditto
Browse files Browse the repository at this point in the history
  • Loading branch information
matryer committed Aug 4, 2024
1 parent 372f5e6 commit 52f5911
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
9 changes: 7 additions & 2 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ type Parser struct {
// objects marks object names.
objects map[string]struct{}

// SuppressErrorField suppresses the Error field in output objects.
SuppressErrorField bool

// docs are the docs for extracting comments.
docs *doc.Package
}
Expand Down Expand Up @@ -255,8 +258,10 @@ func (p *Parser) Parse() (Definition, error) {
sort.Slice(p.def.Objects, func(i, j int) bool {
return p.def.Objects[i].Name < p.def.Objects[j].Name
})
if err := p.addOutputFields(); err != nil {
return p.def, err
if !p.SuppressErrorField {
if err := p.addOutputFields(); err != nil {
return p.def, err
}
}
return p.def, nil
}
Expand Down
50 changes: 25 additions & 25 deletions render/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,37 @@ import (
//
// Examples
//
// "" => [""]
// "lowercase" => ["lowercase"]
// "Class" => ["Class"]
// "MyClass" => ["My", "Class"]
// "MyC" => ["My", "C"]
// "HTML" => ["HTML"]
// "PDFLoader" => ["PDF", "Loader"]
// "AString" => ["A", "String"]
// "SimpleXMLParser" => ["Simple", "XML", "Parser"]
// "vimRPCPlugin" => ["vim", "RPC", "Plugin"]
// "GL11Version" => ["GL", "11", "Version"]
// "99Bottles" => ["99", "Bottles"]
// "May5" => ["May", "5"]
// "BFG9000" => ["BFG", "9000"]
// "BöseÜberraschung" => ["Böse", "Überraschung"]
// "Two spaces" => ["Two", " ", "spaces"]
// "BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"]
// "" => [""]
// "lowercase" => ["lowercase"]
// "Class" => ["Class"]
// "MyClass" => ["My", "Class"]
// "MyC" => ["My", "C"]
// "HTML" => ["HTML"]
// "PDFLoader" => ["PDF", "Loader"]
// "AString" => ["A", "String"]
// "SimpleXMLParser" => ["Simple", "XML", "Parser"]
// "vimRPCPlugin" => ["vim", "RPC", "Plugin"]
// "GL11Version" => ["GL", "11", "Version"]
// "99Bottles" => ["99", "Bottles"]
// "May5" => ["May", "5"]
// "BFG9000" => ["BFG", "9000"]
// "BöseÜberraschung" => ["Böse", "Überraschung"]
// "Two spaces" => ["Two", " ", "spaces"]
// "BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"]
//
// Splitting rules
//
// 1) If string is not valid UTF-8, return it without splitting as
// 1. If string is not valid UTF-8, return it without splitting as
// single item array.
// 2) Assign all unicode characters into one of 4 sets: lower case
// 2. Assign all unicode characters into one of 4 sets: lower case
// letters, upper case letters, numbers, and all other characters.
// 3) Iterate through characters of string, introducing splits
// 3. Iterate through characters of string, introducing splits
// between adjacent characters that belong to different sets.
// 4) Iterate through array of split strings, and if a given string
// 4. Iterate through array of split strings, and if a given string
// is upper case:
// if subsequent string is lower case:
// move last character of upper case string to beginning of
// lower case string
// if subsequent string is lower case:
// move last character of upper case string to beginning of
// lower case string
func Split(src string) (entries []string) {
// don't split invalid utf8
if !utf8.ValidString(src) {
Expand Down Expand Up @@ -155,7 +155,7 @@ func camelizeUp(word string) string {

func isAcronym(word string) bool {
for _, ac := range baseAcronyms {
if strings.ToUpper(ac) == strings.ToUpper(word) {
if strings.EqualFold(ac, word) {
return true
}
}
Expand Down

0 comments on commit 52f5911

Please sign in to comment.