Skip to content

Commit 46cd10e

Browse files
Merge branch 'docs' of github.ibm.com:SoftLayer/softlayer-cli into docs
2 parents f2e5b5d + 87b2d7e commit 46cd10e

2 files changed

Lines changed: 44 additions & 11 deletions

File tree

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,5 +449,24 @@ ENV Variables that need to be set:
449449
2. `IBMCLOUD_APIKEY` : API key for using `ibmcloud`. This is how we upload to COS. The COS plugin needs to be installed as well. `ibmcloud plugin install cloud-object-storage`
450450

451451

452+
# Documentation
453+
454+
`/docs/docs` is a command that will generate markdown documentation. This documentation needs to be copied and updated in the https://github.ibm.com/cloud-docs/cli repo (draft branch).
455+
456+
To build the full docs locally, see https://test.cloud.ibm.com/docs-internal/writing?topic=writing-transform-local
457+
458+
```bash
459+
➜ md-source pwd
460+
/Users/chris/Code/md-source
461+
➜ md-source ls -lh
462+
total 0
463+
drwxr-xr-x 3 chris staff 96B Nov 30 12:58 build
464+
drwxr-xr-x 3 chris staff 96B Nov 30 13:01 input
465+
drwxr-xr-x 4 chris staff 128B Nov 30 13:01 output
466+
467+
➜ marked-it-cli input --output=output --footer-file=build/markdown/footer.txt --extension-file=build/markdown/headerFooterExt.js --extension-file=build/markdown/generateSectionsExt.js --extension-file=build/markdown/accessibilityExt.js --extension-file=build/markdown/jsonTocExt.js --keyref-file=build/markdown/cloudoekeyrefs.yml --overwrite --verbose --toc-json --extension-file=build/markdown/videoExt.js --extension-file=build/markdown/terraformExt.js --extension-file=build/markdown/includesExt.js --extension-file=build/markdown/glossaryExt.js --@glossary:definitions-file=/Users/chris/Code/md-source/build/markdown/glossary.json
468+
```
469+
470+
452471
## TODO
453472
Automate build with https://github.ibm.com/coligo/cli/tree/main/script

docs/main.go

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ type SlCmdDoc struct {
5757
Flags []SlCmdFlag
5858
Help string
5959
LongHelp string
60+
Backtick string
61+
CommandPath string
6062
}
6163

6264
// For a commands flags
@@ -80,6 +82,7 @@ func CliDocs() {
8082
CommandShortLink: fmt.Sprintf("sl_%v", shortName),
8183
Commands: nil,
8284
Help: iCmd.Short,
85+
8386
}
8487
if len(iCmd.Commands()) > 0 {
8588
thisCmdGroup.Commands = buildSlCmdDoc(iCmd)
@@ -97,23 +100,30 @@ func CliDocs() {
97100
func PrintMakrdown(cmd SlCmdGroup) {
98101

99102
var cmdTemplate = `
100-
## {{.Name}}
103+
# ibmcloud sl {{.Name}}
101104
{: #{{.CommandShortLink}}}
102105
103106
{{.Help}}
104107
105108
{{range .Commands}}
106-
#### {{.Name}}
109+
## ibmcloud {{.CommandPath}}
107110
{: #{{.CommandShortLink}}}
108111
109112
{{.Help}}
110113
111-
**Command options**:
112-
{{range .Flags}}
113-
--{{.Name}} {{.Help}}
114-
{{end}}
115-
116114
{{.LongHelp}}
115+
116+
{{.Backtick}}bash
117+
ibmcloud {{.Use}}
118+
{{.Backtick}}
119+
{: codeblock}
120+
121+
{{if .Flags}}
122+
**Flags**:
123+
{{range .Flags}}
124+
--{{.Name}} {{.Help}}
125+
{{end}}
126+
{{end}}
117127
{{end}}
118128
119129
`
@@ -131,15 +141,19 @@ func PrintMakrdown(cmd SlCmdGroup) {
131141
func buildSlCmdDoc(topCommand *cobra.Command) []SlCmdDoc {
132142
docs := []SlCmdDoc{}
133143
for _, iCmd := range topCommand.Commands() {
134-
shortName := strings.ReplaceAll(iCmd.Name(), " ", "_")
135-
shortName = strings.ReplaceAll(iCmd.Name(), "-", "_")
144+
shortName := fmt.Sprintf("sl_%s_%s", topCommand.Name(), iCmd.Name())
145+
shortName = strings.ReplaceAll(shortName, " ", "_")
146+
shortName = strings.ReplaceAll(shortName, "-", "_")
147+
136148
thisDoc := SlCmdDoc{
137149
Name: iCmd.Name(),
138150
CommandShortLink: shortName,
139-
Use: iCmd.Use,
151+
CommandPath: iCmd.CommandPath(),
152+
Use: iCmd.UseLine(),
140153
Flags: nil,
141154
Help: iCmd.Short,
142-
LongHelp: iCmd.Long,
155+
LongHelp: strings.ReplaceAll(iCmd.Long, "${COMMAND_NAME}", "ibmcloud"),
156+
Backtick: "```",
143157
}
144158
thisDoc.Flags = buildSlCmdFlag(iCmd)
145159

0 commit comments

Comments
 (0)