Create temporary directory when missing
This commit is contained in:
parent
b200d9d2e9
commit
7f2dab8f89
|
@ -1,3 +1,6 @@
|
|||
0.1.6:
|
||||
- Create temporary directory when missing
|
||||
|
||||
0.1.5:
|
||||
- Allow no packages to be specified
|
||||
|
||||
|
|
54
README.md
54
README.md
|
@ -24,17 +24,41 @@ go get golang.org/x/tools/cmd/godoc
|
|||
|
||||
## Documentation
|
||||
|
||||
Execute `godoc-static` supplying at least one package name to generate
|
||||
documentation for specific packages:
|
||||
To generate documentation for specific packages, execute `godoc-static`
|
||||
supplying at least one package name:
|
||||
|
||||
```bash
|
||||
godoc-static -destination=/home/user/sites/docs fmt net/http
|
||||
```
|
||||
|
||||
When no package names are supplied, documentation is generated for packages
|
||||
listed by `go list ...` instead.
|
||||
When no packages are supplied, documentation is generated for packages listed
|
||||
by `go list ...` instead.
|
||||
|
||||
Missing packages are not downloaded automatically.
|
||||
Packages are not downloaded/updated automatically.
|
||||
|
||||
### Usage examples
|
||||
|
||||
Generate documentation for `archive`, `net/http` and `gitlab.com/tslocum/cview` targeting `https://docs.rocketnine.space`:
|
||||
|
||||
```bash
|
||||
godoc-static \
|
||||
-base-path=/ \
|
||||
-site-name="Rocket Nine Labs Documentation" \
|
||||
-site-description="Welcome!" \
|
||||
-destination=/home/user/sites/docs \
|
||||
archive net/http gitlab.com/tslocum/cview
|
||||
```
|
||||
|
||||
Targeting `https://rocketnine.space/docs/`:
|
||||
|
||||
```bash
|
||||
godoc-static \
|
||||
-base-path=/docs/ \
|
||||
-site-name="Rocket Nine Labs Documentation" \
|
||||
-site-description-file=/home/user/sitefiles/description.md \
|
||||
-destination=/home/user/sites/docs \
|
||||
archive net/http gitlab.com/tslocum/cview
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
|
@ -71,26 +95,6 @@ Site name.
|
|||
#### -verbose
|
||||
Enable verbose logging.
|
||||
|
||||
### Usage examples
|
||||
|
||||
Generate documentation for `archive`, `net/http` and `gitlab.com/tslocum/cview` targeting `https://docs.rocketnine.space`:
|
||||
|
||||
```bash
|
||||
godoc-static -base-path=/ -site-name="Rocket Nine Labs Documentation" \
|
||||
-site-description="Welcome!" \
|
||||
-destination=/home/user/sites/docs \
|
||||
archive net/http gitlab.com/tslocum/cview
|
||||
```
|
||||
|
||||
Targeting `https://rocketnine.space/docs/`:
|
||||
|
||||
```bash
|
||||
godoc-static -base-path=/docs/ -site-name="Rocket Nine Labs Documentation" \
|
||||
-site-description-file=/home/user/sitefiles/description.md \
|
||||
-destination=/home/user/sites/docs \
|
||||
archive net/http gitlab.com/tslocum/cview
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Please share issues/suggestions [here](https://gitlab.com/tslocum/godoc-static/issues).
|
||||
|
|
4
go.mod
4
go.mod
|
@ -4,6 +4,6 @@ go 1.13
|
|||
|
||||
require (
|
||||
github.com/PuerkitoBio/goquery v1.5.1
|
||||
github.com/yuin/goldmark v1.1.22
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2
|
||||
github.com/yuin/goldmark v1.1.23
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b
|
||||
)
|
||||
|
|
6
go.sum
6
go.sum
|
@ -2,11 +2,13 @@ github.com/PuerkitoBio/goquery v1.5.1 h1:PSPBGne8NIUWw+/7vFBV+kG2J/5MOjbzc7154Oa
|
|||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||
github.com/andybalholm/cascadia v1.1.0 h1:BuuO6sSfQNFRu1LppgbD25Hr2vLYW25JvxHs5zzsLTo=
|
||||
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||
github.com/yuin/goldmark v1.1.22 h1:0e0f6Zee9SAQ5yOZGNMWaOxqVvcc/9/kUWu/Kl91Jk8=
|
||||
github.com/yuin/goldmark v1.1.22/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.23 h1:eTodJ8hwEUvwXhb9qxQNuL/q1d+xMQClrXR4mdvV7gs=
|
||||
github.com/yuin/goldmark v1.1.23/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
|
18
main.go
18
main.go
|
@ -1,3 +1,4 @@
|
|||
// Package godoc-static generates static Go documentation
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -66,6 +67,17 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func getTmpDir() string {
|
||||
tmpDir := os.TempDir()
|
||||
if _, err := os.Stat(tmpDir); os.IsNotExist(err) {
|
||||
mkDirErr := os.MkdirAll(tmpDir, 0755)
|
||||
if _, err = os.Stat(tmpDir); os.IsNotExist(err) {
|
||||
log.Fatalf("failed to create missing temporary directory %s: %s", tmpDir, mkDirErr)
|
||||
}
|
||||
}
|
||||
return tmpDir
|
||||
}
|
||||
|
||||
func run() error {
|
||||
var buf bytes.Buffer
|
||||
timeStarted := time.Now()
|
||||
|
@ -237,7 +249,7 @@ func run() error {
|
|||
return strings.ToLower(pkgs[i]) < strings.ToLower(pkgs[j])
|
||||
})
|
||||
|
||||
// Allow godoc to initialize
|
||||
// Allow some time for godoc to initialize
|
||||
|
||||
if time.Since(godocStarted) < 3*time.Second {
|
||||
time.Sleep((3 * time.Second) - time.Since(godocStarted))
|
||||
|
@ -319,8 +331,6 @@ func run() error {
|
|||
log.Printf("Copying %s sources...", pkg)
|
||||
}
|
||||
|
||||
tmpDir := os.TempDir()
|
||||
// TODO Handle temp directory not existing
|
||||
buf.Reset()
|
||||
|
||||
cmd := exec.Command("go", "list", "-find", "-f",
|
||||
|
@ -337,7 +347,7 @@ func run() error {
|
|||
`{{ join .TestGoFiles "\n" }}`+"\n"+
|
||||
`{{ join .XTestGoFiles "\n" }}`,
|
||||
pkg)
|
||||
cmd.Dir = tmpDir
|
||||
cmd.Dir = getTmpDir()
|
||||
cmd.Stdout = &buf
|
||||
setDeathSignal(cmd)
|
||||
|
||||
|
|
Loading…
Reference in New Issue