Skip to content

Commit 69bd16e

Browse files
authored
Docs (#270)
* Basic CLI Docs generation
1 parent 30063af commit 69bd16e

8 files changed

Lines changed: 105 additions & 1 deletion

File tree

.github/workflows/docs.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Deploy CLI Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
jobs:
8+
build-and-deploy-docs:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
environment:
15+
name: github-pages
16+
url: ${{steps.deployment.outputs.page_url}}
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up Go
25+
uses: actions/setup-go@v5
26+
27+
- name: Generate Docs with Go
28+
working-directory: src/pipeleak
29+
run: go run main.go docs
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v6
33+
with:
34+
python-version: '3.x'
35+
36+
- name: Install MkDocs
37+
run: pip install mkdocs mkdocs-material
38+
39+
- name: Build Docs
40+
run: mkdocs build
41+
42+
- name: Setup Pages
43+
uses: actions/configure-pages@v5
44+
45+
- name: Upload Artifact
46+
uses: actions/upload-pages-artifact@v4
47+
with:
48+
path: 'site/'
49+
50+
- name: Deploy to GitHub Pages
51+
id: deployment
52+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
rules.yml
22
*.log
3-
dist
3+
dist
4+
renovate-enum-out
5+
cli-docs
6+
site

mkdocs.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
site_name: Pipeleak CLI Docs
2+
docs_dir: src/pipeleak/cli-docs
3+
site_dir: site
4+
theme:
5+
name: material
6+
palette:
7+
scheme: slate
8+
extra:
9+
highlightjs: true

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Run the following command to scan your e.g. GitLab instance:
2727
pipeleak gl scan --token glpat-xxxxxxxxxxx --gitlab https://gitlab.com
2828
```
2929

30+
More detailed command documentation can be found [here](https://compasssecurity.github.io/pipeleak/pipeleak/).
31+
3032
### Scanning Artifacts
3133

3234
In addition to logs, Pipeleak can also scan artifacts generated by your pipelines.

src/pipeleak/cmd/docs/docs.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package docs
2+
3+
import (
4+
"os"
5+
6+
"github.com/rs/zerolog/log"
7+
8+
"github.com/spf13/cobra"
9+
"github.com/spf13/cobra/doc"
10+
)
11+
12+
func NewDocsCmd(root *cobra.Command) *cobra.Command {
13+
return &cobra.Command{
14+
Use: "docs",
15+
Short: "Generate CLI documentation",
16+
Long: "Generate Markdown documentation for all commands in this CLI application.",
17+
Run: func(cmd *cobra.Command, args []string) {
18+
outputDir := "./cli-docs"
19+
20+
if err := os.MkdirAll(outputDir, os.ModePerm); err != nil {
21+
log.Fatal().Err(err).Msg("Failed to create cli-docs directory")
22+
}
23+
24+
err := doc.GenMarkdownTree(root, outputDir)
25+
if err != nil {
26+
log.Fatal().Err(err).Msg("Failed to generate cli docs")
27+
}
28+
29+
log.Info().Str("folder", outputDir).Msg("Docs successfully generated")
30+
},
31+
}
32+
}

src/pipeleak/cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/CompassSecurity/pipeleak/cmd/bitbucket"
1111
"github.com/CompassSecurity/pipeleak/cmd/devops"
12+
"github.com/CompassSecurity/pipeleak/cmd/docs"
1213
"github.com/CompassSecurity/pipeleak/cmd/github"
1314
"github.com/CompassSecurity/pipeleak/cmd/gitlab"
1415
"github.com/rs/zerolog"
@@ -39,6 +40,7 @@ func init() {
3940
rootCmd.AddCommand(gitlab.NewGitLabRootCmd())
4041
rootCmd.AddCommand(bitbucket.NewBitBucketRootCmd())
4142
rootCmd.AddCommand(devops.NewAzureDevOpsRootCmd())
43+
rootCmd.AddCommand(docs.NewDocsCmd(rootCmd))
4244
rootCmd.PersistentFlags().BoolVarP(&JsonLogoutput, "json", "", false, "Use JSON as log output format")
4345
rootCmd.PersistentFlags().BoolVarP(&LogColor, "coloredLog", "", true, "Output the human-readable log in color")
4446
rootCmd.PersistentFlags().StringVarP(&LogFile, "logfile", "l", "", "Log output to a file")

src/pipeleak/go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ require (
6060
github.com/couchbase/gocbcoreps v0.1.3 // indirect
6161
github.com/couchbase/goprotostellar v1.0.2 // indirect
6262
github.com/couchbaselabs/gocbconnstr/v2 v2.0.0-20240607131231-fb385523de28 // indirect
63+
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
6364
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
6465
github.com/felixge/httpsnoop v1.0.4 // indirect
6566
github.com/fsnotify/fsnotify v1.7.0 // indirect
@@ -110,6 +111,7 @@ require (
110111
github.com/prometheus/common v0.55.0 // indirect
111112
github.com/prometheus/procfs v0.15.1 // indirect
112113
github.com/rabbitmq/amqp091-go v1.10.0 // indirect
114+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
113115
github.com/tailscale/depaware v0.0.0-20250112153213-b748de04d81b // indirect
114116
github.com/tetratelabs/wazero v1.9.0 // indirect
115117
github.com/tidwall/match v1.1.1 // indirect

src/pipeleak/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ github.com/couchbaselabs/gocbconnstr/v2 v2.0.0-20240607131231-fb385523de28 h1:lh
152152
github.com/couchbaselabs/gocbconnstr/v2 v2.0.0-20240607131231-fb385523de28/go.mod h1:o7T431UOfFVHDNvMBUmUxpHnhivwv7BziUao/nMl81E=
153153
github.com/cpuguy83/dockercfg v0.3.2 h1:DlJTyZGBDlXqUZ2Dk2Q3xHs/FtnooJJVaad2S9GKorA=
154154
github.com/cpuguy83/dockercfg v0.3.2/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc=
155+
github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0=
155156
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
156157
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
157158
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -442,6 +443,7 @@ github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWN
442443
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
443444
github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
444445
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
446+
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
445447
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
446448
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk=
447449
github.com/rxwycdh/rxhash v0.0.0-20230131062142-10b7a38b400d h1:pVClFYVn4nLE5D8YiihMwOznjoTuM8vA/6Rk6Jrkfe0=

0 commit comments

Comments
 (0)