Skip to content

Commit

Permalink
Merge pull request #26 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 0.6.0
  • Loading branch information
andyone authored Jun 15, 2019
2 parents 7e57d9b + 3fc1d8d commit ff3b79f
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 46 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
sudo: false

language: go

go:
- 1.8.x
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
- tip

branches:
Expand Down
30 changes: 19 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
################################################################################

# This Makefile generated by GoMakeGen 0.8.0 using next command:
# This Makefile generated by GoMakeGen 1.1.0 using next command:
# gomakegen --race .
#
# More info: https://kaos.sh/gomakegen

################################################################################

.DEFAULT_GOAL := help
.PHONY = fmt all clean deps deps-test test help
.PHONY = fmt all clean git-config deps deps-test test gen-fuzz help

################################################################################

Expand All @@ -15,23 +17,28 @@ all: shdoc ## Build all binaries
shdoc: ## Build shdoc binary
go build shdoc.go

install: ## Install binaries
install: ## Install all binaries
cp shdoc /usr/bin/shdoc

uninstall: ## Uninstall binaries
uninstall: ## Uninstall all binaries
rm -f /usr/bin/shdoc

deps: ## Download dependencies
git-config: ## Configure git redirects for stable import path services
git config --global http.https://pkg.re.followRedirects true
go get -d -v pkg.re/essentialkaos/ek.v9

deps-test: ## Download dependencies for tests
git config --global http.https://pkg.re.followRedirects true
deps: git-config ## Download dependencies
go get -d -v pkg.re/essentialkaos/ek.v10

deps-test: git-config ## Download dependencies for tests
go get -d -v pkg.re/check.v1

test: ## Run tests
go test -race ./...
go test -covermode=count ./...
go test -race ./parser
go test -covermode=count ./parser

gen-fuzz: ## Generate archives for fuzz testing
which go-fuzz-build &>/dev/null || go get -u -v github.com/dvyukov/go-fuzz/go-fuzz-build
go-fuzz-build -o parser-fuzz.zip github.com/essentialkaos/shdoc/parser

fmt: ## Format source code with gofmt
find . -name "*.go" -exec gofmt -s -w {} \;
Expand All @@ -40,9 +47,10 @@ clean: ## Remove generated files
rm -f shdoc

