From 181f2d06675d4cb16a0ce3a422dc1a66bb3ce59c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Mon, 9 Oct 2023 22:10:33 +0200 Subject: [PATCH] use mkdocs-awesome-pages-plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché --- Makefile | 2 +- catalog/aws/policy-1.yaml | 9 +- catalog/ecs/policy-1.yaml | 4 - hack/docs/catalog/main.go | 38 ++++++++ website/docs/.pages | 8 ++ website/docs/blog/.pages | 3 + website/docs/catalog/aws/policy-1.md | 18 ---- website/docs/catalog/ecs/policy-1.md | 19 ---- website/docs/catalog/policies/.pages | 3 + website/docs/catalog/policies/0.md | 26 ++++++ website/docs/catalog/policies/1.md | 21 +++++ website/docs/playground/.pages | 3 + .../{playground.md => playground/index.md} | 0 website/docs/policies/.pages | 13 +++ website/docs/policies/apis/.pages | 3 + .../apis/kyverno-json.v1alpha1.md | 0 website/docs/policies/commands/.pages | 15 ++++ .../{ => policies}/commands/kyverno-json.md | 0 .../commands/kyverno-json_completion.md | 0 .../commands/kyverno-json_completion_bash.md | 0 .../commands/kyverno-json_completion_fish.md | 0 .../kyverno-json_completion_powershell.md | 0 .../commands/kyverno-json_completion_zsh.md | 0 .../commands/kyverno-json_docs.md | 0 .../commands/kyverno-json_jp.md | 0 .../commands/kyverno-json_jp_function.md | 0 .../commands/kyverno-json_jp_parse.md | 0 .../commands/kyverno-json_jp_query.md | 0 .../commands/kyverno-json_scan.md | 0 .../commands/kyverno-json_version.md | 0 website/docs/policies/jp/.pages | 4 + website/docs/{ => policies}/jp/functions.md | 0 .../docs/{jp.md => policies/jp/overview.md} | 0 website/docs/start/.pages | 5 ++ website/docs/{intro.md => start/index.md} | 0 website/docs/{ => start}/install.md | 0 website/docs/{ => start}/quick-start.md | 0 website/mkdocs.yaml | 86 ++++++++++--------- 38 files changed, 192 insertions(+), 88 deletions(-) create mode 100644 hack/docs/catalog/main.go create mode 100644 website/docs/.pages create mode 100644 website/docs/blog/.pages delete mode 100644 website/docs/catalog/aws/policy-1.md delete mode 100644 website/docs/catalog/ecs/policy-1.md create mode 100644 website/docs/catalog/policies/.pages create mode 100644 website/docs/catalog/policies/0.md create mode 100644 website/docs/catalog/policies/1.md create mode 100644 website/docs/playground/.pages rename website/docs/{playground.md => playground/index.md} (100%) create mode 100644 website/docs/policies/.pages create mode 100644 website/docs/policies/apis/.pages rename website/docs/{ => policies}/apis/kyverno-json.v1alpha1.md (100%) create mode 100644 website/docs/policies/commands/.pages rename website/docs/{ => policies}/commands/kyverno-json.md (100%) rename website/docs/{ => policies}/commands/kyverno-json_completion.md (100%) rename website/docs/{ => policies}/commands/kyverno-json_completion_bash.md (100%) rename website/docs/{ => policies}/commands/kyverno-json_completion_fish.md (100%) rename website/docs/{ => policies}/commands/kyverno-json_completion_powershell.md (100%) rename website/docs/{ => policies}/commands/kyverno-json_completion_zsh.md (100%) rename website/docs/{ => policies}/commands/kyverno-json_docs.md (100%) rename website/docs/{ => policies}/commands/kyverno-json_jp.md (100%) rename website/docs/{ => policies}/commands/kyverno-json_jp_function.md (100%) rename website/docs/{ => policies}/commands/kyverno-json_jp_parse.md (100%) rename website/docs/{ => policies}/commands/kyverno-json_jp_query.md (100%) rename website/docs/{ => policies}/commands/kyverno-json_scan.md (100%) rename website/docs/{ => policies}/commands/kyverno-json_version.md (100%) create mode 100644 website/docs/policies/jp/.pages rename website/docs/{ => policies}/jp/functions.md (100%) rename website/docs/{jp.md => policies/jp/overview.md} (100%) create mode 100644 website/docs/start/.pages rename website/docs/{intro.md => start/index.md} (100%) rename website/docs/{ => start}/install.md (100%) rename website/docs/{ => start}/quick-start.md (100%) diff --git a/Makefile b/Makefile index c9d84680..1b088ef1 100644 --- a/Makefile +++ b/Makefile @@ -152,7 +152,7 @@ codegen-mkdocs: codegen-docs ## Generate mkdocs website @echo Generate mkdocs website... >&2 @pip3 install mkdocs @pip3 install --upgrade pip - @pip3 install -U mkdocs-material mkdocs-redirects mkdocs-minify-plugin mkdocs-include-markdown-plugin lunr mkdocs-rss-plugin + @pip3 install -U mkdocs-material mkdocs-redirects mkdocs-minify-plugin mkdocs-include-markdown-plugin lunr mkdocs-rss-plugin mkdocs-awesome-pages-plugin @rm -rf ./website/docs/apis && mkdir -p ./website/docs/apis && cp docs/user/apis/md/* ./website/docs/apis @rm -rf ./website/docs/commands && mkdir -p ./website/docs/commands && cp docs/user/commands/* ./website/docs/commands @rm -rf ./website/docs/jp && mkdir -p ./website/docs/jp && cp docs/user/jp/* ./website/docs/jp diff --git a/catalog/aws/policy-1.yaml b/catalog/aws/policy-1.yaml index e5c2414e..02d2d831 100644 --- a/catalog/aws/policy-1.yaml +++ b/catalog/aws/policy-1.yaml @@ -1,11 +1,12 @@ ---- -tags: -- aws ---- apiVersion: json.kyverno.io/v1alpha1 kind: Policy metadata: name: test + labels: + s3.aws.catalog.kyverno.io: '' + annotations: + title.catalog.kyverno.io: Policy 1 + description.catalog.kyverno.io: Policy 1 spec: rules: - name: foo-bar diff --git a/catalog/ecs/policy-1.yaml b/catalog/ecs/policy-1.yaml index 5a38da09..6884961d 100644 --- a/catalog/ecs/policy-1.yaml +++ b/catalog/ecs/policy-1.yaml @@ -1,7 +1,3 @@ ---- -tags: -- ecs ---- apiVersion: json.kyverno.io/v1alpha1 kind: Policy metadata: diff --git a/hack/docs/catalog/main.go b/hack/docs/catalog/main.go new file mode 100644 index 00000000..6e1691e4 --- /dev/null +++ b/hack/docs/catalog/main.go @@ -0,0 +1,38 @@ +package main + +import ( + "fmt" + "os" + + "github.com/kyverno/kyverno-json/pkg/policy" + "sigs.k8s.io/yaml" +) + +func main() { + policies, err := policy.Load("./catalog") + if err != nil { + panic(err) + } + for i, policy := range policies { + f, err := os.Create("website/docs/catalog/policies/" + fmt.Sprintf("%d.md", i)) + if err != nil { + panic(err) + } + defer f.Close() + bytes, err := yaml.Marshal(policy) + if err != nil { + panic(err) + } + fmt.Fprintln(f, "# "+policy.Annotations["title.catalog.kyverno.io"]) + fmt.Fprintln(f) + fmt.Fprintln(f, policy.Annotations["description.catalog.kyverno.io"]) + fmt.Fprintln(f) + fmt.Fprintln(f, "## Manifest") + fmt.Fprintln(f) + fmt.Fprintln(f, "```yaml") + if _, err := f.Write(bytes); err != nil { + panic(err) + } + fmt.Fprintln(f, "```") + } +} diff --git a/website/docs/.pages b/website/docs/.pages new file mode 100644 index 00000000..9d821fca --- /dev/null +++ b/website/docs/.pages @@ -0,0 +1,8 @@ +nav: +- Home: index.md +- start +- policies +- Policy catalog: + - catalog/index.md +- playground +- blog diff --git a/website/docs/blog/.pages b/website/docs/blog/.pages new file mode 100644 index 00000000..a5489bb8 --- /dev/null +++ b/website/docs/blog/.pages @@ -0,0 +1,3 @@ +nav: +- Blog: + - index.md diff --git a/website/docs/catalog/aws/policy-1.md b/website/docs/catalog/aws/policy-1.md deleted file mode 100644 index c6c60156..00000000 --- a/website/docs/catalog/aws/policy-1.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -tags: -- aws ---- -```yaml -apiVersion: json.kyverno.io/v1alpha1 -kind: Policy -metadata: - name: test -spec: - rules: - - name: foo-bar - validate: - assert: - all: - - foo: - /(bar)/: 10 -``` \ No newline at end of file diff --git a/website/docs/catalog/ecs/policy-1.md b/website/docs/catalog/ecs/policy-1.md deleted file mode 100644 index b4e4c4ce..00000000 --- a/website/docs/catalog/ecs/policy-1.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -tags: -- acs -- ecs ---- -```yaml -apiVersion: json.kyverno.io/v1alpha1 -kind: Policy -metadata: - name: test -spec: - rules: - - name: foo-bar - validate: - assert: - all: - - foo: - /(bar)/: 10 -``` \ No newline at end of file diff --git a/website/docs/catalog/policies/.pages b/website/docs/catalog/policies/.pages new file mode 100644 index 00000000..80f2baf8 --- /dev/null +++ b/website/docs/catalog/policies/.pages @@ -0,0 +1,3 @@ +nav: +- 0.md +- 1.md diff --git a/website/docs/catalog/policies/0.md b/website/docs/catalog/policies/0.md new file mode 100644 index 00000000..21b123d6 --- /dev/null +++ b/website/docs/catalog/policies/0.md @@ -0,0 +1,26 @@ +# Policy 1 + +Policy 1 + +## Manifest + +```yaml +apiVersion: json.kyverno.io/v1alpha1 +kind: Policy +metadata: + annotations: + description.catalog.kyverno.io: Policy 1 + title.catalog.kyverno.io: Policy 1 + creationTimestamp: null + labels: + s3.aws.catalog.kyverno.io: "" + name: test +spec: + rules: + - name: foo-bar + validate: + assert: + all: + - foo: + /(bar)/: 10 +``` diff --git a/website/docs/catalog/policies/1.md b/website/docs/catalog/policies/1.md new file mode 100644 index 00000000..4833743b --- /dev/null +++ b/website/docs/catalog/policies/1.md @@ -0,0 +1,21 @@ +# + + + +## Manifest + +```yaml +apiVersion: json.kyverno.io/v1alpha1 +kind: Policy +metadata: + creationTimestamp: null + name: test +spec: + rules: + - name: foo-bar + validate: + assert: + all: + - foo: + /(bar)/: 10 +``` diff --git a/website/docs/playground/.pages b/website/docs/playground/.pages new file mode 100644 index 00000000..64a8fb8a --- /dev/null +++ b/website/docs/playground/.pages @@ -0,0 +1,3 @@ +nav: +- Playground: + - index.md diff --git a/website/docs/playground.md b/website/docs/playground/index.md similarity index 100% rename from website/docs/playground.md rename to website/docs/playground/index.md diff --git a/website/docs/policies/.pages b/website/docs/policies/.pages new file mode 100644 index 00000000..65ae95cf --- /dev/null +++ b/website/docs/policies/.pages @@ -0,0 +1,13 @@ +nav: +- Writing policies: + - index.md + - Basics: + - api-version.md + - match.md + - assertion-trees.md + - modifiers.md + - explicit-bindings.md + - escaping.md + - commands + - jp + - apis diff --git a/website/docs/policies/apis/.pages b/website/docs/policies/apis/.pages new file mode 100644 index 00000000..f27b7417 --- /dev/null +++ b/website/docs/policies/apis/.pages @@ -0,0 +1,3 @@ +nav: +- APIs: + - v1alpha1: kyverno-json.v1alpha1.md diff --git a/website/docs/apis/kyverno-json.v1alpha1.md b/website/docs/policies/apis/kyverno-json.v1alpha1.md similarity index 100% rename from website/docs/apis/kyverno-json.v1alpha1.md rename to website/docs/policies/apis/kyverno-json.v1alpha1.md diff --git a/website/docs/policies/commands/.pages b/website/docs/policies/commands/.pages new file mode 100644 index 00000000..11df0b26 --- /dev/null +++ b/website/docs/policies/commands/.pages @@ -0,0 +1,15 @@ +nav: +- Command Line Usage: + - kyverno-json.md + - kyverno-json_completion.md + - kyverno-json_completion_bash.md + - kyverno-json_completion_fish.md + - kyverno-json_completion_powershell.md + - kyverno-json_completion_zsh.md + - kyverno-json_docs.md + - kyverno-json_jp.md + - kyverno-json_jp_function.md + - kyverno-json_jp_parse.md + - kyverno-json_jp_query.md + - kyverno-json_scan.md + - kyverno-json_version.md diff --git a/website/docs/commands/kyverno-json.md b/website/docs/policies/commands/kyverno-json.md similarity index 100% rename from website/docs/commands/kyverno-json.md rename to website/docs/policies/commands/kyverno-json.md diff --git a/website/docs/commands/kyverno-json_completion.md b/website/docs/policies/commands/kyverno-json_completion.md similarity index 100% rename from website/docs/commands/kyverno-json_completion.md rename to website/docs/policies/commands/kyverno-json_completion.md diff --git a/website/docs/commands/kyverno-json_completion_bash.md b/website/docs/policies/commands/kyverno-json_completion_bash.md similarity index 100% rename from website/docs/commands/kyverno-json_completion_bash.md rename to website/docs/policies/commands/kyverno-json_completion_bash.md diff --git a/website/docs/commands/kyverno-json_completion_fish.md b/website/docs/policies/commands/kyverno-json_completion_fish.md similarity index 100% rename from website/docs/commands/kyverno-json_completion_fish.md rename to website/docs/policies/commands/kyverno-json_completion_fish.md diff --git a/website/docs/commands/kyverno-json_completion_powershell.md b/website/docs/policies/commands/kyverno-json_completion_powershell.md similarity index 100% rename from website/docs/commands/kyverno-json_completion_powershell.md rename to website/docs/policies/commands/kyverno-json_completion_powershell.md diff --git a/website/docs/commands/kyverno-json_completion_zsh.md b/website/docs/policies/commands/kyverno-json_completion_zsh.md similarity index 100% rename from website/docs/commands/kyverno-json_completion_zsh.md rename to website/docs/policies/commands/kyverno-json_completion_zsh.md diff --git a/website/docs/commands/kyverno-json_docs.md b/website/docs/policies/commands/kyverno-json_docs.md similarity index 100% rename from website/docs/commands/kyverno-json_docs.md rename to website/docs/policies/commands/kyverno-json_docs.md diff --git a/website/docs/commands/kyverno-json_jp.md b/website/docs/policies/commands/kyverno-json_jp.md similarity index 100% rename from website/docs/commands/kyverno-json_jp.md rename to website/docs/policies/commands/kyverno-json_jp.md diff --git a/website/docs/commands/kyverno-json_jp_function.md b/website/docs/policies/commands/kyverno-json_jp_function.md similarity index 100% rename from website/docs/commands/kyverno-json_jp_function.md rename to website/docs/policies/commands/kyverno-json_jp_function.md diff --git a/website/docs/commands/kyverno-json_jp_parse.md b/website/docs/policies/commands/kyverno-json_jp_parse.md similarity index 100% rename from website/docs/commands/kyverno-json_jp_parse.md rename to website/docs/policies/commands/kyverno-json_jp_parse.md diff --git a/website/docs/commands/kyverno-json_jp_query.md b/website/docs/policies/commands/kyverno-json_jp_query.md similarity index 100% rename from website/docs/commands/kyverno-json_jp_query.md rename to website/docs/policies/commands/kyverno-json_jp_query.md diff --git a/website/docs/commands/kyverno-json_scan.md b/website/docs/policies/commands/kyverno-json_scan.md similarity index 100% rename from website/docs/commands/kyverno-json_scan.md rename to website/docs/policies/commands/kyverno-json_scan.md diff --git a/website/docs/commands/kyverno-json_version.md b/website/docs/policies/commands/kyverno-json_version.md similarity index 100% rename from website/docs/commands/kyverno-json_version.md rename to website/docs/policies/commands/kyverno-json_version.md diff --git a/website/docs/policies/jp/.pages b/website/docs/policies/jp/.pages new file mode 100644 index 00000000..4ae5b6a9 --- /dev/null +++ b/website/docs/policies/jp/.pages @@ -0,0 +1,4 @@ +nav: +- JMESPath: + - Overview: overview.md + - Functions: functions.md diff --git a/website/docs/jp/functions.md b/website/docs/policies/jp/functions.md similarity index 100% rename from website/docs/jp/functions.md rename to website/docs/policies/jp/functions.md diff --git a/website/docs/jp.md b/website/docs/policies/jp/overview.md similarity index 100% rename from website/docs/jp.md rename to website/docs/policies/jp/overview.md diff --git a/website/docs/start/.pages b/website/docs/start/.pages new file mode 100644 index 00000000..9aa8a32e --- /dev/null +++ b/website/docs/start/.pages @@ -0,0 +1,5 @@ +nav: +- Getting Started: + - index.md + - install.md + - quick-start.md diff --git a/website/docs/intro.md b/website/docs/start/index.md similarity index 100% rename from website/docs/intro.md rename to website/docs/start/index.md diff --git a/website/docs/install.md b/website/docs/start/install.md similarity index 100% rename from website/docs/install.md rename to website/docs/start/install.md diff --git a/website/docs/quick-start.md b/website/docs/start/quick-start.md similarity index 100% rename from website/docs/quick-start.md rename to website/docs/start/quick-start.md diff --git a/website/mkdocs.yaml b/website/mkdocs.yaml index e06e8814..c39962e6 100644 --- a/website/mkdocs.yaml +++ b/website/mkdocs.yaml @@ -51,6 +51,9 @@ theme: plugins: - search +- awesome-pages: + strict: false + collapse_single_pages: true # - redirects: # redirect_maps: # discord.md: https://discord.gg/RGEBtg8vQ6 @@ -71,48 +74,47 @@ plugins: - blog: post_url_format: "{slug}" -nav: -- Home: index.md -- Getting Started: - - intro.md - - install.md - - quick-start.md -- Writing policies: - - policies/index.md - - Basics: - - policies/api-version.md - - policies/match.md - - policies/assertion-trees.md - - policies/modifiers.md - - policies/explicit-bindings.md - - policies/escaping.md - - Command Line Usage: - - commands/kyverno-json.md - - commands/kyverno-json_completion.md - - commands/kyverno-json_completion_bash.md - - commands/kyverno-json_completion_fish.md - - commands/kyverno-json_completion_powershell.md - - commands/kyverno-json_completion_zsh.md - - commands/kyverno-json_docs.md - - commands/kyverno-json_jp.md - - commands/kyverno-json_jp_function.md - - commands/kyverno-json_jp_parse.md - - commands/kyverno-json_jp_query.md - - commands/kyverno-json_scan.md - - commands/kyverno-json_version.md - - JMESPath: - - Overview: jp.md - - Functions: jp/functions.md - - APIs: - - v1alpha1: apis/kyverno-json.v1alpha1.md -- Policy catalog: - - catalog/index.md - - catalog/aws/policy-1.md - - catalog/ecs/policy-1.md -- Playground: - - playground.md -- Blog: - - blog/index.md +# nav: +# - Home: index.md +# - Getting Started: +# - intro.md +# - install.md +# - quick-start.md +# - Writing policies: +# - policies/index.md +# - Basics: +# - policies/api-version.md +# - policies/match.md +# - policies/assertion-trees.md +# - policies/modifiers.md +# - policies/explicit-bindings.md +# - policies/escaping.md +# - Command Line Usage: +# - commands/kyverno-json.md +# - commands/kyverno-json_completion.md +# - commands/kyverno-json_completion_bash.md +# - commands/kyverno-json_completion_fish.md +# - commands/kyverno-json_completion_powershell.md +# - commands/kyverno-json_completion_zsh.md +# - commands/kyverno-json_docs.md +# - commands/kyverno-json_jp.md +# - commands/kyverno-json_jp_function.md +# - commands/kyverno-json_jp_parse.md +# - commands/kyverno-json_jp_query.md +# - commands/kyverno-json_scan.md +# - commands/kyverno-json_version.md +# - JMESPath: +# - Overview: jp.md +# - Functions: jp/functions.md +# - APIs: +# - v1alpha1: apis/kyverno-json.v1alpha1.md +# - Policy catalog: +# - catalog/index.md +# - catalog/policies +# - Playground: +# - playground.md +# - Blog: +# - blog/index.md markdown_extensions: - admonition