From 988895afef607f26e603329a52e1ae41a333e420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Wed, 26 Oct 2016 16:00:52 +0300 Subject: [PATCH] Docs how to generate HTML and image files. Thanks to @sindresorhus for the amazing pageres tool! :sparkles: --- README.md | 29 ++++++++++++++++++++++++++++- package.json | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bb0d555..8d9cc88 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Options: -u, --until Optional end date. -g, --global-activity Shows global activity calendar in the current repository. - -n, --no-ansi Forces the tool not to use ANSI styles. + -n, --disable-ansi Forces the tool not to use ANSI styles. -l, --light Enables the light theme. -d, --data Sets a custom data store file. -a, --authors Shows a pie chart with the author related @@ -168,6 +168,33 @@ module.exports = { Since it's a js file, you can `require` any other modules there. +## Saving the data as HTML and images + +`git-stats --raw` outputs raw JSON format which can be consumed by other tools to generate results such as HTML files or images. + +[`git-stats-html`](https://github.com/IonicaBizau/git-stats-html) interprets the JSON data and generates an HTML file. Example: + +```sh +# Install git-stats-html +npm install -g git-stats-html + +# Export the data from the last year (generate out.html) +git-stats --raw | git-stats-html -o out.html + +# Export data since 2015 (save the results in out.html) +git-stats --since '1 January 2015' --raw | ./bin/git-stats-html -o out.html --big +``` + +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/): + +```sh +# Install pageres +npm install -g pageres-cli + +# Generate the image from HTML +pageres out.html 775x250 +``` + ## Cross-platform compatibility `git-stats` is working fine in terminal emulators supporting ANSI styles. It should work fine on Linux and OS X. diff --git a/package.json b/package.json index d79a7c8..9bbc99a 100644 --- a/package.json +++ b/package.json @@ -216,6 +216,43 @@ { "p": "Since it's a js file, you can `require` any other modules there." }, + { + "h2": "Saving the data as HTML and images" + }, + { + "p": [ + "`git-stats --raw` outputs raw JSON format which can be consumed by other tools to generate results such as HTML files or images.", + "[`git-stats-html`](https://github.com/IonicaBizau/git-stats-html) interprets the JSON data and generates an HTML file. Example:", + { + "code": { + "content": [ + "# Install git-stats-html", + "npm install -g git-stats-html", + "", + "# Export the data from the last year (generate out.html)", + "git-stats --raw | git-stats-html -o out.html", + "", + "# Export data since 2015 (save the results in out.html)", + "git-stats --since '1 January 2015' --raw | ./bin/git-stats-html -o out.html --big" + ], + "language": "sh" + } + }, + "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/):", + { + "code": { + "content": [ + "# Install pageres", + "npm install -g pageres-cli", + "", + "# Generate the image from HTML", + "pageres out.html 775x250" + ], + "language": "sh" + } + } + ] + }, { "h2": "Cross-platform compatibility" },