help: ## Show this info
@echo -e '\nSupported targets:\n'
@echo -e '\n\033[1mSupported targets:\033[0m\n'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-12s\033[0m %s\n", $$1, $$2}'
@echo -e ''
@echo -e '\033[90mGenerated by GoMakeGen 1.1.0\033[0m\n'

################################################################################
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<p align="center"><a href="#readme"><img src="https://gh.kaos.st/shdoc.svg"/></a></p>

<p align="center"><a href="#usage-demo">Usage Demo</a> • <a href="#installation">Installation</a> • <a href="#usage">Usage</a> • <a href="#test--coverage-status">Test & Coverage Status</a> • <a href="#contributing">Contributing</a> • <a href="#license">License</a></p>

<p align="center">
<a href="https://travis-ci.org/essentialkaos/shdoc"><img src="https://travis-ci.org/essentialkaos/shdoc.svg"></a>
<a href="https://goreportcard.com/report/github.com/essentialkaos/shdoc"><img src="https://goreportcard.com/badge/github.com/essentialkaos/shdoc"></a>
Expand All @@ -10,6 +8,10 @@
<a href="https://essentialkaos.com/ekol"><img src="https://gh.kaos.st/ekol.svg"></a>
</p>

<p align="center"><a href="#usage-demo">Usage Demo</a> • <a href="#installation">Installation</a> • <a href="#usage">Usage</a> • <a href="#test--coverage-status">Test & Coverage Status</a> • <a href="#contributing">Contributing</a> • <a href="#license">License</a></p>

<br/>

`shdoc` is a tool for viewing and exporting documentation for shell scripts.

### Usage Demo
Expand All @@ -26,7 +28,7 @@ Before the initial install allows git to use redirects for [pkg.re](https://gith
git config --global http.https://pkg.re.followRedirects true
```

Make sure you have a working Go 1.8+ workspace ([instructions](https://golang.org/doc/install)), then:
Make sure you have a working Go 1.10+ workspace ([instructions](https://golang.org/doc/install)), then:

```
go get github.com/essentialkaos/shdoc
Expand Down
36 changes: 36 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Security Policies and Procedures

This document outlines security procedures and general policies for all
ESSENTIAL KAOS projects.

* [Reporting a Bug](#reporting-a-bug)
* [Disclosure Policy](#disclosure-policy)

## Reporting a Bug

The ESSENTIAL KAOS team and community take all security bugs in our projects
very seriously. Thank you for improving the security of our project. We
appreciate your efforts and responsible disclosure and will make every effort
to acknowledge your contributions.

Report security bugs by emailing our security team at [email protected].

The security team will acknowledge your email within 48 hours and will send a
more detailed response within 48 hours, indicating the next steps in handling
your report. After the initial reply to your report, the security team will
endeavor to keep you informed of the progress towards a fix and full
announcement, and may ask for additional information or guidance.

Report security bugs in third-party dependencies to the person or team
maintaining the dependencies.

## Disclosure Policy

When the security team receives a security bug report, they will assign it to a
primary handler. This person will coordinate the fix and release process,
involving the following steps:

* Confirm the problem and determine the affected versions;
* Audit code to find any similar potential problems;
* Prepare fixes for all releases still under maintenance. These fixes will be
released as fast as possible.
2 changes: 1 addition & 1 deletion parser/fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package parser

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2009-2018 ESSENTIAL KAOS //
// Copyright (c) 2009-2019 ESSENTIAL KAOS //
// Essential Kaos Open Source License <https://essentialkaos.com/ekol> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down
12 changes: 6 additions & 6 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package parser

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2009-2018 ESSENTIAL KAOS //
// Copyright (c) 2009-2019 ESSENTIAL KAOS //
// Essential Kaos Open Source License <https://essentialkaos.com/ekol> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand All @@ -16,10 +16,10 @@ import (
"regexp"
"strings"

"pkg.re/essentialkaos/ek.v9/fsutil"
"pkg.re/essentialkaos/ek.v9/mathutil"
"pkg.re/essentialkaos/ek.v9/sliceutil"
"pkg.re/essentialkaos/ek.v9/strutil"
"pkg.re/essentialkaos/ek.v10/fsutil"
"pkg.re/essentialkaos/ek.v10/mathutil"
"pkg.re/essentialkaos/ek.v10/sliceutil"
"pkg.re/essentialkaos/ek.v10/strutil"
)

// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down Expand Up @@ -76,7 +76,7 @@ type Variable struct {
Line int `json:"line"` // LOC of definition
}

// Document contians info about all constants, global variables and methods
// Document contains info about all constants, global variables and methods
type Document struct {
Title string `json:"title"`
About []string `json:"about"`
Expand Down
2 changes: 1 addition & 1 deletion parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package parser

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2009-2018 ESSENTIAL KAOS //
// Copyright (c) 2009-2019 ESSENTIAL KAOS //
// Essential Kaos Open Source License <https://essentialkaos.com/ekol> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down
42 changes: 22 additions & 20 deletions shdoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2009-2018 ESSENTIAL KAOS //
// Copyright (c) 2009-2019 ESSENTIAL KAOS //
// Essential Kaos Open Source License <https://essentialkaos.com/ekol> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand All @@ -13,14 +13,13 @@ import (
"strings"
"text/template"

"pkg.re/essentialkaos/ek.v9/env"
"pkg.re/essentialkaos/ek.v9/fmtc"
"pkg.re/essentialkaos/ek.v9/fmtutil"
"pkg.re/essentialkaos/ek.v9/fsutil"
"pkg.re/essentialkaos/ek.v9/options"
"pkg.re/essentialkaos/ek.v9/path"
"pkg.re/essentialkaos/ek.v9/usage"
"pkg.re/essentialkaos/ek.v9/usage/update"
"pkg.re/essentialkaos/ek.v10/fmtc"
"pkg.re/essentialkaos/ek.v10/fmtutil"
"pkg.re/essentialkaos/ek.v10/fsutil"
"pkg.re/essentialkaos/ek.v10/options"
"pkg.re/essentialkaos/ek.v10/path"
"pkg.re/essentialkaos/ek.v10/usage"
"pkg.re/essentialkaos/ek.v10/usage/update"

. "github.com/essentialkaos/shdoc/parser"
)
Expand All @@ -29,7 +28,7 @@ import (

const (
APP = "SHDoc"
VER = "0.5.0"
VER = "0.6.0"
DESC = "Tool for viewing and exporting docs for shell scripts"
)

Expand All @@ -55,6 +54,7 @@ var optMap = options.Map{

// ////////////////////////////////////////////////////////////////////////////////// //

// main is main function
func main() {
args, errs := options.Parse(optMap)

Expand Down Expand Up @@ -94,7 +94,7 @@ func main() {

// ////////////////////////////////////////////////////////////////////////////////// //

// process start source processing
// process starts source processing
func process(file string, pattern string) {
if !fsutil.IsExist(file) {
printErrorAndExit("File %s does not exist", file)
Expand Down Expand Up @@ -140,7 +140,7 @@ func process(file string, pattern string) {
}
}

// findInfo search geven pattern in entities names
// findInfo searches geven pattern in entities names
func findInfo(doc *Document, pattern string) {
fmtc.NewLine()

Expand Down Expand Up @@ -172,7 +172,7 @@ func findInfo(doc *Document, pattern string) {
}
}

// simpleRender print all document info to console
// simpleRender prints all document info to console
func simpleRender(doc *Document) {
if doc.HasAbout() {
fmtutil.Separator(false, "ABOUT")
Expand Down Expand Up @@ -228,9 +228,9 @@ func simpleRender(doc *Document) {
fmtutil.Separator(false)
}

// renderTemplate read template and render to file
// renderTemplate reads template and render to file
func renderTemplate(doc *Document) {
projectDir := env.Get().GetS("GOPATH")
projectDir := os.Getenv("GOPATH")
templateFile := path.Join(
projectDir, "src/github.com/essentialkaos/shdoc/templates",
options.GetS(OPT_TEMPLATE)+".tpl",
Expand Down Expand Up @@ -283,19 +283,19 @@ func renderTemplate(doc *Document) {
fmtutil.Separator(false)
}

// renderConstant print constant info to console
// renderConstant prints constant info to console
func renderConstant(c *Variable) {
fmtc.Printf("{s-}%4d:{!} {m*}%s{!} {s}={!} %s "+getVarTypeDesc(c.Type)+"\n", c.Line, c.Name, c.Value)
fmtc.Printf(" %s\n", c.UnitedDesc())
}

// renderMethod print variable info to console
// renderMethod prints variable info to console
func renderVariable(v *Variable) {
fmtc.Printf("{s-}%4d:{!} {c*}%s{!} {s}={!} %s "+getVarTypeDesc(v.Type)+"\n", v.Line, v.Name, v.Value)
fmtc.Printf(" %s\n", v.UnitedDesc())
}

// renderMethod print method info to console
// renderMethod prints method info to console
func renderMethod(m *Method, showExamples bool) {
fmtc.Printf("{s-}%4d:{!} {b*}%s{!} {s}-{!} %s\n", m.Line, m.Name, m.UnitedDesc())

Expand Down Expand Up @@ -335,7 +335,7 @@ func renderMethod(m *Method, showExamples bool) {
}
}

// getVarTypeDesc return type description
// getVarTypeDesc returns type description
func getVarTypeDesc(t VariableType) string {
switch t {
case VAR_TYPE_STRING:
Expand All @@ -359,14 +359,15 @@ func printWarn(f string, a ...interface{}) {
fmtc.Fprintf(os.Stderr, "{y}"+f+"{!}\n", a...)
}

// printErrorAndExit print error mesage and exit with exit code 1
// printErrorAndExit prints error mesage and exit with exit code 1
func printErrorAndExit(f string, a ...interface{}) {
printError(f, a...)
os.Exit(1)
}

// ////////////////////////////////////////////////////////////////////////////////// //

// showUsage shows usage info
func showUsage() {
info := usage.NewInfo("", "file")

Expand Down Expand Up @@ -395,6 +396,7 @@ func showUsage() {
info.Render()
}

// showAbout shows info about version
func showAbout() {
about := &usage.About{
App: APP,
Expand Down

0 comments on commit ff3b79f

Please sign in to comment.