Skip to content

Commit

Permalink
Fix CLI doc generation bug (#3050)
Browse files Browse the repository at this point in the history
Fixes #2626

Actual cause of this issue is that MDX A) needs some of the characters
in the sample shell code to be escaped and B) even if you escape it, it
wont render the line as markdown properly.

Do some unholy things with sed to make it work. Forgive me.
  • Loading branch information
dmjb committed Apr 11, 2024
1 parent aa2f09b commit 6e21fc0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions .mk/gen.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,18 @@ mock: ## generate mocks
mockgen -package mockgh -destination internal/providers/github/mock/common.go github.com/stacklok/minder/internal/providers/github ClientService


# Ugly hack: cobra uses tabs for code blocks in markdown in some places
# This leads to some issues with MDX in the docs renderer
# Use sed to get rid of lines which begin with tabs and swap in backticks.
.PHONY: cli-docs
cli-docs: ## generate cli-docs
@rm -rf docs/docs/ref/cli
$(eval DOC_PATH := docs/docs/ref/cli)
@rm -rf ${DOC_PATH}
@mkdir -p docs/docs/ref/cli
@echo 'label: Minder CLI' > docs/docs/ref/cli/_category_.yml
@echo 'position: 20' >> docs/docs/ref/cli/_category_.yml
@echo 'label: Minder CLI' > ${DOC_PATH}/_category_.yml
@echo 'position: 20' >> ${DOC_PATH}/_category_.yml
@go run -tags '$(BUILDTAGS)' cmd/cli/main.go docs
@# this sed is much uglier than it should be so that it can run on Mac
@sed -i.bak 's/^ \(.*\)$$/```\$\n\1\$\n```/g' ${DOC_PATH}/minder_completion_zsh.md ${DOC_PATH}/minder_completion_bash.md
@# clean up temporary files created by sed
@rm ${DOC_PATH}/*.bak
1 change: 1 addition & 0 deletions docs/docs/ref/cli/minder_completion_bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ To load completions for every new session, execute once:
```
minder completion bash > /etc/bash_completion.d/minder
```

#### macOS:

```
Expand Down
1 change: 1 addition & 0 deletions docs/docs/ref/cli/minder_completion_zsh.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ minder completion zsh > "${fpath[1]}/_minder"
```

#### macOS:

```
minder completion zsh > $(brew --prefix)/share/zsh/site-functions/_minder
```
Expand Down

0 comments on commit 6e21fc0

Please sign in to comment.