Skip to content

Commit 9dcc708

Browse files
authored
Tweak client ref doc page (#555)
* Show a commands shell-synopsis directly below the synopsis title * Add link in commands Examples text on how to set flags via env-var or config file * Update golden snyk.md used in docs page test * Update dev-guide.md with instructions on how to run tests
1 parent 8bf447d commit 9dcc708

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

cmd/kosli/docs.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,12 @@ func KosliGenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(st
131131

132132
if len(cmd.Long) > 0 {
133133
buf.WriteString("## Synopsis\n\n")
134+
if cmd.Runnable() {
135+
buf.WriteString(fmt.Sprintf("```shell\n%s\n```\n\n", cmd.UseLine()))
136+
}
134137
buf.WriteString(strings.Replace(cmd.Long, "^", "`", -1) + "\n\n")
135138
}
136139

137-
if cmd.Runnable() {
138-
buf.WriteString(fmt.Sprintf("```shell\n%s\n```\n\n", cmd.UseLine()))
139-
}
140-
141140
if err := printOptions(buf, cmd, name); err != nil {
142141
return err
143142
}
@@ -181,7 +180,9 @@ func KosliGenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(st
181180
// Note: The contents of the title lines could also contain < and > characters which will
182181
// be lost if simply embedded in a md ## section.
183182
buf.WriteString("## Examples Use Cases\n\n")
184-
buf.WriteString("These examples all assume that the flags `--api-token`, `--org`, `--host`, (and `--flow`, `--trail` when required), are set/provided. \n\n")
183+
url := "https://docs.kosli.com/getting_started/install/#assigning-flags-via-environment-variables"
184+
message := fmt.Sprintf("These examples all assume that the flags `--api-token`, `--org`, `--host`, (and `--flow`, `--trail` when required), are [set/provided](%v). \n\n", url)
185+
buf.WriteString(message)
185186

186187
// Some non-title lines contain a # character, (eg in a snappish) so we have to
187188
// split on newlines first and then only split on # in the first position

cmd/kosli/testdata/output/docs/snyk.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ summary: "Report a snyk attestation to an artifact or a trail in a Kosli flow.
99

1010
## Synopsis
1111

12+
```shell
13+
snyk [IMAGE-NAME | FILE-PATH | DIR-PATH] [flags]
14+
```
15+
1216
Report a snyk attestation to an artifact or a trail in a Kosli flow.
1317
Only SARIF snyk output is accepted.
1418
Snyk output can be for "snyk code test", "snyk container test", or "snyk iac test".
@@ -29,10 +33,6 @@ You can optionally redact some of the git commit data sent to Kosli using `--red
2933
Note that when the attestation is reported for an artifact that does not yet exist in Kosli, `--commit` is required to facilitate
3034
binding the attestation to the right artifact.
3135

32-
```shell
33-
snyk [IMAGE-NAME | FILE-PATH | DIR-PATH] [flags]
34-
```
35-
3636
## Flags
3737
| Flag | Description |
3838
| :--- | :--- |
@@ -62,7 +62,7 @@ snyk [IMAGE-NAME | FILE-PATH | DIR-PATH] [flags]
6262

6363
## Examples Use Cases
6464

65-
These examples all assume that the flags `--api-token`, `--org`, `--host`, (and `--flow`, `--trail` when required), are set/provided.
65+
These examples all assume that the flags `--api-token`, `--org`, `--host`, (and `--flow`, `--trail` when required), are [set/provided](https://docs.kosli.com/getting_started/install/#assigning-flags-via-environment-variables).
6666

6767
**report a snyk attestation about a pre-built docker artifact (kosli calculates the fingerprint)**
6868

dev-guide.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,14 @@ Then to run Kosli commands:
3939

4040
## Running the tests
4141

42+
To run the tests you need to set the env-var `KOSLI_API_TOKEN_PROD`
43+
to an api-token (with reader rights), for the `kosli` Org on https://app.kosli.com
44+
45+
To run all tests except the too slow ones:
46+
`make test_integration`
47+
48+
To run all the tests"
49+
`make test_integration_full`
50+
4251
To run only the tests in a single test suite, eg TestAttestJunitCommandTestSuite
4352
`make test_integration_single TARGET=TestAttestJunitCommandTestSuite`

0 commit comments

Comments
 (0)