Skip to content

Commit

Permalink
chore: add support to skip adding br tags to links or code (#394)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Dec 30, 2022
1 parent c17c3df commit 1926ef3
Show file tree
Hide file tree
Showing 8 changed files with 301 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-coverage.yml
Expand Up @@ -56,5 +56,5 @@ jobs:
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ github.token }}
github_token: ${{ secrets.PAT_TOKEN }}
branch: ${{ github.head_ref }}
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Expand Up @@ -104,9 +104,9 @@ jobs:
platform: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v3.2.0
uses: actions/checkout@v3
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token

- name: Setup go
Expand Down
20 changes: 10 additions & 10 deletions README.md
@@ -1,5 +1,5 @@
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/bb5dc10c1d2645c0894fa6774300639b)](https://app.codacy.com/gh/tj-actions/auto-doc?utm_source=github.com\&utm_medium=referral\&utm_content=tj-actions/auto-doc\&utm_campaign=Badge_Grade_Settings)
![Coverage](https://img.shields.io/badge/Coverage-84.4%25-brightgreen)
![Coverage](https://img.shields.io/badge/Coverage-81.2%25-brightgreen)
[![Go Reference](https://pkg.go.dev/badge/github.com/tj-actions/auto-doc.svg)](https://pkg.go.dev/github.com/tj-actions/auto-doc)
[![Go Report Card](https://goreportcard.com/badge/github.com/tj-actions/auto-doc)](https://goreportcard.com/report/github.com/tj-actions/auto-doc)
[![CI](https://github.com/tj-actions/auto-doc/workflows/CI/badge.svg)](https://github.com/tj-actions/auto-doc/actions?query=workflow%3ACI)
Expand Down Expand Up @@ -42,15 +42,15 @@ Add the `Inputs` and/or `Outputs` [`H2` header](https://github.com/adam-p/markdo

<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->

| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
|----------------|--------|----------|----------------|-----------------------------------------------------------------------------|
| action | string | false | `"action.yml"` | Path to the action.yml file<br> |
| bin\_path | string | false | | Path to the auto-doc binary<br> |
| col\_max\_width | string | false | `"1000"` | Max width of a column<br> |
| col\_max\_words | string | false | `"6"` | Max number of words per<br>line in a column |
| input\_columns | string | false | | List of Input columns names<br>to display, default (display all<br>columns) |
| output | string | false | `"README.md"` | Path to the output file<br> |
| output\_columns | string | false | | List of Output column names<br>to display, default (display all<br>columns) |
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
|----------------|--------|----------|----------------|------------------------------------------------------------------------------|
| action | string | false | `"action.yml"` | Path to the action.yml file<br> |
| bin\_path | string | false | | Path to the auto-doc binary<br> |
| col\_max\_width | string | false | `"1000"` | Max width of a column<br> |
| col\_max\_words | string | false | `"6"` | Max number of words per<br>line in a column |
| input\_columns | string | false | | List of Input columns names<br> to display, default (display all<br>columns) |
| output | string | false | `"README.md"` | Path to the output file<br> |
| output\_columns | string | false | | List of Output column names<br> to display, default (display all<br>columns) |

<!-- AUTO-DOC-INPUT:END -->

Expand Down
10 changes: 8 additions & 2 deletions cmd/root.go
Expand Up @@ -352,7 +352,7 @@ func RootCmdFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(
&colMaxWords,
"colMaxWords",
"5",
"6",
"Max number of words per line in a column",
)
cmd.Flags().StringArrayVar(
Expand Down Expand Up @@ -418,6 +418,11 @@ func wordWrap(s string, limit int) string {
// convert slice/array back to string
// but insert <br> at specified limit
// unless the current slice contains a Markdown link or code block or code
hasMore := len(strSlice) > currentLimit

if hasMore && len(result) > 0 {
result += " "
}

if len(strSlice) < currentLimit {
currentLimit = len(strSlice)
Expand All @@ -438,5 +443,6 @@ func wordWrap(s string, limit int) string {
currentLimit = len(strSlice)
}
}
return result

return strings.TrimSpace(result)
}

0 comments on commit 1926ef3

Please sign in to comment.