Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix links in fields doc #3539

Merged
merged 10 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.x
- name: Setup Golang
uses: actions/setup-go@v1
with:
go-version: '1.13.12'
- name: build
run: |
pip install mkdocs==1.0.4 mkdocs_material==4.1.1
mkdocs build
make parse-examples
mkdir ./site/.circleci && echo '{version: 2, jobs: {build: {branches: {ignore: gh-pages}}}}' > ./site/.circleci/config.yml
- name: deploy
uses: peaceiris/actions-gh-pages@v2.5.0
env:
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./site
PUBLISH_DIR: ./site
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,7 @@ endif
.PHONY: check-version-warning
check-version-warning:
@if [[ "$(VERSION)" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then echo -n "It looks like you're trying to use a SemVer version, but have not prepended it with a "v" (such as "v$(VERSION)"). The "v" is required for our releases. Do you wish to continue anyway? [y/N]" && read ans && [ $${ans:-N} = y ]; fi

.PHONY: parse-examples
parse-examples:
go run -tags fields ./hack parseexamples
2 changes: 2 additions & 0 deletions hack/docgen.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !fields
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file imports "github.com/argoproj/argo/cmd/argo/commands", so it will in effect build the entire codebase into the binary. This takes a lot of time and it will require generating static files, which takes even longer. Since this is unnecessary for the script in this PR, don't include this file when we're building for this purpose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this. Can I ask we just fix the docs?


package main

import (
Expand Down
6 changes: 5 additions & 1 deletion hack/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import "os"
import (
"os"
)

func main() {
switch os.Args[1] {
Expand All @@ -14,6 +16,8 @@ func main() {
kubeifySwagger(os.Args[2], os.Args[3])
case "secondaryswaggergen":
secondarySwaggerGen()
case "parseexamples":
parseExamples()
default:
panic(os.Args[1])
}
Expand Down
7 changes: 7 additions & 0 deletions hack/null_docgen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// +build fields

package main

func generateDocs() {
panic("hack package was built with 'fields' tag; doc generation code was not included")
}
42 changes: 42 additions & 0 deletions hack/parse_examples.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"io/ioutil"
"regexp"
)

const (
newHeader = `<summary>Examples with this field (click to open)</summary>
<br>
<ul>`
newHeaderAlt = `<summary>Examples (click to open)</summary>
<br>
<ul>`
newLink = ` <li> <a href="$2">$1</a>`
newDetails = `</ul>
</details>`
)

var (
headerRegex = regexp.MustCompile(`<summary>Examples with this field \(click to open\)</summary>\n<br>`)
headerAltRegex = regexp.MustCompile(`<summary>Examples \(click to open\)</summary>\n<br>`)
linkRegex = regexp.MustCompile(`- \[\x60(.+?)\x60\]\((.+?)\)`)
detailsRegex = regexp.MustCompile(`</details>`)
)

func parseExamples() {
file, err := ioutil.ReadFile("site/fields/index.html")
if err != nil {
panic(err)
}

file = headerRegex.ReplaceAll(file, []byte(newHeader))
file = headerAltRegex.ReplaceAll(file, []byte(newHeaderAlt))
file = linkRegex.ReplaceAll(file, []byte(newLink))
file = detailsRegex.ReplaceAll(file, []byte(newDetails))

err = ioutil.WriteFile("site/fields/index.html", file, 0644)
if err != nil {
panic(err)
}
}