Skip to content

Commit

Permalink
Use Glamour's ASCII style for rendering docs
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Jan 6, 2020
1 parent 3df4931 commit 128c291
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 123 deletions.
3 changes: 1 addition & 2 deletions cmd/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/charmbracelet/glamour"
"github.com/mattn/go-isatty"
"github.com/spf13/cobra"
"github.com/twpayne/chezmoi/internal/chezmoi"
"golang.org/x/crypto/ssh/terminal"
)

Expand Down Expand Up @@ -70,7 +69,7 @@ func (c *Config) runDocsCmd(cmd *cobra.Command, args []string) error {
}

tr, err := glamour.NewTermRenderer(
glamour.WithStyles(chezmoi.ANSIStyleConfig),
glamour.WithStyles(glamour.ASCIIStyleConfig),
glamour.WithWordWrap(width),
)
if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/Masterminds/goutils v1.1.0 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/charmbracelet/glamour v0.0.0-20191228065158-2023fdc9f6fd
github.com/charmbracelet/glamour v0.0.0-20200106073151-6e19bd5b4861
github.com/coreos/go-semver v0.3.0
github.com/dlclark/regexp2 v1.2.0 // indirect
github.com/gobuffalo/envy v1.8.1 // indirect
Expand All @@ -20,14 +20,13 @@ require (
github.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95 // indirect
github.com/huandu/xstrings v1.2.1 // indirect
github.com/imdario/mergo v0.3.8 // indirect
github.com/kr/text v0.1.0
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 // indirect
github.com/mattn/go-isatty v0.0.11
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/pkg/diff v0.0.0-20190930165518-531926345625
github.com/rogpeppe/go-internal v1.5.0 // indirect
github.com/russross/blackfriday/v2 v2.0.1
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cobra v0.0.5
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand All @@ -39,7 +38,7 @@ require (
github.com/twpayne/go-vfs v1.3.6
github.com/twpayne/go-vfsafero v1.0.0
github.com/twpayne/go-xdg/v3 v3.1.0
github.com/yuin/goldmark v1.1.19
github.com/yuin/goldmark v1.1.20 // indirect
github.com/zalando/go-keyring v0.0.0-20191212171435-ac5f1d08068b
go.etcd.io/bbolt v1.3.3
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/charmbracelet/glamour v0.0.0-20191228065158-2023fdc9f6fd h1:8nFcGlPpvtKV98fQs1SXuXSAJWW9FC/QkQyVnsRnhJE=
github.com/charmbracelet/glamour v0.0.0-20191228065158-2023fdc9f6fd/go.mod h1:pnwzzHkgr91y3cCdPydiwDkJjApGSkUCXj2kYJyVQM8=
github.com/charmbracelet/glamour v0.0.0-20200106073151-6e19bd5b4861 h1:a1LTqfNL2HvwyxUxeXRA3+FEV6Q0BcAxqHr09pCgZlM=
github.com/charmbracelet/glamour v0.0.0-20200106073151-6e19bd5b4861/go.mod h1:Z1C2JkVGBom/RYfoKcPBZ81lHMR3xp3W6OCLNWWEIMc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down Expand Up @@ -140,6 +140,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/logrusorgru/aurora v0.0.0-20191116043053-66b7ad493a23 h1:Wp7NjqGKGN9te9N/rvXYRhlVcrulGdxnz8zadXWs7fc=
github.com/logrusorgru/aurora v0.0.0-20191116043053-66b7ad493a23/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 h1:bqDmpDG49ZRnB5PcgP0RXtQvnMSgIF14M7CBd2shtXs=
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
Expand Down Expand Up @@ -190,8 +192,6 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rakyll/statik v0.1.6 h1:uICcfUXpgqtw2VopbIncslhAmE5hwc4g20TEyEENBNs=
github.com/rakyll/statik v0.1.6/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk=
Expand Down Expand Up @@ -261,10 +261,10 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yuin/goldmark v1.1.16 h1:S2woQOeBdzkMSw+PPqfuVpYD+tEXhLCDtoWZcqL4jQs=
github.com/yuin/goldmark v1.1.16/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.19 h1:0s2/60x0XsFCXHeFut+F3azDVAAyIMyUfJRbRexiTYs=
github.com/yuin/goldmark v1.1.19/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.20 h1:WZzdEFW2cYKjlc9wvNRh1+t2n7m8h+g0mB0ssg9nzHQ=
github.com/yuin/goldmark v1.1.20/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/zalando/go-keyring v0.0.0-20191212171435-ac5f1d08068b h1:1qTomCI2pk/vHuNDwNoIE9/sFZCmASzjKYy7AkbjKA4=
github.com/zalando/go-keyring v0.0.0-20191212171435-ac5f1d08068b/go.mod h1:RaxNwUITJaHVdQ0VC7pELPZ3tOWn13nr0gZMZEhpVU0=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
Expand Down
107 changes: 0 additions & 107 deletions internal/chezmoi/styleconfig.go

This file was deleted.

6 changes: 2 additions & 4 deletions internal/extract-helps/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"text/template"

"github.com/charmbracelet/glamour"
"github.com/twpayne/chezmoi/internal/chezmoi"
)

var (
Expand Down Expand Up @@ -76,7 +75,7 @@ func printMultiLineString(s, indent string) string {
}

func extractHelps(r io.Reader) (map[string]*help, error) {
longStyleConfig := chezmoi.ANSIStyleConfig
longStyleConfig := glamour.ASCIIStyleConfig
longStyleConfig.H4.Prefix = ""
longTermRenderer, err := glamour.NewTermRenderer(
glamour.WithStyles(longStyleConfig),
Expand All @@ -86,7 +85,7 @@ func extractHelps(r io.Reader) (map[string]*help, error) {
return nil, err
}

examplesStyleConfig := chezmoi.ANSIStyleConfig
examplesStyleConfig := glamour.ASCIIStyleConfig
examplesStyleConfig.Document.Indent = nil
examplesTermRenderer, err := glamour.NewTermRenderer(
glamour.WithStyles(examplesStyleConfig),
Expand Down Expand Up @@ -134,7 +133,6 @@ func extractHelps(r io.Reader) (map[string]*help, error) {
s := bufio.NewScanner(r)
FOR:
for s.Scan() {
// fmt.Printf("%s: %q\n", state, s.Text())
switch state {
case "find-commands":
if commandsRegexp.MatchString(s.Text()) {
Expand Down

0 comments on commit 128c291

Please sign in to comment.