Skip to content

Commit 988895a

Browse files
committed
Docs how to generate HTML and image files.
Thanks to @sindresorhus for the amazing pageres tool! ✨
1 parent 66a5504 commit 988895a

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Options:
5656
-u, --until <date> Optional end date.
5757
-g, --global-activity Shows global activity calendar in the current
5858
repository.
59-
-n, --no-ansi Forces the tool not to use ANSI styles.
59+
-n, --disable-ansi Forces the tool not to use ANSI styles.
6060
-l, --light Enables the light theme.
6161
-d, --data <path> Sets a custom data store file.
6262
-a, --authors Shows a pie chart with the author related
@@ -168,6 +168,33 @@ module.exports = {
168168

169169
Since it's a js file, you can `require` any other modules there.
170170

171+
## Saving the data as HTML and images
172+
173+
`git-stats --raw` outputs raw JSON format which can be consumed by other tools to generate results such as HTML files or images.
174+
175+
[`git-stats-html`](https://github.com/IonicaBizau/git-stats-html) interprets the JSON data and generates an HTML file. Example:
176+
177+
```sh
178+
# Install git-stats-html
179+
npm install -g git-stats-html
180+
181+
# Export the data from the last year (generate out.html)
182+
git-stats --raw | git-stats-html -o out.html
183+
184+
# Export data since 2015 (save the results in out.html)
185+
git-stats --since '1 January 2015' --raw | ./bin/git-stats-html -o out.html --big
186+
```
187+
188+
After we have the HTML file, we can generate an image file using [`pageres`](https://github.com/sindresorhus/pageres) by [**@sindresorhus**](https://github.com/sindresorhus/):
189+
190+
```sh
191+
# Install pageres
192+
npm install -g pageres-cli
193+
194+
# Generate the image from HTML
195+
pageres out.html 775x250
196+
```
197+
171198
## Cross-platform compatibility
172199

173200
`git-stats` is working fine in terminal emulators supporting ANSI styles. It should work fine on Linux and OS X.

package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,43 @@
216216
{
217217
"p": "Since it's a js file, you can `require` any other modules there."
218218
},
219+
{
220+
"h2": "Saving the data as HTML and images"
221+
},
222+
{
223+
"p": [
224+
"`git-stats --raw` outputs raw JSON format which can be consumed by other tools to generate results such as HTML files or images.",
225+
"[`git-stats-html`](https://github.com/IonicaBizau/git-stats-html) interprets the JSON data and generates an HTML file. Example:",
226+
{
227+
"code": {
228+
"content": [
229+
"# Install git-stats-html",
230+
"npm install -g git-stats-html",
231+
"",
232+
"# Export the data from the last year (generate out.html)",
233+
"git-stats --raw | git-stats-html -o out.html",
234+
"",
235+
"# Export data since 2015 (save the results in out.html)",
236+
"git-stats --since '1 January 2015' --raw | ./bin/git-stats-html -o out.html --big"
237+
],
238+
"language": "sh"
239+
}
240+
},
241+
"After we have the HTML file, we can generate an image file using [`pageres`](https://github.com/sindresorhus/pageres) by [**@sindresorhus**](https://github.com/sindresorhus/):",
242+
{
243+
"code": {
244+
"content": [
245+
"# Install pageres",
246+
"npm install -g pageres-cli",
247+
"",
248+
"# Generate the image from HTML",
249+
"pageres out.html 775x250"
250+
],
251+
"language": "sh"
252+
}
253+
}
254+
]
255+
},
219256
{
220257
"h2": "Cross-platform compatibility"
221258
},

0 commit comments

Comments
 (0)