diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f320811..6ead78d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -122,6 +122,8 @@ jobs: run: poetry run mike deploy --push main env: GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }} + MKDOCS_GIT_COMMITTERS_APIKEY: ${{ github.token }} + EXCLUDE_SHIELDS_IO_PRIVACY: true - name: Deploy release docs if: ${{ github.event_name == 'workflow_dispatch' && needs.release.result == 'success' }} run: |- @@ -130,3 +132,4 @@ jobs: poetry run mike deploy --push --update-aliases ${{ needs.release.outputs.tag_name }} latest env: GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }} + MKDOCS_GIT_COMMITTERS_APIKEY: ${{ github.token }} diff --git a/.gitignore b/.gitignore index ab56be4..262638d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ -.idea/ +/.idea/ -dist/ +/dist/ # Ignore version binaries in root project-folder /version* /.cache/ +/site/ diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..f3f6fd2 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +/docs/includes/abbreviations.md diff --git a/CNAME b/CNAME deleted file mode 100644 index 85f3080..0000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -version-cli.app \ No newline at end of file diff --git a/README.md b/README.md index d0f4305..505ce3e 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,15 @@ -
+ + +
- logo + logo
-
- - -

Version

GitHub Tag GitHub go.mod Go version - GitHub Actions Workflow Status + GitHub Actions Workflow Status Sonar Quality Gate - Snyk Security + Snyk Security
`version` is a small cli tool that bumps your version number for you and retrieves the latest version of a specified diff --git a/docs/includes/abbreviations.md b/docs/includes/abbreviations.md index 94b8b60..92b83f4 100644 --- a/docs/includes/abbreviations.md +++ b/docs/includes/abbreviations.md @@ -1,2 +1,2 @@ -_[CLI]: Command Line Interface -_[cli]: Command Line Interface +*[CLI]: Command Line Interface +*[cli]: Command Line Interface diff --git a/docs/index.md b/docs/index.md index 037b39e..ce92317 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,3 @@
-
- logo -
--8<-- "README.md:description" diff --git a/docs/mkdocs-hooks/custom-edit-url.py b/docs/mkdocs-hooks/custom-edit-url.py index c551282..5a54afa 100644 --- a/docs/mkdocs-hooks/custom-edit-url.py +++ b/docs/mkdocs-hooks/custom-edit-url.py @@ -3,4 +3,4 @@ def on_page_context(context, page, **_): if 'edit_url' in page.meta: page.edit_url = page.meta['edit_url'] - return context + return context diff --git a/docs/mkdocs-hooks/privacy-exclude-shields-io.py b/docs/mkdocs-hooks/privacy-exclude-shields-io.py new file mode 100644 index 0000000..067f0d5 --- /dev/null +++ b/docs/mkdocs-hooks/privacy-exclude-shields-io.py @@ -0,0 +1,48 @@ +import logging +import os +import re +from urllib.parse import urlparse + +import material.plugins.privacy.plugin as privacy +from unittest.mock import patch + +from urllib.parse import ParseResult as URL +from mkdocs.structure.files import File +from colorama import Fore, Style + +# Set up logging +log = logging.getLogger("mkdocs.material.privacy") + + +def _is_excluded(self, url: URL, initiator: File | None = None): + if not self._is_external(url): + return True + + # Skip if external assets must not be processed + if not self.config.assets: + return True + + # If initiator is given, format for printing + via = "" + if initiator: + via = "".join([ + Fore.WHITE, Style.DIM, + f"in '{initiator.src_uri}' ", + Style.RESET_ALL + ]) + + # Print warning if fetching is not enabled + if not self.config.assets_fetch: + log.warning(f"External file: {url.geturl()} {via}") + return True + + if "img.shields.io" in url.geturl(): + return True + + # File is not excluded + return False + + +if os.getenv("EXCLUDE_SHIELDS_IO_PRIVACY") == "true": + # Only exclude shields.io from the privacy plugin if desired (i.e. for the "main" version of docs) + privacy.PrivacyPlugin._is_excluded = _is_excluded diff --git a/docs/mkdocs-hooks/relative-links.py b/docs/mkdocs-hooks/relative-links.py deleted file mode 100644 index 272359b..0000000 --- a/docs/mkdocs-hooks/relative-links.py +++ /dev/null @@ -1,2 +0,0 @@ -def on_page_markdown(markdown, *, config, **_): - return markdown.replace("./docs/", config.docs_dir) diff --git a/docs/mkdocs-hooks/relative-src.py b/docs/mkdocs-hooks/relative-src.py new file mode 100644 index 0000000..388d53d --- /dev/null +++ b/docs/mkdocs-hooks/relative-src.py @@ -0,0 +1,7 @@ +import re + + +def on_page_content(html: str, *, page, **_): + if page.file.src_uri == "index.md": + html = html.replace('data-is-relative="true" src="./docs/', 'data-is-relative="true" src="') + return html diff --git a/mkdocs.yaml b/mkdocs.yaml index 9c530dd..75bcd91 100644 --- a/mkdocs.yaml +++ b/mkdocs.yaml @@ -6,7 +6,7 @@ copyright: > Copyright © 2024 version-cli - Change cookie settings -strict: true +strict: false repo_name: version-cli/version repo_url: https://github.com/version-cli/version/ @@ -26,6 +26,8 @@ remote_branch: gh-pages hooks: - docs/mkdocs-hooks/custom-edit-url.py + - docs/mkdocs-hooks/relative-src.py + - docs/mkdocs-hooks/privacy-exclude-shields-io.py nav: - Home: index.md @@ -86,16 +88,18 @@ theme: plugins: - search - - privacy + - privacy: + assets_expr_map: + ".md": "[\"'](https://(?!img\\.shields\\.io)[^\"']+)[\"']" - social: cards_layout_options: background_color: "#D4AA01" color: "#ffffff" -# - git-revision-date-localized: -# enable_creation_date: true -# - git-committers: -# repository: version-cli/docs -# branch: main + - git-revision-date-localized: + enable_creation_date: true + - git-committers: + repository: version-cli/version + branch: main extra: analytics: