happydoc
---
convenient system that easy to create to make people easy to publish their documents

## Quick Start

- [Install](#Install)
- [Run happydoc server at your server](#run-happydoc-server-at-your-server)
- [Publish document on client side](#publish-document-on-client-side)

### Install

- Server side(use go to install as a system command): `go get -u github.com/maple-leaf/happydoc`
- Client side(install as npm package): `npm i happydoc -D`

> PS: If you want, you can also use `go` to install at client side as a system wide command

### Run happydoc server at your server

After you install `happydoc` on server, run command `happydoc server` to install happydoc service and run it

### Publish document on client side

- npm
	- __init__: `npx happydoc init`
	- __publish__: say you have `docs` folder in your project which contains documents generated by, say esdoc, and `apidocs`
	folder which contains server api documents generated by, say swagger. (__both should have `index.html` inside__)
		- use npx: `npx happydoc publish docs -v 0.0.1 -t frontend`
		- [TODO] use npm script: `npm run happydoc apidocs`

		```javascript
		// package.json
		{
			...
			scripts: {
				'happydoc': 'happydoc publish'
			}
		}
		```

---

## config file - .happydoc.json

```json
{
	"project": "myAwesomeProject",
	"server": "http://127.0.0.1:8000",
	"account": "your account name at server",
	"token":
}
```

## Commands

- `happydoc init`

generate config file `.happydoc.json` by answer questions. If project has file `package.json`, project will
default to name field inside it.

- `happydoc publish`

upload documents to server. It receives one argument to indicate **path to document folder**, and has four flags:
	- `server`: shorthand `s`, will override value inside `.happydoc.json` if used
	- `project`: shorthand `p`, will override value inside `.happydoc.json` if used
	- `version`: shorthand `v`, current version of documents
	- `type`: shorthand `t`, type of documents

	```bash
	happydoc publish docs/fontend -v 1.2.0 -t frontend
	happydoc publish docs/backend -v 1.2.0 -t backend -s http://my-doc-server.com -p myAwesomeProject2
	```

- `happydoc server`

init and run happydoc server. This server will receives documents uploaded by happdoc client with `publish` command.
And `token` used by happdoc client is also generated on it.

This command will ask you:
- folder to init server
- which port should be used by server
- password set for postgresql **running on docker container, NOT DB ON YOUR HOST**

# Build and Release
- release using [goreleaser](https://github.com/goreleaser/goreleaser),
release require github token with repo, check [doc](https://goreleaser.com/quick-start/)

	```bash
	git tag version
	export GITHUB_TOKEN='Your Github Token Here'
	goreleaser goreleaser release

	# dry run without publish to github etc.
	goreleaser release --skip-publish
	```
- publish release to npm using [go-npm](https://github.com/sanathkr/go-npm): `npm publish`

## This project use
- [golang](https://github.com/golang/go)
- [postgres](https://www.postgresql.org/)
- [cobra](https://github.com/spf13/cobra)
- [gin](https://github.com/gin-gonic/gin)

## TODO
- better UI
- use https
- fix output for subcommand `server`
