Skip to content

Commit 371845b

Browse files
authored
Generate Markdown docs for cosign (#839)
Signed-off-by: Jason Hall <[email protected]>
1 parent 4cc0fbd commit 371845b

36 files changed

+1473
-2
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file is documented at https://git-scm.com/docs/gitattributes.
2+
# Linguist-specific attributes are documented at
3+
# https://github.com/github/linguist.
4+
5+
doc/cosign*.md linguist-generated=true

.github/workflows/verify-docgen.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# Copyright 2021 The Sigstore Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
name: Docgen
17+
18+
on: [push, pull_request]
19+
20+
jobs:
21+
docgen:
22+
name: Verify Docgen
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: actions/setup-go@v2
28+
with:
29+
go-version: '1.17.x'
30+
- run: ./cmd/help/verify.sh

cmd/cosign/cli/commands.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ var (
3131

3232
func New() *cobra.Command {
3333
cmd := &cobra.Command{
34-
Use: "cosign",
34+
Use: "cosign",
35+
DisableAutoGenTag: true,
3536
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
3637
if ro.OutputFile != "" {
3738
out, err := os.Create(ro.OutputFile)

cmd/cosign/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//
21
// Copyright 2021 The Sigstore Authors.
32
//
43
// Licensed under the Apache License, Version 2.0 (the "License");

cmd/help/main.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2021 The Sigstore Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package main
16+
17+
import (
18+
"fmt"
19+
"os"
20+
21+
"github.com/sigstore/cosign/cmd/cosign/cli"
22+
"github.com/spf13/cobra"
23+
"github.com/spf13/cobra/doc"
24+
)
25+
26+
func main() {
27+
var dir string
28+
root := &cobra.Command{
29+
Use: "gendoc",
30+
Short: "Generate cosign's help docs",
31+
SilenceUsage: true,
32+
Args: cobra.NoArgs,
33+
RunE: func(*cobra.Command, []string) error {
34+
return doc.GenMarkdownTree(cli.New(), dir)
35+
},
36+
}
37+
root.Flags().StringVarP(&dir, "dir", "d", "doc", "Path to directory in which to generate docs")
38+
if err := root.Execute(); err != nil {
39+
fmt.Println(err)
40+
os.Exit(1)
41+
}
42+
}

cmd/help/verify.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2021 The Sigstore Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
# Verify that generated Markdown docs are up-to-date.
20+
tmpdir=$(mktemp -d)
21+
go run cmd/help/main.go --dir "$tmpdir"
22+
echo "###########################################"
23+
echo "If diffs are found, run: go run ./cmd/help/"
24+
echo "###########################################"
25+
diff -Naur "$tmpdir" doc/

doc/cosign.md

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/cosign_attach.md

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/cosign_attach_sbom.md

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/cosign_attach_signature.md

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)