Skip to content

Commit

Permalink
Generate Markdown docs for cosign (sigstore#839)
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Hall <jasonhall@redhat.com>
  • Loading branch information
imjasonh authored Oct 4, 2021
1 parent 4cc0fbd commit 371845b
Show file tree
Hide file tree
Showing 36 changed files with 1,473 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file is documented at https://git-scm.com/docs/gitattributes.
# Linguist-specific attributes are documented at
# https://github.com/github/linguist.

doc/cosign*.md linguist-generated=true
30 changes: 30 additions & 0 deletions .github/workflows/verify-docgen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Copyright 2021 The Sigstore Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Docgen

on: [push, pull_request]

jobs:
docgen:
name: Verify Docgen
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.17.x'
- run: ./cmd/help/verify.sh
3 changes: 2 additions & 1 deletion cmd/cosign/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ var (

func New() *cobra.Command {
cmd := &cobra.Command{
Use: "cosign",
Use: "cosign",
DisableAutoGenTag: true,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if ro.OutputFile != "" {
out, err := os.Create(ro.OutputFile)
Expand Down
1 change: 0 additions & 1 deletion cmd/cosign/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//
// Copyright 2021 The Sigstore Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
42 changes: 42 additions & 0 deletions cmd/help/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2021 The Sigstore Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"fmt"
"os"

"github.com/sigstore/cosign/cmd/cosign/cli"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

func main() {
var dir string
root := &cobra.Command{
Use: "gendoc",
Short: "Generate cosign's help docs",
SilenceUsage: true,
Args: cobra.NoArgs,
RunE: func(*cobra.Command, []string) error {
return doc.GenMarkdownTree(cli.New(), dir)
},
}
root.Flags().StringVarP(&dir, "dir", "d", "doc", "Path to directory in which to generate docs")
if err := root.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
25 changes: 25 additions & 0 deletions cmd/help/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# Copyright 2021 The Sigstore Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

# Verify that generated Markdown docs are up-to-date.
tmpdir=$(mktemp -d)
go run cmd/help/main.go --dir "$tmpdir"
echo "###########################################"
echo "If diffs are found, run: go run ./cmd/help/"
echo "###########################################"
diff -Naur "$tmpdir" doc/
37 changes: 37 additions & 0 deletions doc/cosign.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions doc/cosign_attach.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions doc/cosign_attach_sbom.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions doc/cosign_attach_signature.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions doc/cosign_attest.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions doc/cosign_clean.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions doc/cosign_copy.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 371845b

Please sign in to comment.