@@ -21,15 +21,16 @@ type modules = map[string]versions
21
21
22
22
// Config is the structure passed to `Run`
23
23
type Config struct {
24
- repository string
25
- from string
26
- to string
27
- link bool
24
+ repository string
25
+ from string
26
+ to string
27
+ link bool
28
+ headerLevel uint
28
29
}
29
30
30
31
// NewConfig creates a new configuration
31
- func NewConfig (repository , from , to string , link bool ) * Config {
32
- return & Config {repository , from , to , link }
32
+ func NewConfig (repository , from , to string , link bool , headerLevel uint ) * Config {
33
+ return & Config {repository , from , to , link , headerLevel }
33
34
}
34
35
35
36
// Run starts go modiff and returns the markdown string
@@ -74,7 +75,7 @@ func Run(config *Config) (string, error) {
74
75
if err != nil {
75
76
return "" , err
76
77
}
77
- return diffModules (mods , config .link ), nil
78
+ return diffModules (mods , config .link , config . headerLevel ), nil
78
79
}
79
80
80
81
func toURL (name string ) string {
@@ -95,7 +96,7 @@ func logErr(msg interface{}) (string, error) {
95
96
return "" , err
96
97
}
97
98
98
- func diffModules (mods modules , addLinks bool ) string {
99
+ func diffModules (mods modules , addLinks bool , headerLevel uint ) string {
99
100
var added , removed , changed []string
100
101
for name , mod := range mods {
101
102
txt := fmt .Sprintf ("- %s: " , name )
@@ -135,9 +136,13 @@ func diffModules(mods modules, addLinks bool) string {
135
136
136
137
// Pretty print
137
138
builder := & strings.Builder {}
138
- builder .WriteString ("# Dependencies\n " )
139
+ builder .WriteString (fmt .Sprintf (
140
+ "%s Dependencies\n " , strings .Repeat ("#" , int (headerLevel )),
141
+ ))
139
142
forEach := func (section string , input []string ) {
140
- builder .WriteString (fmt .Sprintf ("\n ## %s\n " , section ))
143
+ builder .WriteString (fmt .Sprintf ("\n %s %s\n " ,
144
+ strings .Repeat ("#" , int (headerLevel )+ 1 ), section ,
145
+ ))
141
146
if len (input ) > 0 {
142
147
for _ , mod := range input {
143
148
builder .WriteString (fmt .Sprintf ("%s\n " , mod ))
0 commit comments