Skip to content

Commit

Permalink
Update to Octicons v7.3.0, regenerate.
Browse files Browse the repository at this point in the history
Move constants on top of relevant function in generate.go.
This should make the code more readable.

Follows primer/octicons#220.
  • Loading branch information
dmitshur committed May 9, 2018
1 parent 91d1485 commit f448200
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 175 deletions.
2 changes: 1 addition & 1 deletion _data/data.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// Package octiconssvg provides GitHub Octicons in SVG format.
package octiconssvg

//go:generate curl -L -o octicons.tgz https://registry.npmjs.org/octicons/-/octicons-7.3.0.tgz
//go:generate tar -xf octicons.tgz package/build/data.json
//go:generate rm octicons.tgz
//go:generate mv package/build/data.json _data/data.json
//go:generate rmdir -p package/build
//go:generate go run generate.go -o octicons.go
//go:generate unconvert -apply
//go:generate gofmt -w -s octicons.go
18 changes: 9 additions & 9 deletions generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ func SetSize(icon *html.Node, size int) *html.Node {

type octicon struct {
Path string
Width int `json:",string"`
Height int `json:",string"`
Width int
Height int
}

func generateAndWriteOcticon(w io.Writer, octicons map[string]octicon, name string) {
Expand All @@ -128,6 +128,13 @@ func generateAndWriteOcticon(w io.Writer, octicons map[string]octicon, name stri
fmt.Fprintln(w, "}")
}

// These constants are used during generation of SetSize function.
// Keep them in sync with generateOcticon below.
const (
widthAttrIndex = 1
heightAttrIndex = 2
)

func generateOcticon(o octicon) (svgXML string) {
path := o.Path
if strings.HasPrefix(path, `<path fill-rule="evenodd" `) {
Expand All @@ -140,13 +147,6 @@ func generateOcticon(o octicon) (svgXML string) {
o.Width, o.Height, o.Width, o.Height, path)
}

// These constants are used during generation of SetSize function.
// Keep them in sync with generateOcticon.
const (
widthAttrIndex = 1
heightAttrIndex = 2
)

func parseOcticon(svgXML string) *html.Node {
e, err := html.ParseFragment(strings.NewReader(svgXML), nil)
if err != nil {
Expand Down
Loading

0 comments on commit f448200

Please sign in to comment.