Add some docs/readmes (#329)

Updates and adds some package docs.

It also provides autogenerated README's using https://github.com/jimmyfrasche/autoreadme tool. To use it, make sure it's installed on your system, and every time you update documentation, run go generate to update the README.md file.
This commit is contained in:
Ivan Daniluk 2017-09-15 18:00:00 +02:00 committed by Ivan Tomilov
parent f88de68f86
commit cf7a9949a3
6 changed files with 157 additions and 13 deletions

View File

@ -1,5 +1,5 @@
#jail [![GoDoc](https://godoc.org/github.com/status-im/status-go/geth/jail?status.png)](https://godoc.org/github.com/status-im/status-go/geth/jail) # jail [![GoDoc](https://godoc.org/github.com/status-im/status-go/geth/jail?status.png)](https://godoc.org/github.com/status-im/status-go/geth/jail)
go:generate autoreadme -f Package jail implements "jailed" enviroment for executing arbitrary JavaScript code using Otto JS interpreter (https://github.com/robertkrimen/otto). jail - jailed enviroment for executing JS code.
Download: Download:
```shell ```shell
@ -7,7 +7,7 @@ go get github.com/status-im/status-go/geth/jail
``` ```
* * * * * *
go:generate autoreadme -f jail - jailed enviroment for executing JS code.
Package jail implements "jailed" enviroment for executing arbitrary Package jail implements "jailed" enviroment for executing arbitrary
JavaScript code using Otto JS interpreter (https://github.com/robertkrimen/otto). JavaScript code using Otto JS interpreter (https://github.com/robertkrimen/otto).

View File

@ -1,5 +1,6 @@
//go:generate autoreadme -f
/* /*
jail - jailed enviroment for executing JS code.
Package jail implements "jailed" enviroment for executing arbitrary Package jail implements "jailed" enviroment for executing arbitrary
JavaScript code using Otto JS interpreter (https://github.com/robertkrimen/otto). JavaScript code using Otto JS interpreter (https://github.com/robertkrimen/otto).
@ -83,3 +84,5 @@ it's user responsibility to register a corresponding callback function before:
*/ */
package jail package jail
//go:generate autoreadme -f

52
geth/log/README.md Normal file
View File

@ -0,0 +1,52 @@
# log [![GoDoc](https://godoc.org/github.com/status-im/status-go/geth/log?status.png)](https://godoc.org/github.com/status-im/status-go/geth/log)
Package log implements logger for status-go.
Download:
```shell
go get github.com/status-im/status-go/geth/log
```
* * *
Package log implements logger for status-go.
This logger handles two loggers - it's own and ethereum-go logger.
Both are used as "singletons" - using global shared variables.
## Usage
First, import package into your code:
```
import "github.com/status-im/status-go/geth/log
```
Then simply use `Info/Error/Debug/etc` functions to log at desired level:
```
log.Info("Info message")
log.Debug("Debug message")
log.Error("Error message")
```
Slightly more complicated logging:
```
log.Warn("abnormal conn rate", "rate", curRate, "low", lowRate, "high", highRate)
```
Note, in this case parameters should be in in pairs (key, value).
This logger is based upon log15-logger, so see its documentation for advanced usage: https://github.com/inconshreveable/log15
## Initialization
By default logger is set to log to stdout with Error level via `init()` function.
You may change both level and file output by `log.SetLevel()` and `log.SetLogFile()` functions:
```
log.SetLevel("DEBUG")
log.SetLogFile("/path/to/geth.log")
```
* * *
Automatically generated by [autoreadme](https://github.com/jimmyfrasche/autoreadme) on 2017.09.15

View File

@ -1,5 +1,42 @@
/*Package log implements logger for status-go.
This logger handles two loggers - it's own and ethereum-go logger.
Both are used as "singletons" - using global shared variables.
Usage
First, import package into your code:
import "github.com/status-im/status-go/geth/log
Then simply use `Info/Error/Debug/etc` functions to log at desired level:
log.Info("Info message")
log.Debug("Debug message")
log.Error("Error message")
Slightly more complicated logging:
log.Warn("abnormal conn rate", "rate", curRate, "low", lowRate, "high", highRate)
Note, in this case parameters should be in in pairs (key, value).
This logger is based upon log15-logger, so see its documentation for advanced usage: https://github.com/inconshreveable/log15
Initialization
By default logger is set to log to stdout with Error level via `init()` function.
You may change both level and file output by `log.SetLevel()` and `log.SetLogFile()` functions:
log.SetLevel("DEBUG")
log.SetLogFile("/path/to/geth.log")
*/
package log package log
//go:generate autoreadme -f
import ( import (
"fmt" "fmt"
"os" "os"
@ -11,19 +48,19 @@ import (
// Logger is a wrapper around log.Logger. // Logger is a wrapper around log.Logger.
type Logger struct { type Logger struct {
log.Logger log.Logger
Level log.Lvl level log.Lvl
Handler log.Handler handler log.Handler
} }
// logger is package scope instance of Logger // logger is package scope instance of Logger
var logger = Logger{ var logger = Logger{
Logger: log.New("geth", "StatusIM"), Logger: log.New("geth", "StatusIM"),
Level: log.LvlError, level: log.LvlError,
Handler: log.StreamHandler(os.Stdout, log.TerminalFormat(true)), handler: log.StreamHandler(os.Stdout, log.TerminalFormat(true)),
} }
func init() { func init() {
setHandler(logger.Level, logger.Handler) setHandler(logger.level, logger.handler)
} }
// SetLevel inits status and ethereum-go logging packages, // SetLevel inits status and ethereum-go logging packages,
@ -34,8 +71,8 @@ func init() {
func SetLevel(level string) { func SetLevel(level string) {
lvl := levelFromString(level) lvl := levelFromString(level)
logger.Level = lvl logger.level = lvl
setHandler(lvl, logger.Handler) setHandler(lvl, logger.handler)
} }
// SetLogFile configures logger to write output into file. // SetLogFile configures logger to write output into file.
@ -46,8 +83,8 @@ func SetLogFile(filename string) error {
return err return err
} }
logger.Handler = handler logger.handler = handler
setHandler(logger.Level, handler) setHandler(logger.level, handler)
return nil return nil
} }

30
geth/rpc/README.md Normal file
View File

@ -0,0 +1,30 @@
# rpc [![GoDoc](https://godoc.org/github.com/status-im/status-go/geth/rpc?status.png)](https://godoc.org/github.com/status-im/status-go/geth/rpc)
rpc - JSON-RPC client with custom routing.
Download:
```shell
go get github.com/status-im/status-go/geth/rpc
```
* * *
rpc - JSON-RPC client with custom routing.
Package rpc implements status-go JSON-RPC client and handles
requests to different endpoints: upstream or local node.
Every JSON-RPC request coming from either JS code or any other part
of status-go should use this package to be handled and routed properly.
Routing rules are following:
- if Upstream is disabled, everything is routed to local ethereum-go node
- otherwise, some requests (from the list, see below) are routed to upstream, others - locally.
List of methods to be routed is currently available here: https://docs.google.com/spreadsheets/d/1N1nuzVN5tXoDmzkBLeC9_mwIlVH8DGF7YD2XwxA8BAE/edit#gid=0
Note, upon creation of a new client, it ok to be offline - client will keep trying to reconnect in background.
* * *
Automatically generated by [autoreadme](https://github.com/jimmyfrasche/autoreadme) on 2017.09.15

22
geth/rpc/doc.go Normal file
View File

@ -0,0 +1,22 @@
/*
rpc - JSON-RPC client with custom routing.
Package rpc implements status-go JSON-RPC client and handles
requests to different endpoints: upstream or local node.
Every JSON-RPC request coming from either JS code or any other part
of status-go should use this package to be handled and routed properly.
Routing rules are following:
- if Upstream is disabled, everything is routed to local ethereum-go node
- otherwise, some requests (from the list, see below) are routed to upstream, others - locally.
List of methods to be routed is currently available here: https://docs.google.com/spreadsheets/d/1N1nuzVN5tXoDmzkBLeC9_mwIlVH8DGF7YD2XwxA8BAE/edit#gid=0
Note, upon creation of a new client, it ok to be offline - client will keep trying to reconnect in background.
*/
package rpc
//go:generate autoreadme -f