From aec155e96a226afdef442be96b0e9b49fac48a71 Mon Sep 17 00:00:00 2001 From: Flook Peter Date: Fri, 18 Oct 2024 15:14:56 +0800 Subject: [PATCH] Add in dynamic nav for examples --- .github/workflows/docs-site-deploy.yaml | 2 +- .gitignore | 7 ++++++ docs/examples/README.md | 32 ++++++++++++------------- mkdocs.yml | 5 +++- src/script/build_docs.sh | 8 ++++--- 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/.github/workflows/docs-site-deploy.yaml b/.github/workflows/docs-site-deploy.yaml index 36366bd..2c93766 100644 --- a/.github/workflows/docs-site-deploy.yaml +++ b/.github/workflows/docs-site-deploy.yaml @@ -27,7 +27,7 @@ jobs: path: .cache restore-keys: | mkdocs-material- - - run: pip install mkdocs-material mkdocs-open-in-new-tab "mkdocs-material[imaging]" mike + - run: pip install mkdocs-material mkdocs-open-in-new-tab "mkdocs-material[imaging]" mkdocs-awesome-pages-plugin mike - run: bash src/script/build_docs.sh - run: | latest_tag=$(git describe --tags --abbrev=0) diff --git a/.gitignore b/.gitignore index 10b3150..a0889dc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,10 @@ .idea site *.iml +.cache + +docs/changelog.md +docs/contributing.md +docs/home.md +docs/vendors.md +docs/examples/**/*.md \ No newline at end of file diff --git a/docs/examples/README.md b/docs/examples/README.md index fb75e18..aab8fc0 100644 --- a/docs/examples/README.md +++ b/docs/examples/README.md @@ -17,46 +17,46 @@ This folder contains mainly excerpts of data contracts to illustrate specific se ## Full example -- [Full example](all/full-example.odcs.yaml) -- [Postgres AdventureWorks](all/postgresql-adventureworks-contract.odcs.yaml) +- [Full example](all/full-example.md) +- [Postgres AdventureWorks](all/postgresql-adventureworks-contract.md) ## Fundamentals -- [Table and column](fundamentals/table-column-description.odcs.yaml) +- [Table and column](fundamentals/table-column-description.md) ## Dataset and schema -- [All schema types](schema/all-schema-types.odcs.yaml) -- [Data types](data-types/all-data-types.odcs.yaml) -- [Table with single column](schema/table-column.odcs.yaml) -- [Table with columns and partitioning](schema/table-columns-with-partition.odcs.yaml) +- [All schema types](schema/all-schema-types.md) +- [Data types](data-types/all-data-types.md) +- [Table with single column](schema/table-column.md) +- [Table with columns and partitioning](schema/table-columns-with-partition.md) ## Data quality -- [Column accuracy](quality/column-accuracy.odcs.yaml) -- [Column completeness](quality/column-completeness.odcs.yaml) -- [Column custom](quality/column-custom.odcs.yaml) -- [Column validity](quality/column-validity.odcs.yaml) +- [Column accuracy](quality/column-accuracy.md) +- [Column completeness](quality/column-completeness.md) +- [Column custom](quality/column-custom.md) +- [Column validity](quality/column-validity.md) ## Server -- [Azure server](server/azure-server.odcs.yaml) -- [Kafka server](server/kafka-server.odcs.yaml) +- [Azure server](server/azure-server.md) +- [Kafka server](server/kafka-server.md) ## Pricing This section covers pricing when you bill your customer for using this data product. ## Stakeholders -- [Stakeholders example](stakeholders/basic-four-dpo.odcs.yaml) +- [Stakeholders example](stakeholders/basic-four-dpo.md) ## Roles -- [Service and operational roles](roles/service-and-operational-roles.odcs.yaml) +- [Service and operational roles](roles/service-and-operational-roles.md) ## Service-level agreement -- [Database SLA](sla/database-table-sla.odcs.yaml) +- [Database SLA](sla/database-table-sla.md) ## Other properties Coming soon. diff --git a/mkdocs.yml b/mkdocs.yml index 0cd0fed..3e583d7 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -7,6 +7,7 @@ plugins: - open-in-new-tab - search - social + - awesome-pages theme: name: material @@ -34,7 +35,9 @@ theme: nav: - Home: 'home.md' - Standard: 'README.md' - - Examples: 'examples/README.md' + - Examples: + - 'examples/README.md' + - '...' - Changelog: 'changelog.md' - Contributing: 'contributing.md' - Vendors: 'vendors.md' diff --git a/src/script/build_docs.sh b/src/script/build_docs.sh index 5851fa0..0d6e972 100644 --- a/src/script/build_docs.sh +++ b/src/script/build_docs.sh @@ -10,7 +10,8 @@ echo "Creating markdown file for each example" for f in docs/examples/**/*.yaml; do yaml_content=$(cat "$f") markdown_file_path="${f//odcs.yaml/md}" - header="${f//docs\/examples\//}" + file_name=$(basename "$f" .odcs.yaml) + header=$(echo "${file_name//\-/ }" | sed -e "s/\b\(.\)/\u\1/g") echo "Creating file: $markdown_file_path" content=$(cat <<-END # ${header} @@ -21,7 +22,8 @@ ${yaml_content} END ) echo "$content" > "$markdown_file_path" - escaped_header="${header//\//\\/}" + base_path="${f//docs\/examples\//}" + escaped_header="${base_path//\//\\/}" replacement_link="${escaped_header//odcs.yaml/md}" - sed -i -e "s/$escaped_header/$replacement_link/g" docs/examples/README.md + sed -i '' -e "s/$escaped_header/$replacement_link/g" docs/examples/README.md done