Skip to content

Commit

Permalink
chore: add man page generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Fetz committed May 17, 2018
1 parent abb0f6b commit 9d9284b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ typings/

# using yarn at the moment so ignore npm lock
package-lock.json

# man page is code generate so ignore it
man
33 changes: 33 additions & 0 deletions docs/cli/json-analyzer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# json-analyzer(1) -- json size analyzer

## SYNOPSIS

json-analyzer [file][options]

## VERSION

@VERSION@

## DESCRIPTION

json-analyzer allows you to measure a json file/string

* you can use with pipe a json string:

cat <file> | json-analyzer [options]

- or you can use by providing a file path:

json-analyzer <file> [options]

## CONTRIBUTIONS

see <https://github.com/Fetz/json-analyzer/CONTRIBUTING.md> for details

## BUGS

When you find issues, please report to <https://github.com/Fetz/json-analyzer/issues>

## AUTHOR

[Fetz](https://github.com/Fetz)
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"main": "src/lib/json-analyzer.js",
"directories": {
"bin": "src/bin",
"lib": "src/lib"
"doc": "docs",
"lib": "src/lib",
"man": "man"
},
"scripts": {
"commitmsg": "commitlint -e $GIT_PARAMS",
Expand All @@ -18,6 +20,7 @@
"lint": "eslint ./",
"lint:pr": "danger ci",
"eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check",
"generate:man": "sh ./scripts/docs/man-page-generator.sh docs/cli/json-analyzer.md man/json-analyzer.1",
"monitor": "snyk monitor",
"travis-deploy-once": "travis-deploy-once",
"semantic-release": "semantic-release"
Expand Down Expand Up @@ -64,6 +67,7 @@
"husky": "^0.14.3",
"jest": "^22.4.3",
"lint-staged": "^7.1.0",
"marked-man": "^0.2.1",
"prettier": "^1.12.1",
"semantic-release": "^15.4.1",
"snyk": "^1.80.1",
Expand Down
18 changes: 18 additions & 0 deletions scripts/docs/man-page-generator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

src=$1
dest=$2
name=$(basename ${src%.*})
date=$(date -u +'%Y-%m-%d %H:%M:%S')
version=$(node src/bin/json-analyzer.js --version)

mkdir -p $(dirname $dest)

replace_tokens () {
sed "s|@VERSION@|$version|g"
}

./node_modules/.bin/marked-man --roff $src \
| replace_tokens > $dest
exit $?
;;
8 changes: 7 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4106,6 +4106,12 @@ map-visit@^1.0.0:
dependencies:
object-visit "^1.0.0"

marked-man@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/marked-man/-/marked-man-0.2.1.tgz#f259271481de3b507263489f5221b7c5acfd2383"
dependencies:
marked "^0.3.2"

marked-terminal@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/marked-terminal/-/marked-terminal-2.0.0.tgz#5eaf568be66f686541afa52a558280310a31de2d"
Expand All @@ -4116,7 +4122,7 @@ marked-terminal@^2.0.0:
lodash.assign "^4.2.0"
node-emoji "^1.4.1"

marked@^0.3.9:
marked@^0.3.2, marked@^0.3.9:
version "0.3.19"
resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.19.tgz#5d47f709c4c9fc3c216b6d46127280f40b39d790"

Expand Down

0 comments on commit 9d9284b

Please sign in to comment.