Skip to content

Commit 1144eca

Browse files
authored
chore(deps): update to go 1.20 and latest golangci-lint (#85)
1 parent 8850369 commit 1144eca

File tree

10 files changed

+96
-303
lines changed

10 files changed

+96
-303
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Install Go
1616
uses: actions/setup-go@v1
1717
with:
18-
go-version: 1.18.x
18+
go-version: 1.20.x
1919
- name: Run GoReleaser
2020
uses: goreleaser/goreleaser-action@v1
2121
with:

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Install Go
1818
uses: actions/setup-go@v1
1919
with:
20-
go-version: 1.18.x
20+
go-version: 1.20.x
2121
- name: Checkout code
2222
uses: actions/checkout@v2
2323
- name: Lint

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ issues:
4646
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
4747

4848
exclude-use-default: false
49+
50+
run:
51+
skip-dirs:
52+
- testData

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import "github.com/princjef/gomarkdoc"
1313

1414
Package gomarkdoc formats documentation for one or more packages as markdown for usage outside of the main https://pkg.go.dev site. It supports custom templates for tweaking representation of documentation at fine\-grained levels, exporting both exported and unexported symbols, and custom formatters for different backends.
1515

16-
### Command Line Usage
16+
\# Command Line Usage
1717

1818
If you want to use this package as a command\-line tool, you can install the command by running the following on go 1.16\+:
1919

@@ -64,11 +64,11 @@ The gomarkdoc command processes each of the provided packages, generating docume
6464
gomarkdoc --output doc.md .
6565
```
6666

67-
### Package Specifiers
67+
\# Package Specifiers
6868

6969
The gomarkdoc tool supports generating documentation for both local packages and remote ones. To specify a local package, start the name of the package with a period \(.\) or specify an absolute path on the filesystem. All other package signifiers are assumed to be remote packages. You may specify both local and remote packages in the same command invocation as separate arguments.
7070

71-
### Output Redirection
71+
\# Output Redirection
7272

7373
By default, the documentation generated by the gomarkdoc command is sent to standard output, where it can be redirected to a file. This can be useful if you want to perform additional modifications to the documentation or send it somewhere other than a file. However, keep in mind that there are some inconsistencies in how various shells/platforms handle redirected command output \(for example, Powershell encodes in UTF\-16, not UTF\-8\). As a result, the \-\-output option described below is recommended for most use cases.
7474

@@ -84,40 +84,40 @@ gomarkdoc --output '{{.Dir}}/README.md' ./...
8484

8585
You can see all of the data available to the output template in the PackageSpec struct in the github.com/princjef/gomarkdoc/cmd/gomarkdoc package.
8686

87-
### Template Overrides
87+
\# Template Overrides
8888

8989
The documentation information that is output is formatted using a series of text templates for the various components of the overall documentation which get generated. Higher level templates contain lower level templates, but any template may be replaced with an override template using the \-\-template/\-t option. The full list of templates that may be overridden are:
9090

9191
```
9292
- file: generates documentation for a file containing one or more
93-
packages, depending on how the tool is configured. This is the
94-
root template for documentation generation.
93+
packages, depending on how the tool is configured. This is the
94+
root template for documentation generation.
9595
9696
- package: generates documentation for an entire package.
9797
9898
- type: generates documentation for a single type declaration, as well
99-
as any related functions/methods.
99+
as any related functions/methods.
100100
101101
- func: generates documentation for a single function or method. It may
102-
be referenced from within a type, or directly in the package,
103-
depending on nesting.
102+
be referenced from within a type, or directly in the package,
103+
depending on nesting.
104104
105105
- value: generates documentation for a single variable or constant
106-
declaration block within a package.
106+
declaration block within a package.
107107
108108
- index: generates an index of symbols within a package, similar to what
109-
is seen for godoc.org. The index links to types, funcs,
110-
variables, and constants generated by other templates, so it may
111-
need to be overridden as well if any of those templates are
112-
changed in a material way.
109+
is seen for godoc.org. The index links to types, funcs,
110+
variables, and constants generated by other templates, so it may
111+
need to be overridden as well if any of those templates are
112+
changed in a material way.
113113
114114
- example: generates documentation for a single example for a package or
115-
one of its symbols. The example is generated alongside whichever
116-
symbol it represents, based on the standard naming conventions
117-
outlined in https://blog.golang.org/examples#TOC_4.
115+
one of its symbols. The example is generated alongside whichever
116+
symbol it represents, based on the standard naming conventions
117+
outlined in https://blog.golang.org/examples#TOC_4.
118118
119119
- doc: generates the freeform documentation block for any of the above
120-
structures that can contain a documentation section.
120+
structures that can contain a documentation section.
121121
122122
- import: generates the import code used to pull in a package.
123123
```
@@ -128,7 +128,7 @@ Overriding with the \-t option uses a key\-vaule pair mapping a template name to
128128
gomarkdoc -t package=custom-package.gotxt -t doc=custom-doc.gotxt .
129129
```
130130

131-
### Additional Options
131+
\# Additional Options
132132

133133
As with the godoc tool itself, only exported symbols will be shown in documentation. This can be expanded to include all symbols in a package by adding the \-\-include\-unexported/\-u flag.
134134

@@ -182,13 +182,13 @@ Some features of gomarkdoc rely on being able to detect information from the git
182182
gomarkdoc --repository.url "https://github.com/princjef/gomarkdoc" --repository.default-branch master --repository.path / -o README.md .
183183
```
184184

185-
### Configuring via File
185+
\# Configuring via File
186186

187187
If you want to reuse configuration options across multiple invocations, you can specify a file in the folder where you invoke gomarkdoc containing configuration information that you would otherwise provide on the command line. This file may be a JSON, TOML, YAML, HCL, env, or Java properties file, but the name is expected to start with .gomarkdoc \(e.g. .gomarkdoc.yml\).
188188

189189
All configuration options are available with the camel\-cased form of their long name \(e.g. \-\-include\-unexported becomes includeUnexported\). Template overrides are specified as a map, rather than a set of key\-value pairs separated by =. Options provided on the command line override those provided in the configuration file if an option is present in both.
190190

191-
### Programmatic Usage
191+
\# Programmatic Usage
192192

193193
While most users will find the command line utility sufficient for their needs, this package may also be used programmatically by installing it directly, rather than its command subpackage. The programmatic usage provides more flexibility when selecting what packages to work with and what components to generate documentation for.
194194

@@ -237,7 +237,7 @@ func main() {
237237
}
238238
```
239239

240-
### Examples
240+
\# Examples
241241

242242
This project uses itself to generate the README files in github.com/princjef/gomarkdoc and its subdirectories. To see the commands that are run to generate documentation for this repository, take a look at the Doc\(\) and DocVerify\(\) functions in magefile.go and the .gomarkdoc.yml file in the root of this repository. To run these commands in your own project, simply replace \`go run ./cmd/gomarkdoc\` with \`gomarkdoc\`.
243243

doc.go

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// levels, exporting both exported and unexported symbols, and custom formatters
55
// for different backends.
66
//
7-
// Command Line Usage
7+
// # Command Line Usage
88
//
99
// If you want to use this package as a command-line tool, you can install the
1010
// command by running the following on go 1.16+:
@@ -21,29 +21,29 @@
2121
// $ gomarkdoc --help
2222
// generate markdown documentation for golang code
2323
//
24-
// Usage:
25-
// gomarkdoc [flags] [package ...]
26-
//
27-
// Flags:
28-
// -c, --check Check the output to see if it matches the generated documentation. --output must be specified to use this.
29-
// --config string File from which to load configuration (default: .gomarkdoc.yml)
30-
// -e, --embed Embed documentation into existing markdown files if available, otherwise append to file.
31-
// --footer string Additional content to inject at the end of each output file.
32-
// --footer-file string File containing additional content to inject at the end of each output file.
33-
// -f, --format string Format to use for writing output data. Valid options: github (default), azure-devops, plain (default "github")
34-
// --header string Additional content to inject at the beginning of each output file.
35-
// --header-file string File containing additional content to inject at the beginning of each output file.
36-
// -h, --help help for gomarkdoc
37-
// -u, --include-unexported Output documentation for unexported symbols, methods and fields in addition to exported ones.
38-
// -o, --output string File or pattern specifying where to write documentation output. Defaults to printing to stdout.
39-
// --repository.default-branch string Manual override for the git repository URL used in place of automatic detection.
40-
// --repository.path string Manual override for the path from the root of the git repository used in place of automatic detection.
41-
// --repository.url string Manual override for the git repository URL used in place of automatic detection.
24+
// Usage:
25+
// gomarkdoc [flags] [package ...]
26+
//
27+
// Flags:
28+
// -c, --check Check the output to see if it matches the generated documentation. --output must be specified to use this.
29+
// --config string File from which to load configuration (default: .gomarkdoc.yml)
30+
// -e, --embed Embed documentation into existing markdown files if available, otherwise append to file.
31+
// --footer string Additional content to inject at the end of each output file.
32+
// --footer-file string File containing additional content to inject at the end of each output file.
33+
// -f, --format string Format to use for writing output data. Valid options: github (default), azure-devops, plain (default "github")
34+
// --header string Additional content to inject at the beginning of each output file.
35+
// --header-file string File containing additional content to inject at the beginning of each output file.
36+
// -h, --help help for gomarkdoc
37+
// -u, --include-unexported Output documentation for unexported symbols, methods and fields in addition to exported ones.
38+
// -o, --output string File or pattern specifying where to write documentation output. Defaults to printing to stdout.
39+
// --repository.default-branch string Manual override for the git repository URL used in place of automatic detection.
40+
// --repository.path string Manual override for the path from the root of the git repository used in place of automatic detection.
41+
// --repository.url string Manual override for the git repository URL used in place of automatic detection.
4242
// --tags strings Set of build tags to apply when choosing which files to include for documentation generation.
43-
// -t, --template stringToString Custom template string to use for the provided template name instead of the default template. (default [])
44-
// --template-file stringToString Custom template file to use for the provided template name instead of the default template. (default [])
45-
// -v, --verbose count Log additional output from the execution of the command. Can be chained for additional verbosity.
46-
// --version Print the version.
43+
// -t, --template stringToString Custom template string to use for the provided template name instead of the default template. (default [])
44+
// --template-file stringToString Custom template file to use for the provided template name instead of the default template. (default [])
45+
// -v, --verbose count Log additional output from the execution of the command. Can be chained for additional verbosity.
46+
// --version Print the version.
4747
//
4848
// The gomarkdoc command processes each of the provided packages, generating
4949
// documentation for the package in markdown format and writing it to console.
@@ -52,7 +52,7 @@
5252
//
5353
// gomarkdoc --output doc.md .
5454
//
55-
// Package Specifiers
55+
// # Package Specifiers
5656
//
5757
// The gomarkdoc tool supports generating documentation for both local packages
5858
// and remote ones. To specify a local package, start the name of the package
@@ -61,7 +61,7 @@
6161
// local and remote packages in the same command invocation as separate
6262
// arguments.
6363
//
64-
// Output Redirection
64+
// # Output Redirection
6565
//
6666
// By default, the documentation generated by the gomarkdoc command is sent to
6767
// standard output, where it can be redirected to a file. This can be useful if
@@ -87,53 +87,53 @@
8787
// PackageSpec struct in the github.com/princjef/gomarkdoc/cmd/gomarkdoc
8888
// package.
8989
//
90-
// Template Overrides
90+
// # Template Overrides
9191
//
9292
// The documentation information that is output is formatted using a series of
9393
// text templates for the various components of the overall documentation which
9494
// get generated. Higher level templates contain lower level templates, but
9595
// any template may be replaced with an override template using the
9696
// --template/-t option. The full list of templates that may be overridden are:
9797
//
98-
// - file: generates documentation for a file containing one or more
99-
// packages, depending on how the tool is configured. This is the
100-
// root template for documentation generation.
98+
// - file: generates documentation for a file containing one or more
99+
// packages, depending on how the tool is configured. This is the
100+
// root template for documentation generation.
101101
//
102-
// - package: generates documentation for an entire package.
102+
// - package: generates documentation for an entire package.
103103
//
104-
// - type: generates documentation for a single type declaration, as well
105-
// as any related functions/methods.
104+
// - type: generates documentation for a single type declaration, as well
105+
// as any related functions/methods.
106106
//
107-
// - func: generates documentation for a single function or method. It may
108-
// be referenced from within a type, or directly in the package,
109-
// depending on nesting.
107+
// - func: generates documentation for a single function or method. It may
108+
// be referenced from within a type, or directly in the package,
109+
// depending on nesting.
110110
//
111-
// - value: generates documentation for a single variable or constant
112-
// declaration block within a package.
111+
// - value: generates documentation for a single variable or constant
112+
// declaration block within a package.
113113
//
114-
// - index: generates an index of symbols within a package, similar to what
115-
// is seen for godoc.org. The index links to types, funcs,
116-
// variables, and constants generated by other templates, so it may
117-
// need to be overridden as well if any of those templates are
118-
// changed in a material way.
114+
// - index: generates an index of symbols within a package, similar to what
115+
// is seen for godoc.org. The index links to types, funcs,
116+
// variables, and constants generated by other templates, so it may
117+
// need to be overridden as well if any of those templates are
118+
// changed in a material way.
119119
//
120-
// - example: generates documentation for a single example for a package or
121-
// one of its symbols. The example is generated alongside whichever
122-
// symbol it represents, based on the standard naming conventions
123-
// outlined in https://blog.golang.org/examples#TOC_4.
120+
// - example: generates documentation for a single example for a package or
121+
// one of its symbols. The example is generated alongside whichever
122+
// symbol it represents, based on the standard naming conventions
123+
// outlined in https://blog.golang.org/examples#TOC_4.
124124
//
125-
// - doc: generates the freeform documentation block for any of the above
126-
// structures that can contain a documentation section.
125+
// - doc: generates the freeform documentation block for any of the above
126+
// structures that can contain a documentation section.
127127
//
128-
// - import: generates the import code used to pull in a package.
128+
// - import: generates the import code used to pull in a package.
129129
//
130130
// Overriding with the -t option uses a key-vaule pair mapping a template name
131131
// to the file containing the contents of the override template to use.
132132
// Specified template files must exist:
133133
//
134134
// gomarkdoc -t package=custom-package.gotxt -t doc=custom-doc.gotxt .
135135
//
136-
// Additional Options
136+
// # Additional Options
137137
//
138138
// As with the godoc tool itself, only exported symbols will be shown in
139139
// documentation. This can be expanded to include all symbols in a package by
@@ -148,21 +148,21 @@
148148
// written and embeds the documentation if present. Otherwise, the documentation
149149
// is appended to the end of the file.
150150
//
151-
// gomarkdoc -o README.md -e .
151+
// gomarkdoc -o README.md -e .
152152
//
153153
// When running with embed mode enabled, gomarkdoc will look for either this
154154
// single comment:
155155
//
156-
// <!-- gomarkdoc:embed -->
156+
// <!-- gomarkdoc:embed -->
157157
//
158158
// Or the following pair of comments (in which case all content in between is
159159
// replaced):
160160
//
161-
// <!-- gomarkdoc:embed:start -->
161+
// <!-- gomarkdoc:embed:start -->
162162
//
163-
// This content is replaced with the embedded documentation
163+
// This content is replaced with the embedded documentation
164164
//
165-
// <!-- gomarkdoc:embed:end -->
165+
// <!-- gomarkdoc:embed:end -->
166166
//
167167
// If you would like to include files that are part of a build tag, you can
168168
// specify build tags with the --tags flag. Tags are also supported through
@@ -195,7 +195,7 @@
195195
//
196196
// gomarkdoc --repository.url "https://github.com/princjef/gomarkdoc" --repository.default-branch master --repository.path / -o README.md .
197197
//
198-
// Configuring via File
198+
// # Configuring via File
199199
//
200200
// If you want to reuse configuration options across multiple invocations, you
201201
// can specify a file in the folder where you invoke gomarkdoc containing
@@ -210,7 +210,7 @@
210210
// separated by =. Options provided on the command line override those provided
211211
// in the configuration file if an option is present in both.
212212
//
213-
// Programmatic Usage
213+
// # Programmatic Usage
214214
//
215215
// While most users will find the command line utility sufficient for their
216216
// needs, this package may also be used programmatically by installing it
@@ -261,7 +261,7 @@
261261
// fmt.Println(out.Package(pkg))
262262
// }
263263
//
264-
// Examples
264+
// # Examples
265265
//
266266
// This project uses itself to generate the README files in
267267
// github.com/princjef/gomarkdoc and its subdirectories. To see the commands

format/devops_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ func TestRawHeader(t *testing.T) {
9797

9898
func TestLocalHref(t *testing.T) {
9999
tests := map[string]string{
100-
"Normal Header": "#normal-header",
101-
" Leading whitespace": "#leading-whitespace",
102-
"Multiple whitespace": "#multiple--whitespace",
100+
"Normal Header": "#normal-header",
101+
" Leading whitespace": "#leading-whitespace",
102+
"Multiple whitespace": "#multiple--whitespace",
103103
"Special(#)%^Characters": "#special%28%23%29%25%5Echaracters",
104104
"With:colon": "#with%3Acolon",
105105
}

0 commit comments

Comments
 (0)