Skip to content

Commit 4f6490e

Browse files
authored
docs(readme): change default examples to use --output option (#45)
1 parent ace50af commit 4f6490e

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Flags:
5252
The gomarkdoc command processes each of the provided packages\, generating documentation for the package in markdown format and writing it to console\. For example\, if you have a package in your current directory and want to send it to a documentation markdown file\, you might do something like this:
5353

5454
```
55-
gomarkdoc . > doc.md
55+
gomarkdoc --output doc.md .
5656
```
5757

5858
### Package Specifiers
@@ -61,7 +61,13 @@ The gomarkdoc tool supports generating documentation for both local packages and
6161

6262
### Output Redirection
6363

64-
If you want to redirect output for each processed package to a file\, you can alternatively provide the \-\-output/\-o option\, which accepts a template specifying how to generate the path of the output file\. A common usage of this option is when generating README documentation for a package with subpackages \(which are supported via the \.\.\. signifier available in other tools\):
64+
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\.
65+
66+
```
67+
gomarkdoc . > doc.md
68+
```
69+
70+
If you want to redirect output for each processed package to a file\, you can provide the \-\-output/\-o option\, which accepts a template specifying how to generate the path of the output file\. A common usage of this option is when generating README documentation for a package with subpackages \(which are supported via the \.\.\. signifier as in other parts of the golang toolchain\)\. In addition\, this option provides consistent behavior across platforms and shells:
6571

6672
```
6773
gomarkdoc --output '{{.Dir}}/README.md' ./...
@@ -116,7 +122,7 @@ gomarkdoc -t package=custom-package.gotxt -t doc=custom-doc.gotxt .
116122
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\.
117123

118124
```
119-
gomarkdoc -u . > README.md
125+
gomarkdoc -u -o README.md .
120126
```
121127

122128
You can also run gomarkdoc in a verification mode with the \-\-check/\-c flag\. This is particularly useful for continuous integration when you want to make sure that a commit correctly updated the generated documentation\. This flag is only supported when the \-\-output/\-o flag is specified\, as the file provided there is what the tool is checking:

doc.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
// For example, if you have a package in your current directory and want to
4545
// send it to a documentation markdown file, you might do something like this:
4646
//
47-
// gomarkdoc . > doc.md
47+
// gomarkdoc --output doc.md .
4848
//
4949
// Package Specifiers
5050
//
@@ -57,12 +57,23 @@
5757
//
5858
// Output Redirection
5959
//
60+
// By default, the documentation generated by the gomarkdoc command is sent to
61+
// standard output, where it can be redirected to a file. This can be useful if
62+
// you want to perform additional modifications to the documentation or send it
63+
// somewhere other than a file. However, keep in mind that there are some
64+
// inconsistencies in how various shells/platforms handle redirected command
65+
// output (for example, Powershell encodes in UTF-16, not UTF-8). As a result,
66+
// the --output option described below is recommended for most use cases.
67+
//
68+
// gomarkdoc . > doc.md
69+
//
6070
// If you want to redirect output for each processed package to a file, you can
61-
// alternatively provide the --output/-o option, which accepts a template
62-
// specifying how to generate the path of the output file. A common usage of
63-
// this option is when generating README documentation for a package with
64-
// subpackages (which are supported via the ... signifier available in other
65-
// tools):
71+
// provide the --output/-o option, which accepts a template specifying how to
72+
// generate the path of the output file. A common usage of this option is when
73+
// generating README documentation for a package with subpackages (which are
74+
// supported via the ... signifier as in other parts of the golang toolchain).
75+
// In addition, this option provides consistent behavior across platforms and
76+
// shells:
6677
//
6778
// gomarkdoc --output '{{.Dir}}/README.md' ./...
6879
//
@@ -120,7 +131,7 @@
120131
// documentation. This can be expanded to include all symbols in a package by
121132
// adding the --include-unexported/-u flag.
122133
//
123-
// gomarkdoc -u . > README.md
134+
// gomarkdoc -u -o README.md .
124135
//
125136
// You can also run gomarkdoc in a verification mode with the --check/-c flag.
126137
// This is particularly useful for continuous integration when you want to make

0 commit comments

Comments
 (0)