From 0dcb2c9ff54ef0efbdb2d9029d6038ae9458b7d4 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 21 Aug 2023 21:52:26 +0200 Subject: [PATCH 01/40] Fixed Docker image build --- .github/workflows/build.yml | 11 ++++++----- Dockerfile | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 62d2c4c3e4e..0c3b8fff2ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,7 @@ on: push: branches: - master + - fix/docker-build pull_request: release: types: @@ -106,14 +107,14 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Login to DockerHub - if: github.event_name == 'release' + #if: github.event_name == 'release' uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Login to GitHub Container Registry - if: github.event_name == 'release' + #if: github.event_name == 'release' uses: docker/login-action@v2 with: registry: ghcr.io @@ -153,7 +154,7 @@ jobs: docker run --rm -i -v ${PWD}:/docs ${REPO_FULL_NAME,,}:${{ steps.meta.outputs.version }} build - name: Set platforms - if: github.event_name == 'release' + #if: github.event_name == 'release' run: | echo "PLATFORMS=linux/amd64,linux/arm64,linux/arm/v7" >> $GITHUB_ENV @@ -167,12 +168,12 @@ jobs: labels: ${{ steps.meta.outputs.labels }} - name: Check manifest - if: github.event_name == 'release' + #if: github.event_name == 'release' run: | docker buildx imagetools inspect ${{ github.event.repository.full_name }}:${{ steps.meta.outputs.version }} - name: Inspect image - if: github.event_name == 'release' + #if: github.event_name == 'release' run: | docker pull ${{ github.event.repository.full_name }}:${{ steps.meta.outputs.version }} docker image inspect ${{ github.event.repository.full_name }}:${{ steps.meta.outputs.version }} diff --git a/Dockerfile b/Dockerfile index 5595e842a89..0c15409b8eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,12 +47,16 @@ RUN \ git \ git-fast-import \ jpeg-dev \ + libxml2 \ + libxslt \ openssh \ zlib-dev \ && \ apk add --no-cache --virtual .build \ gcc \ libffi-dev \ + libxml2-dev \ + libxslt-dev \ musl-dev \ && \ pip install --no-cache-dir --upgrade pip \ From f918ab3effa9b2f4cebb3e53f287dc379cd4a502 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 21 Aug 2023 22:06:54 +0200 Subject: [PATCH 02/40] Fixed Docker image build --- .github/workflows/build.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0c3b8fff2ed..62d2c4c3e4e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,6 @@ on: push: branches: - master - - fix/docker-build pull_request: release: types: @@ -107,14 +106,14 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Login to DockerHub - #if: github.event_name == 'release' + if: github.event_name == 'release' uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Login to GitHub Container Registry - #if: github.event_name == 'release' + if: github.event_name == 'release' uses: docker/login-action@v2 with: registry: ghcr.io @@ -154,7 +153,7 @@ jobs: docker run --rm -i -v ${PWD}:/docs ${REPO_FULL_NAME,,}:${{ steps.meta.outputs.version }} build - name: Set platforms - #if: github.event_name == 'release' + if: github.event_name == 'release' run: | echo "PLATFORMS=linux/amd64,linux/arm64,linux/arm/v7" >> $GITHUB_ENV @@ -168,12 +167,12 @@ jobs: labels: ${{ steps.meta.outputs.labels }} - name: Check manifest - #if: github.event_name == 'release' + if: github.event_name == 'release' run: | docker buildx imagetools inspect ${{ github.event.repository.full_name }}:${{ steps.meta.outputs.version }} - name: Inspect image - #if: github.event_name == 'release' + if: github.event_name == 'release' run: | docker pull ${{ github.event.repository.full_name }}:${{ steps.meta.outputs.version }} docker image inspect ${{ github.event.repository.full_name }}:${{ steps.meta.outputs.version }} From 9ab19e626b82d6643031eb292324d953f9812547 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 21 Aug 2023 22:26:31 +0200 Subject: [PATCH 03/40] Updated Insiders changelog --- CHANGELOG | 4 ++++ docs/insiders/changelog.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 44851315422..b0d1359857b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +mkdocs-material-9.2.0+insiders-4.39.1 (2023-08-21) + +- Fixed git diff in tags plugin after merging back 9.2.0 changes + mkdocs-material-9.2.0 (2023-08-21) Additions and improvements diff --git a/docs/insiders/changelog.md b/docs/insiders/changelog.md index c658a13b192..090bda17557 100644 --- a/docs/insiders/changelog.md +++ b/docs/insiders/changelog.md @@ -2,6 +2,10 @@ ## Material for MkDocs Insiders +### 4.39.1 August 32, 2023 { id="4.39.1" } + +- Fixed git diff in tags plugin after merging back 9.2.0 changes + ### 4.39.0 August 3, 2023 { id="4.39.0" } - Added support for hoisting theme media files when building projects From a313fa9956d3655e3298536a8ac8e44b2b370c52 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 21 Aug 2023 22:38:04 +0200 Subject: [PATCH 04/40] Documentation --- docs/setup/setting-up-a-blog.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/setup/setting-up-a-blog.md b/docs/setup/setting-up-a-blog.md index 80a0a4cbaa4..d188614ff72 100644 --- a/docs/setup/setting-up-a-blog.md +++ b/docs/setup/setting-up-a-blog.md @@ -1076,10 +1076,11 @@ post with one or multiple [authors]. First, create the [`.authors.yml`][authors_file] file in your blog directory, and add an author: ``` yaml -squidfunk: - name: Martin Donath - description: Creator - avatar: https://github.com/squidfunk.png +authors: + squidfunk: + name: Martin Donath + description: Creator + avatar: https://github.com/squidfunk.png ``` The [`.authors.yml`][authors_file] file associates each author with an From 7099ea60a9f6894d95c88c2e94db72f5474f502e Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 21 Aug 2023 23:01:37 +0200 Subject: [PATCH 05/40] Fixed several errors in blog plugin --- material/plugins/blog/plugin.py | 13 ++++++++++--- material/plugins/blog/structure/__init__.py | 2 +- material/plugins/blog/structure/options.py | 6 ++++-- src/plugins/blog/plugin.py | 13 ++++++++++--- src/plugins/blog/structure/__init__.py | 2 +- src/plugins/blog/structure/options.py | 6 ++++-- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index 2d156390f6f..b8c53c821b3 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -326,7 +326,7 @@ def _is_excluded(self, post: Post): # and must be explicitly enabled by the author. if not isinstance(post.config.draft, bool): if self.config.draft_if_future_date: - return post.config.date > datetime.now() + return post.config.date.created > datetime.now() # Post might be a draft return bool(post.config.draft) @@ -364,7 +364,7 @@ def _resolve(self, files: Files, config: MkDocsConfig, nav: Navigation): ]) # Update entrypoint in navigation - for items in [view.parent.children, nav.pages]: + for items in [self._resolve_siblings(view.parent, nav), nav.pages]: items[items.index(page)] = view # Return view @@ -484,6 +484,13 @@ def _resolve_views(self, view: View): assert isinstance(page, View) yield page + # Resolve siblings of a navigation item + def _resolve_siblings(self, item: StructureItem, nav: Navigation): + if isinstance(item, Section): + return item.children + else: + return nav.items + # ------------------------------------------------------------------------- # Attach a list of pages to each other and to the given parent item without @@ -505,7 +512,7 @@ def _attach_to(self, parent: Section, section: Section, nav: Navigation): # the top-level navigation, if no parent section was given. Note, that # it's currently not possible to chose the position of a section, but # we might add support for this in the future. - items = parent.children if parent else nav.items + items = self._resolve_siblings(parent, nav) items.append(section) # Find last sibling that is a page, skipping sections, as we need to diff --git a/material/plugins/blog/structure/__init__.py b/material/plugins/blog/structure/__init__.py index 6003cadd372..725c9bc6637 100644 --- a/material/plugins/blog/structure/__init__.py +++ b/material/plugins/blog/structure/__init__.py @@ -245,7 +245,7 @@ def _patch(config: MkDocsConfig): config.validation = copy(config.validation) config.validation.links = copy(config.validation.links) config.mdx_configs = copy(config.mdx_configs) - config.mdx_configs["toc"] = copy(config.mdx_configs["toc"]) + config.mdx_configs["toc"] = copy(config.mdx_configs.get("toc", {})) # In order to render excerpts for posts, we need to make sure that the # table of contents extension is appropriately configured diff --git a/material/plugins/blog/structure/options.py b/material/plugins/blog/structure/options.py index 0b36d8cfba4..d37779185bd 100644 --- a/material/plugins/blog/structure/options.py +++ b/material/plugins/blog/structure/options.py @@ -60,12 +60,14 @@ def pre_validation(self, config: Config, key_name: str): if not isinstance(config[key_name], dict): config[key_name] = { "created": config[key_name] } - # Initialize date dictionary and convert all date values to datetime - config[key_name] = DateDict(config[key_name]) + # Convert all date values to datetime for key, value in config[key_name].items(): if isinstance(value, date): config[key_name][key] = datetime.combine(value, time()) + # Initialize date dictionary + config[key_name] = DateDict(config[key_name]) + # Ensure each date value is of type datetime def run_validation(self, value: DateDict): for key in value: diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index 2d156390f6f..b8c53c821b3 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -326,7 +326,7 @@ def _is_excluded(self, post: Post): # and must be explicitly enabled by the author. if not isinstance(post.config.draft, bool): if self.config.draft_if_future_date: - return post.config.date > datetime.now() + return post.config.date.created > datetime.now() # Post might be a draft return bool(post.config.draft) @@ -364,7 +364,7 @@ def _resolve(self, files: Files, config: MkDocsConfig, nav: Navigation): ]) # Update entrypoint in navigation - for items in [view.parent.children, nav.pages]: + for items in [self._resolve_siblings(view.parent, nav), nav.pages]: items[items.index(page)] = view # Return view @@ -484,6 +484,13 @@ def _resolve_views(self, view: View): assert isinstance(page, View) yield page + # Resolve siblings of a navigation item + def _resolve_siblings(self, item: StructureItem, nav: Navigation): + if isinstance(item, Section): + return item.children + else: + return nav.items + # ------------------------------------------------------------------------- # Attach a list of pages to each other and to the given parent item without @@ -505,7 +512,7 @@ def _attach_to(self, parent: Section, section: Section, nav: Navigation): # the top-level navigation, if no parent section was given. Note, that # it's currently not possible to chose the position of a section, but # we might add support for this in the future. - items = parent.children if parent else nav.items + items = self._resolve_siblings(parent, nav) items.append(section) # Find last sibling that is a page, skipping sections, as we need to diff --git a/src/plugins/blog/structure/__init__.py b/src/plugins/blog/structure/__init__.py index 6003cadd372..725c9bc6637 100644 --- a/src/plugins/blog/structure/__init__.py +++ b/src/plugins/blog/structure/__init__.py @@ -245,7 +245,7 @@ def _patch(config: MkDocsConfig): config.validation = copy(config.validation) config.validation.links = copy(config.validation.links) config.mdx_configs = copy(config.mdx_configs) - config.mdx_configs["toc"] = copy(config.mdx_configs["toc"]) + config.mdx_configs["toc"] = copy(config.mdx_configs.get("toc", {})) # In order to render excerpts for posts, we need to make sure that the # table of contents extension is appropriately configured diff --git a/src/plugins/blog/structure/options.py b/src/plugins/blog/structure/options.py index 0b36d8cfba4..d37779185bd 100644 --- a/src/plugins/blog/structure/options.py +++ b/src/plugins/blog/structure/options.py @@ -60,12 +60,14 @@ def pre_validation(self, config: Config, key_name: str): if not isinstance(config[key_name], dict): config[key_name] = { "created": config[key_name] } - # Initialize date dictionary and convert all date values to datetime - config[key_name] = DateDict(config[key_name]) + # Convert all date values to datetime for key, value in config[key_name].items(): if isinstance(value, date): config[key_name][key] = datetime.combine(value, time()) + # Initialize date dictionary + config[key_name] = DateDict(config[key_name]) + # Ensure each date value is of type datetime def run_validation(self, value: DateDict): for key in value: From 83f7cfcae2593223720dbb85e79add01d9b66b7b Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 21 Aug 2023 23:07:14 +0200 Subject: [PATCH 06/40] Prepare 9.2.1 release --- CHANGELOG | 8 +++++++- docs/changelog/index.md | 8 +++++++- docs/insiders/changelog.md | 2 +- material/base.html | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b0d1359857b..20edf0a1484 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,12 @@ +mkdocs-material-9.2.1 (2023-08-21) + + * Fixed #5879: Blog plugin failing when building a standalone blog + * Fixed error in blog plugin when using draft tagging on future date + * Fixed error in blog plugin when toc extension is not enabled + mkdocs-material-9.2.0+insiders-4.39.1 (2023-08-21) -- Fixed git diff in tags plugin after merging back 9.2.0 changes + * Fixed git diff in tags plugin after merging back 9.2.0 changes mkdocs-material-9.2.0 (2023-08-21) diff --git a/docs/changelog/index.md b/docs/changelog/index.md index 86f835fd292..d83795a0d32 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -2,7 +2,13 @@ ## Material for MkDocs -### 9.2.0 July 6, 2023 { id="9.2.0" } +### 9.2.1 August 21, 2023 { id="9.2.1" } + +- Fixed #5879: Blog plugin failing when building a standalone blog +- Fixed error in blog plugin when using draft tagging on future date +- Fixed error in blog plugin when toc extension is not enabled + +### 9.2.0 August 21, 2023 { id="9.2.0" } __Additions and improvements__ diff --git a/docs/insiders/changelog.md b/docs/insiders/changelog.md index 090bda17557..2162e6577b3 100644 --- a/docs/insiders/changelog.md +++ b/docs/insiders/changelog.md @@ -2,7 +2,7 @@ ## Material for MkDocs Insiders -### 4.39.1 August 32, 2023 { id="4.39.1" } +### 4.39.1 August 21, 2023 { id="4.39.1" } - Fixed git diff in tags plugin after merging back 9.2.0 changes diff --git a/material/base.html b/material/base.html index fdb68f9653d..ef37134fef0 100644 --- a/material/base.html +++ b/material/base.html @@ -32,7 +32,7 @@ {% endif %} - + {% endblock %} {% block htmltitle %} {% if page.meta and page.meta.title %} diff --git a/package-lock.json b/package-lock.json index 663885c5dbc..56933699c8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mkdocs-material", - "version": "9.2.0", + "version": "9.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mkdocs-material", - "version": "9.2.0", + "version": "9.2.1", "license": "MIT", "dependencies": { "clipboard": "^2.0.11", diff --git a/package.json b/package.json index 45864574c5f..1ff52f45d20 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mkdocs-material", - "version": "9.2.0", + "version": "9.2.1", "description": "Documentation that simply works", "keywords": [ "mkdocs", From 27890b9be51b318ee8ed5a6f2ab5af86da0e5c12 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 21 Aug 2023 23:12:08 +0200 Subject: [PATCH 07/40] Updated changelog --- docs/changelog/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog/index.md b/docs/changelog/index.md index d83795a0d32..77722633464 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -57,7 +57,7 @@ __Fixes__ - Fixed #5806: Version selector not hoverable on some Android devices - Fixed #5826: Blog post drafts with tags show up in tags index -### 9.1.21 July 27, 2023 { id="9.1.20" } +### 9.1.21 July 27, 2023 { id="9.1.21" } - Fixed MkDocs 1.4 compat issue in social plugin (9.1.20 regression) From 817caf0b616adb51aac217dfee715b822ac0d388 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 21 Aug 2023 23:43:31 +0200 Subject: [PATCH 08/40] Refactored blog plugin --- material/plugins/blog/plugin.py | 8 ++++---- src/plugins/blog/plugin.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index b8c53c821b3..3e9017da699 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -364,7 +364,7 @@ def _resolve(self, files: Files, config: MkDocsConfig, nav: Navigation): ]) # Update entrypoint in navigation - for items in [self._resolve_siblings(view.parent, nav), nav.pages]: + for items in [self._resolve_items(view.parent, nav), nav.pages]: items[items.index(page)] = view # Return view @@ -484,8 +484,8 @@ def _resolve_views(self, view: View): assert isinstance(page, View) yield page - # Resolve siblings of a navigation item - def _resolve_siblings(self, item: StructureItem, nav: Navigation): + # Resolve children of a navigation item + def _resolve_items(self, item: StructureItem, nav: Navigation): if isinstance(item, Section): return item.children else: @@ -512,7 +512,7 @@ def _attach_to(self, parent: Section, section: Section, nav: Navigation): # the top-level navigation, if no parent section was given. Note, that # it's currently not possible to chose the position of a section, but # we might add support for this in the future. - items = self._resolve_siblings(parent, nav) + items = self._resolve_items(parent, nav) items.append(section) # Find last sibling that is a page, skipping sections, as we need to diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index b8c53c821b3..3e9017da699 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -364,7 +364,7 @@ def _resolve(self, files: Files, config: MkDocsConfig, nav: Navigation): ]) # Update entrypoint in navigation - for items in [self._resolve_siblings(view.parent, nav), nav.pages]: + for items in [self._resolve_items(view.parent, nav), nav.pages]: items[items.index(page)] = view # Return view @@ -484,8 +484,8 @@ def _resolve_views(self, view: View): assert isinstance(page, View) yield page - # Resolve siblings of a navigation item - def _resolve_siblings(self, item: StructureItem, nav: Navigation): + # Resolve children of a navigation item + def _resolve_items(self, item: StructureItem, nav: Navigation): if isinstance(item, Section): return item.children else: @@ -512,7 +512,7 @@ def _attach_to(self, parent: Section, section: Section, nav: Navigation): # the top-level navigation, if no parent section was given. Note, that # it's currently not possible to chose the position of a section, but # we might add support for this in the future. - items = self._resolve_siblings(parent, nav) + items = self._resolve_items(parent, nav) items.append(section) # Find last sibling that is a page, skipping sections, as we need to From a0cb4a7230bc34214368bdd0720d9b69a6b3cb10 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 21 Aug 2023 23:50:49 +0200 Subject: [PATCH 09/40] Documentation --- material/plugins/blog/structure/__init__.py | 2 +- src/plugins/blog/structure/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/material/plugins/blog/structure/__init__.py b/material/plugins/blog/structure/__init__.py index 725c9bc6637..22348cf6c03 100644 --- a/material/plugins/blog/structure/__init__.py +++ b/material/plugins/blog/structure/__init__.py @@ -106,7 +106,7 @@ def __init__(self, file: File, config: MkDocsConfig): f"{e}" ) - # Excerpts are subsets of posts that are used in views like archive and + # Excerpts are subsets of posts that are used in pages like archive and # category views. They are not rendered as standalone pages, but are # included in the context of the parent post. Each post has a dedicated # excerpt instance which is reused when rendering views. diff --git a/src/plugins/blog/structure/__init__.py b/src/plugins/blog/structure/__init__.py index 725c9bc6637..22348cf6c03 100644 --- a/src/plugins/blog/structure/__init__.py +++ b/src/plugins/blog/structure/__init__.py @@ -106,7 +106,7 @@ def __init__(self, file: File, config: MkDocsConfig): f"{e}" ) - # Excerpts are subsets of posts that are used in views like archive and + # Excerpts are subsets of posts that are used in pages like archive and # category views. They are not rendered as standalone pages, but are # included in the context of the parent post. Each post has a dedicated # excerpt instance which is reused when rendering views. From 62d4a16067a784002a07af30d2e2f2046d9f3bd4 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 22 Aug 2023 07:56:33 +0200 Subject: [PATCH 10/40] Fixed edge cases for standalone case when using blog plugin --- material/plugins/blog/plugin.py | 51 ++++++++++++++++----------------- src/plugins/blog/plugin.py | 51 ++++++++++++++++----------------- 2 files changed, 50 insertions(+), 52 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index 3e9017da699..8ff167de19d 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -161,7 +161,7 @@ def on_nav(self, nav, *, config, files): # Attach and link views for archive title = self._translate(self.config.archive_name, config) - self._attach_to(self.blog.parent, Section(title, views), nav) + self._attach_to(self.blog, Section(title, views), nav) # Generate and attach views for categories if self.config.categories: @@ -170,7 +170,7 @@ def on_nav(self, nav, *, config, files): # Attach and link views for categories title = self._translate(self.config.categories_name, config) - self._attach_to(self.blog.parent, Section(title, views), nav) + self._attach_to(self.blog, Section(title, views), nav) # Paginate generated views, if enabled if self.config.pagination: @@ -280,20 +280,19 @@ def on_page_context(self, context, *, page, config, nav): main = page.parent # If this page is a view, and the parent page is a view as well, we got - # a paginated view and need to update the parent view in the navigation. - # Paginated views are always rendered last, which is why we can safely - # mutate the navigation at this point + # a paginated view and need to replace the parent with the current view. + # Paginated views are always rendered at the end of the build, which is + # why we can safely mutate the navigation at this point if isinstance(main, View): - assert isinstance(main.parent, Section) - - # Replace view in navigation and rewire view - the current view in - # the navigation becomes the main view, thus the entire chain moves - # one level up. It's essential that the rendering order is linear, - # or else we might end up with a broken navigation. - at = main.parent.children.index(main) - main.parent.children[at] = page page.parent = main.parent + # Replace view in navigation and rewire it - the current view in the + # navigation becomes the main view, thus the entire chain moves one + # level up. It's essential that the rendering order is linear, or + # else we might end up with a broken navigation. + items = self._resolve_siblings(main, nav) + items[items.index(main)] = page + # Render excerpts and perpare pagination posts, pagination = self._render(page) @@ -364,7 +363,7 @@ def _resolve(self, files: Files, config: MkDocsConfig, nav: Navigation): ]) # Update entrypoint in navigation - for items in [self._resolve_items(view.parent, nav), nav.pages]: + for items in [self._resolve_siblings(view, nav), nav.pages]: items[items.index(page)] = view # Return view @@ -484,10 +483,10 @@ def _resolve_views(self, view: View): assert isinstance(page, View) yield page - # Resolve children of a navigation item - def _resolve_items(self, item: StructureItem, nav: Navigation): - if isinstance(item, Section): - return item.children + # Resolve siblings of a navigation item + def _resolve_siblings(self, item: StructureItem, nav: Navigation): + if isinstance(item.parent, Section): + return item.parent.children else: return nav.items @@ -505,14 +504,14 @@ def _attach(self, parent: StructureItem, pages: list[Page]): # Attach a section to the given parent section, make sure it's pages are # part of the navigation, and ensure all pages are linked correctly - def _attach_to(self, parent: Section, section: Section, nav: Navigation): - section.parent = parent - - # Determine the parent section to attach the section to, which might be - # the top-level navigation, if no parent section was given. Note, that - # it's currently not possible to chose the position of a section, but - # we might add support for this in the future. - items = self._resolve_items(parent, nav) + def _attach_to(self, view: View, section: Section, nav: Navigation): + section.parent = view.parent + + # Resolve siblings, which are the children of the parent section, or + # the top-level list of navigation items if the view is at the root of + # the project, and append the given section to it. It's currently not + # possible to chose the position of a section. + items = self._resolve_siblings(view, nav) items.append(section) # Find last sibling that is a page, skipping sections, as we need to diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index 3e9017da699..8ff167de19d 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -161,7 +161,7 @@ def on_nav(self, nav, *, config, files): # Attach and link views for archive title = self._translate(self.config.archive_name, config) - self._attach_to(self.blog.parent, Section(title, views), nav) + self._attach_to(self.blog, Section(title, views), nav) # Generate and attach views for categories if self.config.categories: @@ -170,7 +170,7 @@ def on_nav(self, nav, *, config, files): # Attach and link views for categories title = self._translate(self.config.categories_name, config) - self._attach_to(self.blog.parent, Section(title, views), nav) + self._attach_to(self.blog, Section(title, views), nav) # Paginate generated views, if enabled if self.config.pagination: @@ -280,20 +280,19 @@ def on_page_context(self, context, *, page, config, nav): main = page.parent # If this page is a view, and the parent page is a view as well, we got - # a paginated view and need to update the parent view in the navigation. - # Paginated views are always rendered last, which is why we can safely - # mutate the navigation at this point + # a paginated view and need to replace the parent with the current view. + # Paginated views are always rendered at the end of the build, which is + # why we can safely mutate the navigation at this point if isinstance(main, View): - assert isinstance(main.parent, Section) - - # Replace view in navigation and rewire view - the current view in - # the navigation becomes the main view, thus the entire chain moves - # one level up. It's essential that the rendering order is linear, - # or else we might end up with a broken navigation. - at = main.parent.children.index(main) - main.parent.children[at] = page page.parent = main.parent + # Replace view in navigation and rewire it - the current view in the + # navigation becomes the main view, thus the entire chain moves one + # level up. It's essential that the rendering order is linear, or + # else we might end up with a broken navigation. + items = self._resolve_siblings(main, nav) + items[items.index(main)] = page + # Render excerpts and perpare pagination posts, pagination = self._render(page) @@ -364,7 +363,7 @@ def _resolve(self, files: Files, config: MkDocsConfig, nav: Navigation): ]) # Update entrypoint in navigation - for items in [self._resolve_items(view.parent, nav), nav.pages]: + for items in [self._resolve_siblings(view, nav), nav.pages]: items[items.index(page)] = view # Return view @@ -484,10 +483,10 @@ def _resolve_views(self, view: View): assert isinstance(page, View) yield page - # Resolve children of a navigation item - def _resolve_items(self, item: StructureItem, nav: Navigation): - if isinstance(item, Section): - return item.children + # Resolve siblings of a navigation item + def _resolve_siblings(self, item: StructureItem, nav: Navigation): + if isinstance(item.parent, Section): + return item.parent.children else: return nav.items @@ -505,14 +504,14 @@ def _attach(self, parent: StructureItem, pages: list[Page]): # Attach a section to the given parent section, make sure it's pages are # part of the navigation, and ensure all pages are linked correctly - def _attach_to(self, parent: Section, section: Section, nav: Navigation): - section.parent = parent - - # Determine the parent section to attach the section to, which might be - # the top-level navigation, if no parent section was given. Note, that - # it's currently not possible to chose the position of a section, but - # we might add support for this in the future. - items = self._resolve_items(parent, nav) + def _attach_to(self, view: View, section: Section, nav: Navigation): + section.parent = view.parent + + # Resolve siblings, which are the children of the parent section, or + # the top-level list of navigation items if the view is at the root of + # the project, and append the given section to it. It's currently not + # possible to chose the position of a section. + items = self._resolve_siblings(view, nav) items.append(section) # Find last sibling that is a page, skipping sections, as we need to From 9f3efb8a5992d8349270b238e4a3c2eac38677d9 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 22 Aug 2023 07:59:36 +0200 Subject: [PATCH 11/40] Documentation --- material/plugins/blog/plugin.py | 2 +- src/plugins/blog/plugin.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index 8ff167de19d..cb9db5c6630 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -502,7 +502,7 @@ def _attach(self, parent: StructureItem, pages: list[Page]): page.previous_page = tail page.next_page = head - # Attach a section to the given parent section, make sure it's pages are + # Attach a section as a sibling to the given view, make sure it's pages are # part of the navigation, and ensure all pages are linked correctly def _attach_to(self, view: View, section: Section, nav: Navigation): section.parent = view.parent diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index 8ff167de19d..cb9db5c6630 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -502,7 +502,7 @@ def _attach(self, parent: StructureItem, pages: list[Page]): page.previous_page = tail page.next_page = head - # Attach a section to the given parent section, make sure it's pages are + # Attach a section as a sibling to the given view, make sure it's pages are # part of the navigation, and ensure all pages are linked correctly def _attach_to(self, view: View, section: Section, nav: Navigation): section.parent = view.parent From 0704046536d60a1dddae65b1dcf1075f8058e968 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 22 Aug 2023 11:22:56 +0200 Subject: [PATCH 12/40] Fixed compatibility with Python < 3.10 --- material/plugins/blog/structure/__init__.py | 5 +++-- material/plugins/blog/templates/__init__.py | 2 +- src/plugins/blog/structure/__init__.py | 5 +++-- src/plugins/blog/templates/__init__.py | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/material/plugins/blog/structure/__init__.py b/material/plugins/blog/structure/__init__.py index 22348cf6c03..b503a73ae50 100644 --- a/material/plugins/blog/structure/__init__.py +++ b/material/plugins/blog/structure/__init__.py @@ -18,6 +18,8 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +from __future__ import annotations + import logging import os import yaml @@ -33,7 +35,6 @@ from mkdocs.structure.toc import get_toc from mkdocs.utils.meta import YAML_RE from re import Match -from typing import Union from yaml import SafeLoader from .config import PostConfig @@ -205,7 +206,7 @@ class View(Page): # Initialize view def __init__(self, title: str | None, file: File, config: MkDocsConfig): super().__init__(title, file, config) - self.parent: Union[View, Section] + self.parent: View | Section # Initialize posts and views self.posts: list[Post] = [] diff --git a/material/plugins/blog/templates/__init__.py b/material/plugins/blog/templates/__init__.py index ea7edee7f51..9f7d794bb48 100644 --- a/material/plugins/blog/templates/__init__.py +++ b/material/plugins/blog/templates/__init__.py @@ -29,7 +29,7 @@ # Filter for normalizing URLs with support for paginated views @pass_context -def url_filter(context: Context, url: str | None): +def url_filter(context: Context, url: str): page = context["page"] # If the current page is a view, check if the URL links to the page diff --git a/src/plugins/blog/structure/__init__.py b/src/plugins/blog/structure/__init__.py index 22348cf6c03..b503a73ae50 100644 --- a/src/plugins/blog/structure/__init__.py +++ b/src/plugins/blog/structure/__init__.py @@ -18,6 +18,8 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +from __future__ import annotations + import logging import os import yaml @@ -33,7 +35,6 @@ from mkdocs.structure.toc import get_toc from mkdocs.utils.meta import YAML_RE from re import Match -from typing import Union from yaml import SafeLoader from .config import PostConfig @@ -205,7 +206,7 @@ class View(Page): # Initialize view def __init__(self, title: str | None, file: File, config: MkDocsConfig): super().__init__(title, file, config) - self.parent: Union[View, Section] + self.parent: View | Section # Initialize posts and views self.posts: list[Post] = [] diff --git a/src/plugins/blog/templates/__init__.py b/src/plugins/blog/templates/__init__.py index ea7edee7f51..9f7d794bb48 100644 --- a/src/plugins/blog/templates/__init__.py +++ b/src/plugins/blog/templates/__init__.py @@ -29,7 +29,7 @@ # Filter for normalizing URLs with support for paginated views @pass_context -def url_filter(context: Context, url: str | None): +def url_filter(context: Context, url: str): page = context["page"] # If the current page is a view, check if the URL links to the page From fe47f40a06b67d93ab15d18c4c9cf89a2ee27482 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 22 Aug 2023 14:44:34 +0200 Subject: [PATCH 13/40] Prepare 9.2.2 release --- CHANGELOG | 5 +++++ docs/changelog/index.md | 5 +++++ material/base.html | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 20edf0a1484..357bae40409 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +mkdocs-material-9.2.2 (2023-08-22) + + * Fixed #5880: Blog plugin failing when building a standalone blog + * Fixed #5881: Blog plugin not compatible with Python < 3.10 + mkdocs-material-9.2.1 (2023-08-21) * Fixed #5879: Blog plugin failing when building a standalone blog diff --git a/docs/changelog/index.md b/docs/changelog/index.md index 77722633464..946a9c43d5c 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -2,6 +2,11 @@ ## Material for MkDocs +### 9.2.2 August 22, 2023 { id="9.2.2" } + +- Fixed #5880: Blog plugin failing when building a standalone blog +- Fixed #5881: Blog plugin not compatible with Python < 3.10 + ### 9.2.1 August 21, 2023 { id="9.2.1" } - Fixed #5879: Blog plugin failing when building a standalone blog diff --git a/material/base.html b/material/base.html index ef37134fef0..ec633f0d775 100644 --- a/material/base.html +++ b/material/base.html @@ -32,7 +32,7 @@ {% endif %} - + {% endblock %} {% block htmltitle %} {% if page.meta and page.meta.title %} diff --git a/package-lock.json b/package-lock.json index 56933699c8d..72ea94658cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mkdocs-material", - "version": "9.2.1", + "version": "9.2.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mkdocs-material", - "version": "9.2.1", + "version": "9.2.2", "license": "MIT", "dependencies": { "clipboard": "^2.0.11", diff --git a/package.json b/package.json index 1ff52f45d20..8541ca3e954 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mkdocs-material", - "version": "9.2.1", + "version": "9.2.2", "description": "Documentation that simply works", "keywords": [ "mkdocs", From 6ee9df6e1a8befa7fad00d42191bf313c2f6b5d2 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 22 Aug 2023 15:20:10 +0200 Subject: [PATCH 14/40] Fixed rendering in blog plugin with markdown.extensions.toc --- material/plugins/blog/structure/__init__.py | 25 ++++++++++++--------- src/plugins/blog/structure/__init__.py | 25 ++++++++++++--------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/material/plugins/blog/structure/__init__.py b/material/plugins/blog/structure/__init__.py index b503a73ae50..0a6e3650014 100644 --- a/material/plugins/blog/structure/__init__.py +++ b/material/plugins/blog/structure/__init__.py @@ -242,21 +242,26 @@ class Category(View): def _patch(config: MkDocsConfig): config = copy(config) - # Copy configuration that needs to be patched - config.validation = copy(config.validation) - config.validation.links = copy(config.validation.links) - config.mdx_configs = copy(config.mdx_configs) - config.mdx_configs["toc"] = copy(config.mdx_configs.get("toc", {})) + # Copy parts of configuration that needs to be patched + config.validation = copy(config.validation) + config.validation.links = copy(config.validation.links) + config.markdown_extensions = copy(config.markdown_extensions) + config.mdx_configs = copy(config.mdx_configs) + + # Make sure that the author did not add another instance of the table of + # contents extension to the configuration, as this leads to weird behavior + if "markdown.extensions.toc" in config.markdown_extensions: + config.markdown_extensions.remove("markdown.extensions.toc") # In order to render excerpts for posts, we need to make sure that the # table of contents extension is appropriately configured config.mdx_configs["toc"] = { - **config.mdx_configs["toc"], + **config.mdx_configs.get("toc", {}), **{ - "anchorlink": True, # Render headline as clickable - "baselevel": 2, # Render h1 as h2 and so forth - "permalink": False, # Remove permalinks - "toc_depth": 2 # Remove everything below h2 + "anchorlink": True, # Render headline as clickable + "baselevel": 2, # Render h1 as h2 and so forth + "permalink": False, # Remove permalinks + "toc_depth": 2 # Remove everything below h2 } } diff --git a/src/plugins/blog/structure/__init__.py b/src/plugins/blog/structure/__init__.py index b503a73ae50..0a6e3650014 100644 --- a/src/plugins/blog/structure/__init__.py +++ b/src/plugins/blog/structure/__init__.py @@ -242,21 +242,26 @@ class Category(View): def _patch(config: MkDocsConfig): config = copy(config) - # Copy configuration that needs to be patched - config.validation = copy(config.validation) - config.validation.links = copy(config.validation.links) - config.mdx_configs = copy(config.mdx_configs) - config.mdx_configs["toc"] = copy(config.mdx_configs.get("toc", {})) + # Copy parts of configuration that needs to be patched + config.validation = copy(config.validation) + config.validation.links = copy(config.validation.links) + config.markdown_extensions = copy(config.markdown_extensions) + config.mdx_configs = copy(config.mdx_configs) + + # Make sure that the author did not add another instance of the table of + # contents extension to the configuration, as this leads to weird behavior + if "markdown.extensions.toc" in config.markdown_extensions: + config.markdown_extensions.remove("markdown.extensions.toc") # In order to render excerpts for posts, we need to make sure that the # table of contents extension is appropriately configured config.mdx_configs["toc"] = { - **config.mdx_configs["toc"], + **config.mdx_configs.get("toc", {}), **{ - "anchorlink": True, # Render headline as clickable - "baselevel": 2, # Render h1 as h2 and so forth - "permalink": False, # Remove permalinks - "toc_depth": 2 # Remove everything below h2 + "anchorlink": True, # Render headline as clickable + "baselevel": 2, # Render h1 as h2 and so forth + "permalink": False, # Remove permalinks + "toc_depth": 2 # Remove everything below h2 } } From 382101d8a37c72b44211232885c0fd5367c574af Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 22 Aug 2023 15:41:30 +0200 Subject: [PATCH 15/40] Documentation --- material/plugins/blog/plugin.py | 2 +- src/plugins/blog/plugin.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index cb9db5c6630..bfcd224d5cb 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -572,7 +572,7 @@ def _generate_categories(self, config: MkDocsConfig, files: Files): file = self._path_to_file(path, config) files.append(file) - # Create and yield archive view + # Create and yield category view self._save_to_file(file.abs_src_path, f"# {name}") yield Category(name, file, config) diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index cb9db5c6630..bfcd224d5cb 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -572,7 +572,7 @@ def _generate_categories(self, config: MkDocsConfig, files: Files): file = self._path_to_file(path, config) files.append(file) - # Create and yield archive view + # Create and yield category view self._save_to_file(file.abs_src_path, f"# {name}") yield Category(name, file, config) From 2d716453e00332ccb33ae135526641c917f653bf Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 22 Aug 2023 16:47:54 +0200 Subject: [PATCH 16/40] Fixed generation of entrypoint in blog plugin --- material/plugins/blog/plugin.py | 44 +++++++++++++++++++-------------- src/plugins/blog/plugin.py | 44 +++++++++++++++++++-------------- 2 files changed, 52 insertions(+), 36 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index bfcd224d5cb..1d9990dc815 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -125,6 +125,9 @@ def on_files(self, files, *, config): file.abs_dest_path = os.path.join(site, file.dest_path) file.url = file.url.replace(path, root) + # Generate entrypoint, if it does not exist yet + self._generate(files, config) + # Resolve and load posts and generate indexes (run later) - we resolve all # posts after the navigation is constructed in order to allow other plugins # to alter the navigation (e.g. awesome-pages) before we start to add pages @@ -332,24 +335,12 @@ def _is_excluded(self, post: Post): # ------------------------------------------------------------------------- - # Resolve entrypoint - the entrypoint of the blog hosts all posts, sorted - # by descending date. The entrypoint must always be present, even if there - # are no posts, and is automatically created if it does not exist yet. Note - # that posts might be paginated, but this is configurable by the author. + # Resolve entrypoint - the entrypoint of the blog must have been created + # if it did not exist before, and hosts all posts sorted by descending date def _resolve(self, files: Files, config: MkDocsConfig, nav: Navigation): path = os.path.join(self.config.blog_dir, "index.md") path = os.path.normpath(path) - # Create entrypoint, if it does not exist - docs = os.path.relpath(config.docs_dir) - file = os.path.join(docs, path) - if not os.path.isfile(file): - self._save_to_file(file, "# Blog\n\n") - - # Append entrypoint to files - note that the entrypoint is added to - # the docs directory, so we need to set the temporary flag to false - files.append(self._path_to_file(path, config, temp = False)) - # Obtain entrypoint page file = files.get_file_from_path(path) page = file.page @@ -525,6 +516,23 @@ def _attach_to(self, view: View, section: Section, nav: Navigation): # ------------------------------------------------------------------------- + # Generate entrypoint - the entrypoint must always be present, and thus is + # created before the navigation is constructed if it does not exist yet + def _generate(self, files: Files, config: MkDocsConfig): + path = os.path.join(self.config.blog_dir, "index.md") + path = os.path.normpath(path) + + # Create entrypoint, if it does not exist - note that the entrypoint is + # added to the docs directory, not to the temporary directory + docs = os.path.relpath(config.docs_dir) + file = os.path.join(docs, path) + if not os.path.isfile(file): + file = self._path_to_file(path, config, temp = False) + self._save_to_file(file.abs_src_path, "# Blog\n\n") + + # Append entrypoint to files + files.append(file) + # Generate views for archive - analyze posts and generate the necessary # views, taking the date format provided by the author into account def _generate_archive(self, config: MkDocsConfig, files: Files): @@ -539,11 +547,11 @@ def _generate_archive(self, config: MkDocsConfig, files: Files): file = files.get_file_from_path(path) if not file: file = self._path_to_file(path, config) - files.append(file) + self._save_to_file(file.abs_src_path, f"# {name}") # Create and yield archive view - self._save_to_file(file.abs_src_path, f"# {name}") yield Archive(name, file, config) + files.append(file) # Assign post to archive assert isinstance(file.page, Archive) @@ -570,11 +578,11 @@ def _generate_categories(self, config: MkDocsConfig, files: Files): file = files.get_file_from_path(path) if not file: file = self._path_to_file(path, config) - files.append(file) + self._save_to_file(file.abs_src_path, f"# {name}") # Create and yield category view - self._save_to_file(file.abs_src_path, f"# {name}") yield Category(name, file, config) + files.append(file) # Assign post to category and vice versa assert isinstance(file.page, Category) diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index bfcd224d5cb..1d9990dc815 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -125,6 +125,9 @@ def on_files(self, files, *, config): file.abs_dest_path = os.path.join(site, file.dest_path) file.url = file.url.replace(path, root) + # Generate entrypoint, if it does not exist yet + self._generate(files, config) + # Resolve and load posts and generate indexes (run later) - we resolve all # posts after the navigation is constructed in order to allow other plugins # to alter the navigation (e.g. awesome-pages) before we start to add pages @@ -332,24 +335,12 @@ def _is_excluded(self, post: Post): # ------------------------------------------------------------------------- - # Resolve entrypoint - the entrypoint of the blog hosts all posts, sorted - # by descending date. The entrypoint must always be present, even if there - # are no posts, and is automatically created if it does not exist yet. Note - # that posts might be paginated, but this is configurable by the author. + # Resolve entrypoint - the entrypoint of the blog must have been created + # if it did not exist before, and hosts all posts sorted by descending date def _resolve(self, files: Files, config: MkDocsConfig, nav: Navigation): path = os.path.join(self.config.blog_dir, "index.md") path = os.path.normpath(path) - # Create entrypoint, if it does not exist - docs = os.path.relpath(config.docs_dir) - file = os.path.join(docs, path) - if not os.path.isfile(file): - self._save_to_file(file, "# Blog\n\n") - - # Append entrypoint to files - note that the entrypoint is added to - # the docs directory, so we need to set the temporary flag to false - files.append(self._path_to_file(path, config, temp = False)) - # Obtain entrypoint page file = files.get_file_from_path(path) page = file.page @@ -525,6 +516,23 @@ def _attach_to(self, view: View, section: Section, nav: Navigation): # ------------------------------------------------------------------------- + # Generate entrypoint - the entrypoint must always be present, and thus is + # created before the navigation is constructed if it does not exist yet + def _generate(self, files: Files, config: MkDocsConfig): + path = os.path.join(self.config.blog_dir, "index.md") + path = os.path.normpath(path) + + # Create entrypoint, if it does not exist - note that the entrypoint is + # added to the docs directory, not to the temporary directory + docs = os.path.relpath(config.docs_dir) + file = os.path.join(docs, path) + if not os.path.isfile(file): + file = self._path_to_file(path, config, temp = False) + self._save_to_file(file.abs_src_path, "# Blog\n\n") + + # Append entrypoint to files + files.append(file) + # Generate views for archive - analyze posts and generate the necessary # views, taking the date format provided by the author into account def _generate_archive(self, config: MkDocsConfig, files: Files): @@ -539,11 +547,11 @@ def _generate_archive(self, config: MkDocsConfig, files: Files): file = files.get_file_from_path(path) if not file: file = self._path_to_file(path, config) - files.append(file) + self._save_to_file(file.abs_src_path, f"# {name}") # Create and yield archive view - self._save_to_file(file.abs_src_path, f"# {name}") yield Archive(name, file, config) + files.append(file) # Assign post to archive assert isinstance(file.page, Archive) @@ -570,11 +578,11 @@ def _generate_categories(self, config: MkDocsConfig, files: Files): file = files.get_file_from_path(path) if not file: file = self._path_to_file(path, config) - files.append(file) + self._save_to_file(file.abs_src_path, f"# {name}") # Create and yield category view - self._save_to_file(file.abs_src_path, f"# {name}") yield Category(name, file, config) + files.append(file) # Assign post to category and vice versa assert isinstance(file.page, Category) From e64a1e26035aff4ad6816544e06ae567ca813163 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 22 Aug 2023 17:11:18 +0200 Subject: [PATCH 17/40] Prepare 9.2.3 release --- CHANGELOG | 5 +++++ docs/changelog/index.md | 5 +++++ material/base.html | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 357bae40409..07e19232891 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +mkdocs-material-9.2.3 (2023-08-22) + + * Fixed blog plugin rendering wrongly with markdown.extensions.toc + * Fixed blog plugin entrypoint generation + mkdocs-material-9.2.2 (2023-08-22) * Fixed #5880: Blog plugin failing when building a standalone blog diff --git a/docs/changelog/index.md b/docs/changelog/index.md index 946a9c43d5c..89e40cc0130 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -2,6 +2,11 @@ ## Material for MkDocs +### 9.2.3 August 22, 2023 { id="9.2.3" } + +- Fixed blog plugin rendering wrongly with markdown.extensions.toc +- Fixed blog plugin entrypoint generation + ### 9.2.2 August 22, 2023 { id="9.2.2" } - Fixed #5880: Blog plugin failing when building a standalone blog diff --git a/material/base.html b/material/base.html index ec633f0d775..44a77d010e5 100644 --- a/material/base.html +++ b/material/base.html @@ -32,7 +32,7 @@ {% endif %} - + {% endblock %} {% block htmltitle %} {% if page.meta and page.meta.title %} diff --git a/package-lock.json b/package-lock.json index 72ea94658cd..ec05d3791ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mkdocs-material", - "version": "9.2.2", + "version": "9.2.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mkdocs-material", - "version": "9.2.2", + "version": "9.2.3", "license": "MIT", "dependencies": { "clipboard": "^2.0.11", diff --git a/package.json b/package.json index 8541ca3e954..460a0233d27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mkdocs-material", - "version": "9.2.2", + "version": "9.2.3", "description": "Documentation that simply works", "keywords": [ "mkdocs", From 6feea7e1c28aa6c850949b18f16088dc3e18ff38 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 22 Aug 2023 17:12:33 +0200 Subject: [PATCH 18/40] Updated changelog --- docs/changelog/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog/index.md b/docs/changelog/index.md index 89e40cc0130..7e61f016c37 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -4,7 +4,7 @@ ### 9.2.3 August 22, 2023 { id="9.2.3" } -- Fixed blog plugin rendering wrongly with markdown.extensions.toc +- Fixed blog plugin rendering wrongly with `markdown.extensions.toc` - Fixed blog plugin entrypoint generation ### 9.2.2 August 22, 2023 { id="9.2.2" } From 0986c3a039082d5bd8537facecf25bfa960bf020 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Wed, 23 Aug 2023 10:41:28 +0200 Subject: [PATCH 19/40] Removed lxml dependency - not necessary after blog plugin rewrite --- Dockerfile | 4 ---- requirements.txt | 1 - 2 files changed, 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0c15409b8eb..5595e842a89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,16 +47,12 @@ RUN \ git \ git-fast-import \ jpeg-dev \ - libxml2 \ - libxslt \ openssh \ zlib-dev \ && \ apk add --no-cache --virtual .build \ gcc \ libffi-dev \ - libxml2-dev \ - libxslt-dev \ musl-dev \ && \ pip install --no-cache-dir --upgrade pip \ diff --git a/requirements.txt b/requirements.txt index cc1f3ffa91c..24869df6c97 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,7 +29,6 @@ pymdown-extensions>=9.9.1 # Requirements for plugins babel>=2.10.3 colorama>=0.4 -lxml>=4.6 paginate>=0.5.6 readtime>=2.0 regex>=2022.4.24 From 06e8ccd97980dcfae35d7f017be2f19988a7e98b Mon Sep 17 00:00:00 2001 From: squidfunk Date: Wed, 23 Aug 2023 10:41:44 +0200 Subject: [PATCH 20/40] Formatting --- material/plugins/blog/plugin.py | 6 +++--- src/plugins/blog/plugin.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index 1d9990dc815..f46bd7e2b47 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -126,7 +126,7 @@ def on_files(self, files, *, config): file.url = file.url.replace(path, root) # Generate entrypoint, if it does not exist yet - self._generate(files, config) + self._generate(config, files) # Resolve and load posts and generate indexes (run later) - we resolve all # posts after the navigation is constructed in order to allow other plugins @@ -296,7 +296,7 @@ def on_page_context(self, context, *, page, config, nav): items = self._resolve_siblings(main, nav) items[items.index(main)] = page - # Render excerpts and perpare pagination + # Render excerpts and prepare pagination posts, pagination = self._render(page) # Render pagination links @@ -518,7 +518,7 @@ def _attach_to(self, view: View, section: Section, nav: Navigation): # Generate entrypoint - the entrypoint must always be present, and thus is # created before the navigation is constructed if it does not exist yet - def _generate(self, files: Files, config: MkDocsConfig): + def _generate(self, config: MkDocsConfig, files: Files): path = os.path.join(self.config.blog_dir, "index.md") path = os.path.normpath(path) diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index 1d9990dc815..f46bd7e2b47 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -126,7 +126,7 @@ def on_files(self, files, *, config): file.url = file.url.replace(path, root) # Generate entrypoint, if it does not exist yet - self._generate(files, config) + self._generate(config, files) # Resolve and load posts and generate indexes (run later) - we resolve all # posts after the navigation is constructed in order to allow other plugins @@ -296,7 +296,7 @@ def on_page_context(self, context, *, page, config, nav): items = self._resolve_siblings(main, nav) items[items.index(main)] = page - # Render excerpts and perpare pagination + # Render excerpts and prepare pagination posts, pagination = self._render(page) # Render pagination links @@ -518,7 +518,7 @@ def _attach_to(self, view: View, section: Section, nav: Navigation): # Generate entrypoint - the entrypoint must always be present, and thus is # created before the navigation is constructed if it does not exist yet - def _generate(self, files: Files, config: MkDocsConfig): + def _generate(self, config: MkDocsConfig, files: Files): path = os.path.join(self.config.blog_dir, "index.md") path = os.path.normpath(path) From d9456543ca07ebdd06affca78e15c371b0ca33bb Mon Sep 17 00:00:00 2001 From: squidfunk Date: Wed, 23 Aug 2023 11:29:22 +0200 Subject: [PATCH 21/40] Updated Afrikaans translations Co-authored-by: spac3 <81820+spac3@users.noreply.github.com> --- CHANGELOG | 5 +++++ material/partials/languages/af.html | 34 ++++++++++++++++++++++++++++- src/partials/languages/af.html | 34 ++++++++++++++++++++++++++++- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 07e19232891..17d6770282c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +mkdocs-material-9.x.x (unreleased) + + * Updated Afrikaans translations + * Removed lxml dependency - not necessary after blog plugin rewrite + mkdocs-material-9.2.3 (2023-08-22) * Fixed blog plugin rendering wrongly with markdown.extensions.toc diff --git a/material/partials/languages/af.html b/material/partials/languages/af.html index 358623e877c..bc4a0232217 100644 --- a/material/partials/languages/af.html +++ b/material/partials/languages/af.html @@ -5,20 +5,52 @@ "language": "af", "action.edit": "Wysig hierdie bladsy", "action.skip": "Slaan oor na inhoud", + "action.view": "Bekyk bron van hierdie bladsy", + "announce.dismiss": "Moenie dit weer wys nie", + "blog.archive": "Argief", + "blog.categories": "Kategorieë", + "blog.categories.in": "binne", + "blog.continue": "Lees verder", + "blog.draft": "Konsep", + "blog.index": "Terug na indeks", + "blog.meta": "Metadata", + "blog.references": "Verwante skakels", "clipboard.copy": "Kopieer na knipbord", "clipboard.copied": "gekopieer na knipbord", + "consent.accept": "Aanvaar", + "consent.manage": "Bestuur instellings", + "consent.reject": "Verwerp", + "footer": "Voetskrif", "footer.next": "Volgende", "footer.previous": "Vorige", + "header": "Kopskrif", "meta.comments": "Kommentaar", "meta.source": "Bron", + "nav": "Navigasie", + "readtime.one": "1 minuut se lees", + "readtime.other": "# minuut se lees", + "rss.created": "RSS-voer geskep", + "rss.updated": "RSS-voer van opgedateerde inhoud", + "search": "Soek", "search.config.lang": "nl", "search.placeholder": "Soek", + "search.share": "Deel", + "search.reset": "Terugstel", + "search.result.initializer": "Inisialisering van soektog", "search.result.placeholder": "Tik om te begin soek", "search.result.none": "Geen ooreenstemmende dokumente", "search.result.one": "1 ooreenstemmende dokument", "search.result.other": "# ooreenstemmende dokumente", + "search.result.more.one": "1 meer op hierdie bladsy", + "search.result.more.other": "# meer op hierdie bladsy", + "search.result.term.missing": "Vermis", + "select.language": "Kies taal", + "select.version": "Kies weergawe", "source": "Slaan oor na inhoud", + "source.file.contributors": "Medewerkers", "source.file.date.created": "Geskep", "source.file.date.updated": "Laaste opdatering", - "toc": "Inhoudsopgawe" + "tabs": "Duimgids", + "toc": "Inhoudsopgawe", + "top": "Terug na bo" }[key] }}{% endmacro %} diff --git a/src/partials/languages/af.html b/src/partials/languages/af.html index 9e201156723..b7f9f8fac5e 100644 --- a/src/partials/languages/af.html +++ b/src/partials/languages/af.html @@ -25,20 +25,52 @@ "language": "af", "action.edit": "Wysig hierdie bladsy", "action.skip": "Slaan oor na inhoud", + "action.view": "Bekyk bron van hierdie bladsy", + "announce.dismiss": "Moenie dit weer wys nie", + "blog.archive": "Argief", + "blog.categories": "Kategorieë", + "blog.categories.in": "binne", + "blog.continue": "Lees verder", + "blog.draft": "Konsep", + "blog.index": "Terug na indeks", + "blog.meta": "Metadata", + "blog.references": "Verwante skakels", "clipboard.copy": "Kopieer na knipbord", "clipboard.copied": "gekopieer na knipbord", + "consent.accept": "Aanvaar", + "consent.manage": "Bestuur instellings", + "consent.reject": "Verwerp", + "footer": "Voetskrif", "footer.next": "Volgende", "footer.previous": "Vorige", + "header": "Kopskrif", "meta.comments": "Kommentaar", "meta.source": "Bron", + "nav": "Navigasie", + "readtime.one": "1 minuut se lees", + "readtime.other": "# minuut se lees", + "rss.created": "RSS-voer geskep", + "rss.updated": "RSS-voer van opgedateerde inhoud", + "search": "Soek", "search.config.lang": "nl", "search.placeholder": "Soek", + "search.share": "Deel", + "search.reset": "Terugstel", + "search.result.initializer": "Inisialisering van soektog", "search.result.placeholder": "Tik om te begin soek", "search.result.none": "Geen ooreenstemmende dokumente", "search.result.one": "1 ooreenstemmende dokument", "search.result.other": "# ooreenstemmende dokumente", + "search.result.more.one": "1 meer op hierdie bladsy", + "search.result.more.other": "# meer op hierdie bladsy", + "search.result.term.missing": "Vermis", + "select.language": "Kies taal", + "select.version": "Kies weergawe", "source": "Slaan oor na inhoud", + "source.file.contributors": "Medewerkers", "source.file.date.created": "Geskep", "source.file.date.updated": "Laaste opdatering", - "toc": "Inhoudsopgawe" + "tabs": "Duimgids", + "toc": "Inhoudsopgawe", + "top": "Terug na bo" }[key] }}{% endmacro %} From 4f10a612fa34fac27aeef6c754f85ee3c2388235 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Wed, 23 Aug 2023 11:32:16 +0200 Subject: [PATCH 22/40] Updated Insiders changelog --- CHANGELOG | 4 ++++ docs/insiders/changelog.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 17d6770282c..7d039411ca1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,10 @@ mkdocs-material-9.x.x (unreleased) * Updated Afrikaans translations * Removed lxml dependency - not necessary after blog plugin rewrite +mkdocs-material-9.2.3+insiders-4.39.2 (2023-08-23) + + * Fixed color palette toggle being reversed (9.2.0 regression) + mkdocs-material-9.2.3 (2023-08-22) * Fixed blog plugin rendering wrongly with markdown.extensions.toc diff --git a/docs/insiders/changelog.md b/docs/insiders/changelog.md index 2162e6577b3..399de3c6aa7 100644 --- a/docs/insiders/changelog.md +++ b/docs/insiders/changelog.md @@ -2,6 +2,10 @@ ## Material for MkDocs Insiders +### 4.39.2 August 23, 2023 { id="4.39.2" } + +- Fixed color palette toggle being reversed (9.2.0 regression) + ### 4.39.1 August 21, 2023 { id="4.39.1" } - Fixed git diff in tags plugin after merging back 9.2.0 changes From 6a6d2d8edfc01ab316ff190c34db5684fa149532 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Wed, 23 Aug 2023 15:00:05 +0200 Subject: [PATCH 23/40] Refactored offline plugin --- material/plugins/offline/plugin.py | 30 ++++++++++++++++-------------- src/plugins/offline/plugin.py | 30 ++++++++++++++++-------------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/material/plugins/offline/plugin.py b/material/plugins/offline/plugin.py index 8cfa110f665..abcb25984ad 100644 --- a/material/plugins/offline/plugin.py +++ b/material/plugins/offline/plugin.py @@ -21,7 +21,6 @@ import os from mkdocs.plugins import BasePlugin, event_priority -from mkdocs.utils import write_file from .config import OfflineConfig @@ -42,10 +41,10 @@ def on_config(self, config): config.use_directory_urls = False # Append iframe-worker to polyfills/shims - config.extra.polyfills = config.extra.get("polyfills", []) - if not any("iframe-worker" in url for url in config.extra.polyfills): - worker = "https://unpkg.com/iframe-worker/shim" - config.extra.polyfills.append(worker) + config.extra["polyfills"] = config.extra.get("polyfills", []) + if not any("iframe-worker" in url for url in config.extra["polyfills"]): + script = "https://unpkg.com/iframe-worker/shim" + config.extra["polyfills"].append(script) # Add support for offline search (run latest) - the search index is copied # and inlined into a script, so that it can be used without a server @@ -54,14 +53,17 @@ def on_post_build(self, *, config): if not self.config.enabled: return - # Check for existence of search index - path = os.path.join(config.site_dir, "search", "search_index.json") - if not os.path.isfile(path): + # Ensure presence of search index + path = os.path.join(config.site_dir, "search") + file = os.path.join(path, "search_index.json") + if not os.path.isfile(file): return - # Create script with inlined search index - with open(path, encoding = "utf-8") as f: - write_file( - f"var __index = {f.read()}".encode("utf-8"), - path.replace(".json", ".js"), - ) + # Obtain search index contents + with open(file, encoding = "utf-8") as f: + data = f.read() + + # Inline search index contents into script + file = os.path.join(path, "search_index.js") + with open(file, "w", encoding = "utf-8") as f: + f.write(f"var __index = {data}") diff --git a/src/plugins/offline/plugin.py b/src/plugins/offline/plugin.py index 8cfa110f665..abcb25984ad 100644 --- a/src/plugins/offline/plugin.py +++ b/src/plugins/offline/plugin.py @@ -21,7 +21,6 @@ import os from mkdocs.plugins import BasePlugin, event_priority -from mkdocs.utils import write_file from .config import OfflineConfig @@ -42,10 +41,10 @@ def on_config(self, config): config.use_directory_urls = False # Append iframe-worker to polyfills/shims - config.extra.polyfills = config.extra.get("polyfills", []) - if not any("iframe-worker" in url for url in config.extra.polyfills): - worker = "https://unpkg.com/iframe-worker/shim" - config.extra.polyfills.append(worker) + config.extra["polyfills"] = config.extra.get("polyfills", []) + if not any("iframe-worker" in url for url in config.extra["polyfills"]): + script = "https://unpkg.com/iframe-worker/shim" + config.extra["polyfills"].append(script) # Add support for offline search (run latest) - the search index is copied # and inlined into a script, so that it can be used without a server @@ -54,14 +53,17 @@ def on_post_build(self, *, config): if not self.config.enabled: return - # Check for existence of search index - path = os.path.join(config.site_dir, "search", "search_index.json") - if not os.path.isfile(path): + # Ensure presence of search index + path = os.path.join(config.site_dir, "search") + file = os.path.join(path, "search_index.json") + if not os.path.isfile(file): return - # Create script with inlined search index - with open(path, encoding = "utf-8") as f: - write_file( - f"var __index = {f.read()}".encode("utf-8"), - path.replace(".json", ".js"), - ) + # Obtain search index contents + with open(file, encoding = "utf-8") as f: + data = f.read() + + # Inline search index contents into script + file = os.path.join(path, "search_index.js") + with open(file, "w", encoding = "utf-8") as f: + f.write(f"var __index = {data}") From 92fc7f651f0dea98ecd789ce061a76b6fefccedf Mon Sep 17 00:00:00 2001 From: squidfunk Date: Wed, 23 Aug 2023 15:15:11 +0200 Subject: [PATCH 24/40] Formatting --- material/.overrides/hooks/translations.py | 4 +-- material/plugins/blog/plugin.py | 4 +-- material/plugins/blog/structure/__init__.py | 4 +-- material/plugins/info/plugin.py | 5 ++-- material/plugins/search/plugin.py | 2 +- material/plugins/social/plugin.py | 28 +++++++++++---------- material/plugins/tags/config.py | 2 +- src/.overrides/hooks/translations.py | 4 +-- src/plugins/blog/plugin.py | 4 +-- src/plugins/blog/structure/__init__.py | 4 +-- src/plugins/info/plugin.py | 5 ++-- src/plugins/search/plugin.py | 2 +- src/plugins/social/plugin.py | 28 +++++++++++---------- src/plugins/tags/config.py | 2 +- 14 files changed, 50 insertions(+), 48 deletions(-) diff --git a/material/.overrides/hooks/translations.py b/material/.overrides/hooks/translations.py index c4e2d185390..0bf458d960e 100644 --- a/material/.overrides/hooks/translations.py +++ b/material/.overrides/hooks/translations.py @@ -38,8 +38,8 @@ def on_page_markdown(markdown: str, *, page: Page, config: MkDocsConfig, files): return # Collect all existing languages - names: dict[str, str] = dict() - known: dict[str, dict[str, str]] = dict() + names: dict[str, str] = {} + known: dict[str, dict[str, str]] = {} for path in glob("src/partials/languages/*.html"): with open(path, "r", encoding = "utf-8") as f: data = f.read() diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index f46bd7e2b47..369d725cdf0 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -237,7 +237,7 @@ def on_page_markdown(self, markdown, *, page, config, files): # is not already present, so we can remove footnotes or other content # from the excerpt without affecting the content of the excerpt if separator not in page.markdown: - path = page.file.src_uri + path = page.file.src_path if self.config.post_excerpt == "required": raise PluginError( f"Couldn't find '{separator}' separator in '{path}'" @@ -415,7 +415,7 @@ def _resolve_authors(self, config: MkDocsConfig): docs = os.path.relpath(config.docs_dir) file = os.path.join(docs, path) if not os.path.isfile(file): - authors: dict[str, Author] = dict() + authors: dict[str, Author] = {} return authors # Open file and parse as YAML diff --git a/material/plugins/blog/structure/__init__.py b/material/plugins/blog/structure/__init__.py index 0a6e3650014..71f8724ddf5 100644 --- a/material/plugins/blog/structure/__init__.py +++ b/material/plugins/blog/structure/__init__.py @@ -109,8 +109,8 @@ def __init__(self, file: File, config: MkDocsConfig): # Excerpts are subsets of posts that are used in pages like archive and # category views. They are not rendered as standalone pages, but are - # included in the context of the parent post. Each post has a dedicated - # excerpt instance which is reused when rendering views. + # rendered in the context of a view. Each post has a dedicated excerpt + # instance which is reused when rendering views. self.excerpt: Excerpt = None # Initialize authors and actegories diff --git a/material/plugins/info/plugin.py b/material/plugins/info/plugin.py index 11764b6066f..b0bcc71f163 100644 --- a/material/plugins/info/plugin.py +++ b/material/plugins/info/plugin.py @@ -87,8 +87,7 @@ def on_config(self, config): # hack to detect whether the custom_dir setting was used without parsing # mkdocs.yml again - we check at which position the directory provided # by the theme resides, and if it's not the first one, abort. - path = get_theme_dir(config.theme.name) - if config.theme.dirs.index(path): + if config.theme.dirs.index(get_theme_dir(config.theme.name)): log.error("Please remove 'custom_dir' setting.") self._help_on_customizations_and_exit() @@ -130,7 +129,7 @@ def on_config(self, config): ])) ) - # Add information in platform + # Add information on platform f.writestr( os.path.join(example, "platform.json"), json.dumps( diff --git a/material/plugins/search/plugin.py b/material/plugins/search/plugin.py index 33ccd72e7af..33fe4bbf73c 100644 --- a/material/plugins/search/plugin.py +++ b/material/plugins/search/plugin.py @@ -299,7 +299,7 @@ class Element: """ # Initialize HTML element - def __init__(self, tag, attrs = dict()): + def __init__(self, tag, attrs = {}): self.tag = tag self.attrs = attrs diff --git a/material/plugins/social/plugin.py b/material/plugins/social/plugin.py index 650cb9c9626..011992b8184 100644 --- a/material/plugins/social/plugin.py +++ b/material/plugins/social/plugin.py @@ -18,6 +18,19 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +# ----------------------------------------------------------------------------- +# Disclaimer +# ----------------------------------------------------------------------------- +# Please note: this version of the social plugin is not actively development +# anymore. Instead, Material for MkDocs Insiders ships a complete rewrite of +# the plugin which is much more powerful and addresses all shortcomings of +# this implementation. Additionally, the new social plugin allows to create +# entirely custom social cards. You can probably imagine, that this was a lot +# of work to pull off. If you run into problems, or want to have additional +# functionality, please consider sponsoring the project. You can then use the +# new version of the plugin immediately. +# ----------------------------------------------------------------------------- + import concurrent.futures import functools import logging @@ -159,7 +172,7 @@ def on_page_markdown(self, markdown, page, config, files): ) sys.exit(1) - # Generate social card if not in cache - TODO: values from mkdocs.yml + # Generate social card if not in cache hash = md5("".join([ site_name, str(title), @@ -267,17 +280,6 @@ def _render_text(self, size, font, text, lmax, spacing = 0): lines.append(words) words = [word] - # # Balance words on last line - TODO: overflows when broken word is too long - # if len(lines) > 0: - # prev = len(" ".join(lines[-1])) - # last = len(" ".join(words))# - - # print(last, prev) - - # # Heuristic: try to find a good ratio - # if last / prev < 0.6: - # words.insert(0, lines[-1].pop()) - # Join words for each line and create image lines.append(words) lines = [" ".join(line) for line in lines] @@ -424,7 +426,7 @@ def _load_font(self, config): font_filename_base = name.replace(' ', '') filename_regex = re.escape(font_filename_base)+r"-(\w+)\.[ot]tf$" - font = dict() + font = {} # Check for cached files - note these may be in subfolders for currentpath, folders, files in os.walk(self.cache): for file in files: diff --git a/material/plugins/tags/config.py b/material/plugins/tags/config.py index ab94a71b364..ba2aa127d40 100644 --- a/material/plugins/tags/config.py +++ b/material/plugins/tags/config.py @@ -35,7 +35,7 @@ class TagsConfig(Config): # Options for tags tags_file = Optional(Type(str)) - tags_extra_files = Type(dict, default = dict()) + tags_extra_files = Type(dict, default = {}) tags_slugify = Type((type(slugify), partial), default = slugify) tags_slugify_separator = Type(str, default = "-") tags_compare = Optional(Type(type(casefold))) diff --git a/src/.overrides/hooks/translations.py b/src/.overrides/hooks/translations.py index c4e2d185390..0bf458d960e 100644 --- a/src/.overrides/hooks/translations.py +++ b/src/.overrides/hooks/translations.py @@ -38,8 +38,8 @@ def on_page_markdown(markdown: str, *, page: Page, config: MkDocsConfig, files): return # Collect all existing languages - names: dict[str, str] = dict() - known: dict[str, dict[str, str]] = dict() + names: dict[str, str] = {} + known: dict[str, dict[str, str]] = {} for path in glob("src/partials/languages/*.html"): with open(path, "r", encoding = "utf-8") as f: data = f.read() diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index f46bd7e2b47..369d725cdf0 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -237,7 +237,7 @@ def on_page_markdown(self, markdown, *, page, config, files): # is not already present, so we can remove footnotes or other content # from the excerpt without affecting the content of the excerpt if separator not in page.markdown: - path = page.file.src_uri + path = page.file.src_path if self.config.post_excerpt == "required": raise PluginError( f"Couldn't find '{separator}' separator in '{path}'" @@ -415,7 +415,7 @@ def _resolve_authors(self, config: MkDocsConfig): docs = os.path.relpath(config.docs_dir) file = os.path.join(docs, path) if not os.path.isfile(file): - authors: dict[str, Author] = dict() + authors: dict[str, Author] = {} return authors # Open file and parse as YAML diff --git a/src/plugins/blog/structure/__init__.py b/src/plugins/blog/structure/__init__.py index 0a6e3650014..71f8724ddf5 100644 --- a/src/plugins/blog/structure/__init__.py +++ b/src/plugins/blog/structure/__init__.py @@ -109,8 +109,8 @@ def __init__(self, file: File, config: MkDocsConfig): # Excerpts are subsets of posts that are used in pages like archive and # category views. They are not rendered as standalone pages, but are - # included in the context of the parent post. Each post has a dedicated - # excerpt instance which is reused when rendering views. + # rendered in the context of a view. Each post has a dedicated excerpt + # instance which is reused when rendering views. self.excerpt: Excerpt = None # Initialize authors and actegories diff --git a/src/plugins/info/plugin.py b/src/plugins/info/plugin.py index 11764b6066f..b0bcc71f163 100644 --- a/src/plugins/info/plugin.py +++ b/src/plugins/info/plugin.py @@ -87,8 +87,7 @@ def on_config(self, config): # hack to detect whether the custom_dir setting was used without parsing # mkdocs.yml again - we check at which position the directory provided # by the theme resides, and if it's not the first one, abort. - path = get_theme_dir(config.theme.name) - if config.theme.dirs.index(path): + if config.theme.dirs.index(get_theme_dir(config.theme.name)): log.error("Please remove 'custom_dir' setting.") self._help_on_customizations_and_exit() @@ -130,7 +129,7 @@ def on_config(self, config): ])) ) - # Add information in platform + # Add information on platform f.writestr( os.path.join(example, "platform.json"), json.dumps( diff --git a/src/plugins/search/plugin.py b/src/plugins/search/plugin.py index 33ccd72e7af..33fe4bbf73c 100644 --- a/src/plugins/search/plugin.py +++ b/src/plugins/search/plugin.py @@ -299,7 +299,7 @@ class Element: """ # Initialize HTML element - def __init__(self, tag, attrs = dict()): + def __init__(self, tag, attrs = {}): self.tag = tag self.attrs = attrs diff --git a/src/plugins/social/plugin.py b/src/plugins/social/plugin.py index 650cb9c9626..011992b8184 100644 --- a/src/plugins/social/plugin.py +++ b/src/plugins/social/plugin.py @@ -18,6 +18,19 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +# ----------------------------------------------------------------------------- +# Disclaimer +# ----------------------------------------------------------------------------- +# Please note: this version of the social plugin is not actively development +# anymore. Instead, Material for MkDocs Insiders ships a complete rewrite of +# the plugin which is much more powerful and addresses all shortcomings of +# this implementation. Additionally, the new social plugin allows to create +# entirely custom social cards. You can probably imagine, that this was a lot +# of work to pull off. If you run into problems, or want to have additional +# functionality, please consider sponsoring the project. You can then use the +# new version of the plugin immediately. +# ----------------------------------------------------------------------------- + import concurrent.futures import functools import logging @@ -159,7 +172,7 @@ def on_page_markdown(self, markdown, page, config, files): ) sys.exit(1) - # Generate social card if not in cache - TODO: values from mkdocs.yml + # Generate social card if not in cache hash = md5("".join([ site_name, str(title), @@ -267,17 +280,6 @@ def _render_text(self, size, font, text, lmax, spacing = 0): lines.append(words) words = [word] - # # Balance words on last line - TODO: overflows when broken word is too long - # if len(lines) > 0: - # prev = len(" ".join(lines[-1])) - # last = len(" ".join(words))# - - # print(last, prev) - - # # Heuristic: try to find a good ratio - # if last / prev < 0.6: - # words.insert(0, lines[-1].pop()) - # Join words for each line and create image lines.append(words) lines = [" ".join(line) for line in lines] @@ -424,7 +426,7 @@ def _load_font(self, config): font_filename_base = name.replace(' ', '') filename_regex = re.escape(font_filename_base)+r"-(\w+)\.[ot]tf$" - font = dict() + font = {} # Check for cached files - note these may be in subfolders for currentpath, folders, files in os.walk(self.cache): for file in files: diff --git a/src/plugins/tags/config.py b/src/plugins/tags/config.py index ab94a71b364..ba2aa127d40 100644 --- a/src/plugins/tags/config.py +++ b/src/plugins/tags/config.py @@ -35,7 +35,7 @@ class TagsConfig(Config): # Options for tags tags_file = Optional(Type(str)) - tags_extra_files = Type(dict, default = dict()) + tags_extra_files = Type(dict, default = {}) tags_slugify = Type((type(slugify), partial), default = slugify) tags_slugify_separator = Type(str, default = "-") tags_compare = Optional(Type(type(casefold))) From 1b2ba4bcefad36d5d4e2bc3925efad2447af5172 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Wed, 23 Aug 2023 15:39:49 +0200 Subject: [PATCH 25/40] Formatting --- material/plugins/blog/config.py | 16 ++++++++-------- material/plugins/info/config.py | 2 +- material/plugins/search/config.py | 4 ++-- material/plugins/social/config.py | 4 ++-- material/plugins/tags/config.py | 2 +- src/plugins/blog/config.py | 16 ++++++++-------- src/plugins/info/config.py | 2 +- src/plugins/search/config.py | 4 ++-- src/plugins/social/config.py | 4 ++-- src/plugins/tags/config.py | 2 +- 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/material/plugins/blog/config.py b/material/plugins/blog/config.py index a8d3f1a5ba7..c7a85095842 100644 --- a/material/plugins/blog/config.py +++ b/material/plugins/blog/config.py @@ -31,11 +31,11 @@ class BlogConfig(Config): enabled = Type(bool, default = True) - # Options for blog + # Settings for blog blog_dir = Type(str, default = "blog") blog_toc = Type(bool, default = False) - # Options for posts + # Settings for posts post_dir = Type(str, default = "{blog}/posts") post_date_format = Type(str, default = "long") post_url_date_format = Type(str, default = "yyyy/MM/dd") @@ -50,7 +50,7 @@ class BlogConfig(Config): post_readtime = Type(bool, default = True) post_readtime_words_per_minute = Type(int, default = 265) - # Options for archive + # Settings for archive archive = Type(bool, default = True) archive_name = Type(str, default = "blog.archive") archive_date_format = Type(str, default = "yyyy") @@ -58,7 +58,7 @@ class BlogConfig(Config): archive_url_format = Type(str, default = "archive/{date}") archive_toc = Optional(Type(bool)) - # Options for categories + # Settings for categories categories = Type(bool, default = True) categories_name = Type(str, default = "blog.categories") categories_url_format = Type(str, default = "category/{slug}") @@ -67,7 +67,7 @@ class BlogConfig(Config): categories_allowed = Type(list, default = []) categories_toc = Optional(Type(bool)) - # Options for pagination + # Settings for pagination pagination = Type(bool, default = True) pagination_per_page = Type(int, default = 10) pagination_url_format = Type(str, default = "page/{page}") @@ -75,14 +75,14 @@ class BlogConfig(Config): pagination_if_single_page = Type(bool, default = False) pagination_keep_content = Type(bool, default = False) - # Options for authors + # Settings for authors authors = Type(bool, default = True) authors_file = Type(str, default = "{blog}/.authors.yml") - # Options for drafts + # Settings for drafts draft = Type(bool, default = False) draft_on_serve = Type(bool, default = True) draft_if_future_date = Type(bool, default = False) - # Deprecated options + # Deprecated settings pagination_template = Deprecated(moved_to = "pagination_format") diff --git a/material/plugins/info/config.py b/material/plugins/info/config.py index 8d6e085838f..cbd64d4c0cb 100644 --- a/material/plugins/info/config.py +++ b/material/plugins/info/config.py @@ -30,6 +30,6 @@ class InfoConfig(Config): enabled = Type(bool, default = True) enabled_on_serve = Type(bool, default = False) - # Options for archive + # Settings for archive archive = Type(bool, default = True) archive_stop_on_violation = Type(bool, default = True) diff --git a/material/plugins/search/config.py b/material/plugins/search/config.py index d09aec7f1df..e601fb8fd9f 100644 --- a/material/plugins/search/config.py +++ b/material/plugins/search/config.py @@ -45,11 +45,11 @@ class SearchConfig(Config): separator = Optional(Type(str)) pipeline = ListOfItems(Choice(pipeline), default = []) - # Options for text segmentation (Chinese) + # Settings for text segmentation (Chinese) jieba_dict = Optional(Type(str)) jieba_dict_user = Optional(Type(str)) - # Unsupported options, originally implemented in MkDocs + # Unsupported settings, originally implemented in MkDocs indexing = Deprecated(message = "Unsupported option") prebuild_index = Deprecated(message = "Unsupported option") min_search_length = Deprecated(message = "Unsupported option") diff --git a/material/plugins/social/config.py b/material/plugins/social/config.py index 0b459ac6627..2d87c25e052 100644 --- a/material/plugins/social/config.py +++ b/material/plugins/social/config.py @@ -30,12 +30,12 @@ class SocialConfig(Config): enabled = Type(bool, default = True) cache_dir = Type(str, default = ".cache/plugin/social") - # Options for social cards + # Settings for social cards cards = Type(bool, default = True) cards_dir = Type(str, default = "assets/images/social") cards_layout_options = Type(dict, default = {}) - # Deprecated options + # Deprecated settings cards_color = Deprecated( option_type = Type(dict, default = {}), message = diff --git a/material/plugins/tags/config.py b/material/plugins/tags/config.py index ba2aa127d40..763581e56a8 100644 --- a/material/plugins/tags/config.py +++ b/material/plugins/tags/config.py @@ -33,7 +33,7 @@ class TagsConfig(Config): enabled = Type(bool, default = True) - # Options for tags + # Settings for tags tags_file = Optional(Type(str)) tags_extra_files = Type(dict, default = {}) tags_slugify = Type((type(slugify), partial), default = slugify) diff --git a/src/plugins/blog/config.py b/src/plugins/blog/config.py index a8d3f1a5ba7..c7a85095842 100644 --- a/src/plugins/blog/config.py +++ b/src/plugins/blog/config.py @@ -31,11 +31,11 @@ class BlogConfig(Config): enabled = Type(bool, default = True) - # Options for blog + # Settings for blog blog_dir = Type(str, default = "blog") blog_toc = Type(bool, default = False) - # Options for posts + # Settings for posts post_dir = Type(str, default = "{blog}/posts") post_date_format = Type(str, default = "long") post_url_date_format = Type(str, default = "yyyy/MM/dd") @@ -50,7 +50,7 @@ class BlogConfig(Config): post_readtime = Type(bool, default = True) post_readtime_words_per_minute = Type(int, default = 265) - # Options for archive + # Settings for archive archive = Type(bool, default = True) archive_name = Type(str, default = "blog.archive") archive_date_format = Type(str, default = "yyyy") @@ -58,7 +58,7 @@ class BlogConfig(Config): archive_url_format = Type(str, default = "archive/{date}") archive_toc = Optional(Type(bool)) - # Options for categories + # Settings for categories categories = Type(bool, default = True) categories_name = Type(str, default = "blog.categories") categories_url_format = Type(str, default = "category/{slug}") @@ -67,7 +67,7 @@ class BlogConfig(Config): categories_allowed = Type(list, default = []) categories_toc = Optional(Type(bool)) - # Options for pagination + # Settings for pagination pagination = Type(bool, default = True) pagination_per_page = Type(int, default = 10) pagination_url_format = Type(str, default = "page/{page}") @@ -75,14 +75,14 @@ class BlogConfig(Config): pagination_if_single_page = Type(bool, default = False) pagination_keep_content = Type(bool, default = False) - # Options for authors + # Settings for authors authors = Type(bool, default = True) authors_file = Type(str, default = "{blog}/.authors.yml") - # Options for drafts + # Settings for drafts draft = Type(bool, default = False) draft_on_serve = Type(bool, default = True) draft_if_future_date = Type(bool, default = False) - # Deprecated options + # Deprecated settings pagination_template = Deprecated(moved_to = "pagination_format") diff --git a/src/plugins/info/config.py b/src/plugins/info/config.py index 8d6e085838f..cbd64d4c0cb 100644 --- a/src/plugins/info/config.py +++ b/src/plugins/info/config.py @@ -30,6 +30,6 @@ class InfoConfig(Config): enabled = Type(bool, default = True) enabled_on_serve = Type(bool, default = False) - # Options for archive + # Settings for archive archive = Type(bool, default = True) archive_stop_on_violation = Type(bool, default = True) diff --git a/src/plugins/search/config.py b/src/plugins/search/config.py index d09aec7f1df..e601fb8fd9f 100644 --- a/src/plugins/search/config.py +++ b/src/plugins/search/config.py @@ -45,11 +45,11 @@ class SearchConfig(Config): separator = Optional(Type(str)) pipeline = ListOfItems(Choice(pipeline), default = []) - # Options for text segmentation (Chinese) + # Settings for text segmentation (Chinese) jieba_dict = Optional(Type(str)) jieba_dict_user = Optional(Type(str)) - # Unsupported options, originally implemented in MkDocs + # Unsupported settings, originally implemented in MkDocs indexing = Deprecated(message = "Unsupported option") prebuild_index = Deprecated(message = "Unsupported option") min_search_length = Deprecated(message = "Unsupported option") diff --git a/src/plugins/social/config.py b/src/plugins/social/config.py index 0b459ac6627..2d87c25e052 100644 --- a/src/plugins/social/config.py +++ b/src/plugins/social/config.py @@ -30,12 +30,12 @@ class SocialConfig(Config): enabled = Type(bool, default = True) cache_dir = Type(str, default = ".cache/plugin/social") - # Options for social cards + # Settings for social cards cards = Type(bool, default = True) cards_dir = Type(str, default = "assets/images/social") cards_layout_options = Type(dict, default = {}) - # Deprecated options + # Deprecated settings cards_color = Deprecated( option_type = Type(dict, default = {}), message = diff --git a/src/plugins/tags/config.py b/src/plugins/tags/config.py index ba2aa127d40..763581e56a8 100644 --- a/src/plugins/tags/config.py +++ b/src/plugins/tags/config.py @@ -33,7 +33,7 @@ class TagsConfig(Config): enabled = Type(bool, default = True) - # Options for tags + # Settings for tags tags_file = Optional(Type(str)) tags_extra_files = Type(dict, default = {}) tags_slugify = Type((type(slugify), partial), default = slugify) From 6839f1cd9706e08b9839ac5e1d807cfcb30b219f Mon Sep 17 00:00:00 2001 From: squidfunk Date: Wed, 23 Aug 2023 16:02:43 +0200 Subject: [PATCH 26/40] Formatting --- material/plugins/blog/plugin.py | 10 ++++++---- material/plugins/blog/structure/__init__.py | 2 +- src/plugins/blog/plugin.py | 10 ++++++---- src/plugins/blog/structure/__init__.py | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index 369d725cdf0..542bc4b2f80 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -411,16 +411,18 @@ def _resolve_authors(self, config: MkDocsConfig): path = self.config.authors_file.format(blog = self.config.blog_dir) path = os.path.normpath(path) - # If the authors file does not exist, return an empty dictionary + # Resolve path relative to docs directory docs = os.path.relpath(config.docs_dir) file = os.path.join(docs, path) + + # If the authors file does not exist, return here + config: Authors = Authors() if not os.path.isfile(file): - authors: dict[str, Author] = {} - return authors + return config.authors # Open file and parse as YAML with open(file, encoding = "utf-8") as f: - config: Authors = Authors(os.path.abspath(file)) + config.config_file_path = os.path.abspath(file) try: config.load_dict(yaml.load(f, SafeLoader) or {}) diff --git a/material/plugins/blog/structure/__init__.py b/material/plugins/blog/structure/__init__.py index 71f8724ddf5..ae202c3e213 100644 --- a/material/plugins/blog/structure/__init__.py +++ b/material/plugins/blog/structure/__init__.py @@ -52,7 +52,7 @@ class Post(Page): def __init__(self, file: File, config: MkDocsConfig): super().__init__(None, file, config) - # Resolve path relative to docs directory for error reporting + # Resolve path relative to docs directory docs = os.path.relpath(config.docs_dir) path = os.path.relpath(file.abs_src_path, docs) diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index 369d725cdf0..542bc4b2f80 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -411,16 +411,18 @@ def _resolve_authors(self, config: MkDocsConfig): path = self.config.authors_file.format(blog = self.config.blog_dir) path = os.path.normpath(path) - # If the authors file does not exist, return an empty dictionary + # Resolve path relative to docs directory docs = os.path.relpath(config.docs_dir) file = os.path.join(docs, path) + + # If the authors file does not exist, return here + config: Authors = Authors() if not os.path.isfile(file): - authors: dict[str, Author] = {} - return authors + return config.authors # Open file and parse as YAML with open(file, encoding = "utf-8") as f: - config: Authors = Authors(os.path.abspath(file)) + config.config_file_path = os.path.abspath(file) try: config.load_dict(yaml.load(f, SafeLoader) or {}) diff --git a/src/plugins/blog/structure/__init__.py b/src/plugins/blog/structure/__init__.py index 71f8724ddf5..ae202c3e213 100644 --- a/src/plugins/blog/structure/__init__.py +++ b/src/plugins/blog/structure/__init__.py @@ -52,7 +52,7 @@ class Post(Page): def __init__(self, file: File, config: MkDocsConfig): super().__init__(None, file, config) - # Resolve path relative to docs directory for error reporting + # Resolve path relative to docs directory docs = os.path.relpath(config.docs_dir) path = os.path.relpath(file.abs_src_path, docs) From cc096e48830744238f02f4b4abbeafab8217ffb3 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 24 Aug 2023 08:46:30 +0200 Subject: [PATCH 27/40] Documentation --- README.md | 4 ++-- docs/insiders/index.md | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8fc72309213..f0211734c34 100644 --- a/README.md +++ b/README.md @@ -123,9 +123,9 @@ - + /> --> diff --git a/docs/insiders/index.md b/docs/insiders/index.md index ec5003a86e1..3cd52ed2402 100644 --- a/docs/insiders/index.md +++ b/docs/insiders/index.md @@ -188,7 +188,6 @@ You can cancel your sponsorship anytime.[^5] [![Sparkfun]](https://sparkfun.com/){ target=_blank title="Sparkfun Electronics" } [![Eccenca]](https://eccenca.com/){ target=_blank title="Eccenca" } [![Neptune]](https://neptune.ai/){ target=_blank title="Neptune" } -[![Cash App]](https://cash.app/){ target=_blank title="Cash App" } [![RackN]](https://rackn.com/){ target=_blank title="RackN" } [![CivicActions]](https://civicactions.com/){ target=_blank title="CivicActions" } [![bitcrowd]](https://bitcrowd.net/){ target=_blank title="bitcrowd" } From 89de76d84017c22b770deaa54fc92363fe33948a Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 24 Aug 2023 09:56:43 +0200 Subject: [PATCH 28/40] Revert "Removed lxml dependency - not necessary after blog plugin rewrite" This reverts commit 0986c3a039082d5bd8537facecf25bfa960bf020. --- Dockerfile | 4 ++++ requirements.txt | 1 + 2 files changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 5595e842a89..0c15409b8eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,12 +47,16 @@ RUN \ git \ git-fast-import \ jpeg-dev \ + libxml2 \ + libxslt \ openssh \ zlib-dev \ && \ apk add --no-cache --virtual .build \ gcc \ libffi-dev \ + libxml2-dev \ + libxslt-dev \ musl-dev \ && \ pip install --no-cache-dir --upgrade pip \ diff --git a/requirements.txt b/requirements.txt index 24869df6c97..cc1f3ffa91c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,6 +29,7 @@ pymdown-extensions>=9.9.1 # Requirements for plugins babel>=2.10.3 colorama>=0.4 +lxml>=4.6 paginate>=0.5.6 readtime>=2.0 regex>=2022.4.24 From 77e55376ba48c33d68b68215042541d184f53eb3 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 24 Aug 2023 09:58:10 +0200 Subject: [PATCH 29/40] Updated changelog --- CHANGELOG | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7d039411ca1..cb7d7e1c0c2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,6 @@ -mkdocs-material-9.x.x (unreleased) +mkdocs-material-9.2.4 (2023-xx-xx) * Updated Afrikaans translations - * Removed lxml dependency - not necessary after blog plugin rewrite mkdocs-material-9.2.3+insiders-4.39.2 (2023-08-23) From 20ce88af9e53d361dd0cf83d72bc707e2c97fa1a Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 24 Aug 2023 10:03:19 +0200 Subject: [PATCH 30/40] Updated Insiders changelog --- CHANGELOG | 4 ++++ docs/insiders/changelog.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index cb7d7e1c0c2..d95971c509f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,10 @@ mkdocs-material-9.2.4 (2023-xx-xx) * Updated Afrikaans translations +mkdocs-material-9.2.3+insiders-4.39.3 (2023-08-24) + + * Fixed lxml dependency missing in Docker image (4.39.2 regression) + mkdocs-material-9.2.3+insiders-4.39.2 (2023-08-23) * Fixed color palette toggle being reversed (9.2.0 regression) diff --git a/docs/insiders/changelog.md b/docs/insiders/changelog.md index 399de3c6aa7..b74a92468ec 100644 --- a/docs/insiders/changelog.md +++ b/docs/insiders/changelog.md @@ -2,6 +2,10 @@ ## Material for MkDocs Insiders +### 4.39.3 August 24, 2023 { id="4.39.3" } + +- Fixed lxml dependency missing in Docker container (4.39.2 regression) + ### 4.39.2 August 23, 2023 { id="4.39.2" } - Fixed color palette toggle being reversed (9.2.0 regression) From 9259251377fd8d6d28b1417ffc8bdbd78acb2213 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 24 Aug 2023 18:39:12 +0200 Subject: [PATCH 31/40] Documentation --- docs/faq/sponsoring.md | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/docs/faq/sponsoring.md b/docs/faq/sponsoring.md index d1ef21123b7..81fb0643eb0 100644 --- a/docs/faq/sponsoring.md +++ b/docs/faq/sponsoring.md @@ -79,15 +79,28 @@ Note that [$15] is the minimum amount to be granted access to Insiders. [$15]: https://github.com/sponsors/squidfunk/sponsorships?tier_id=210638 -[__How is my sponsorship contribution used to support the project?__](#sponsorship-support){ #sponsorship-support } +[__How are sponsorship contributions used?__](#sponsorship-support){ #sponsorship-support } -Your sponsorship contribution directly supports the development and -maintenance of the project, by buying us maintainers time. It allows us to -dedicate more time and resources to enhance the project's features and -functionality. The additional funding helps us prioritize improvements and -updates, benefiting Insiders users and the wider community. We also actively -contribute to other upstream projects, fostering collaboration and giving -back to the Open Source ecosystem. +It's vital to recognize that the total sponsorship amount doesn't directly +translate into the funds we have available for use. The way we allocate +sponsorship amounts is detailed as follows: + +1. __Taxes__: Since we provide a service to our sponsors, we're of course + legally obligated to pay sales tax. This requirement applies to all + sponsorship contributions, aligning us with standard business practices + as for the rest of the world. + +2. __Sponsorships__: A significant portion of our funding is redirected to + upstream projects. This cultivates collaboration and supports the broader + Open Source ecosystem. Those projects and their maintainers are essential + for the ongoing development of Material for MkDocs. + + [Explore our sponsorships](https://github.com/squidfunk?tab=sponsoring). + +3. __Funds__: We are in the process of forming a team devoted to Material for + MkDocs and are proactively compensating critical contributors. These + funds cover various aspects of the project, like the creation of new + features, bug resolution, support, and sponsor relations. [__Are there any limitations on the number of sponsors for a particular tier?__](#sponsorship-limitations){ #sponsorship-limitations } @@ -371,8 +384,8 @@ appearance of your site should be optional. Most Insiders features enhance the overall experience, e.g., by adding icons to pages or providing a feedback widget. While these features add value for your site's users, they should be optional for previewing when making changes to content. Currently, the only -content-related features in Insiders that non-Insiders users can't properly -preview are [Annotations] and [Card grids]. +content-related feature in Insiders that non-Insiders users can't properly +preview are [Card grids]. This means that outside collaborators can build the documentation locally with Material for MkDocs, and when they push their changes, your CI pipeline will @@ -384,10 +397,8 @@ See the [getting started guide] for more information. [configuration inheritance]: https://www.mkdocs.org/user-guide/configuration/#configuration-inheritance [getting started guide]: ../insiders/getting-started.md#caveats - [Annotations]: ../reference/annotations.md?h=anno#annotations [Card grids]: ../reference/grids.md?h=grids#using-card-grids - ## Support [__How can I contact support if I have questions about becoming a sponsor?__ ](#support-contact){ #support-contact } From d26a949175f70c912e8a74e6639f6e56e01df419 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sat, 26 Aug 2023 09:58:03 +0200 Subject: [PATCH 32/40] Updated premium sponsors --- .github/assets/sponsors/sponsor-buhler.png | Bin 0 -> 6003 bytes README.md | 3 +++ docs/insiders/index.md | 2 ++ 3 files changed, 5 insertions(+) create mode 100644 .github/assets/sponsors/sponsor-buhler.png diff --git a/.github/assets/sponsors/sponsor-buhler.png b/.github/assets/sponsors/sponsor-buhler.png new file mode 100644 index 0000000000000000000000000000000000000000..d58a2c5df36be93f2cbffa60cc36623cd519b144 GIT binary patch literal 6003 zcmdT|^;Z-?yIv6#0YQ*P8YGtPkOc{)mUQWEmhN&vT4VuPN_G*D?(URuX^?J^lI~^& zKEC_Q{TJ^2Vdl)4Gw;05%)E1+=R8pwYVV)pQR4vsfagkz@>&4Equz&c2rkw`5B3>( z{4nv!UQSL!8?5m`fk8`yK}e9FTYy`Dk580AUQUUDT|ziXTzN(j-Mov)-tG zsIeQh@Fs(6W`Aw0=8$ElL_ez{=QjaAt~Iw|30q>YGX(~OWsW0Fi$wgAEdl_0vXSAkLCS>|W=!MdBMFmlgO#huI_|6di}$;; zhcJR?Ot+_h4}<~vpQ+1l)wGXk3EPN=je6B-Ow{2j$2 z{{oFCtI=YVSFODBZ$J2^?Jown8co8U9(f$LZm!@zV2AWCMRT|U4JNS7Yqo0!^6S0&M zzADWr<^T8{k?P&4+L=?6qhza`P)DkWYt~QmgyxjbtisJ|po-NnnclzM6u2+vbGS`k zRc~?mZ}?zQDjI!pDfq8r4|-^_d%Wl|a{YaIQf!j|0GJrHy}-X|C*phm~1mtCr5NX*QV<3-xuzyVy%9(`m!yr$ygwr-;` z6?vnXL92bC8G%cabON2`&cpxRrkowqvkuz;vQtmE;i1Fm1z<`zg9DAbHl~+8dnD=UDDuwa7FH$YPiZ|i@u*A43B~e z+d)}u^Sptt{c>Kb3OQbpC5H3()R*Tnx zM3~ZEU8yKSjK}MAc&~0wAkLBFdAkNp%R~UJP&4q-?oiLN#BADBeXqMjd(Z}YgEiMV zlDX6c8-T~CmoV{r{Cs^gBk!F1z_`)h(97vH6WJe&hd6Y%)mGFkW~@GyQ+oXNQrA>B zDJ3Is?Xir(L)7s+^Z8<1r4Vh4g!KKWgG+A>kfuOQH3BOl{%U$&XmQ_D%oBe@IPLVu zC)2A$`~mY;QYCj86;CiKDV{?tkWb9sK(cLqrB~z9&?i-{!a!s_!*{Lw_yL1}=wW54 zXtD8b(8=kDcZP)dHY>HIhr9dKAcv{0NVx#-h<)^Fz?itm&AzTFDX7-sA}y%lZ!w(z zKIhoBIZ*Vr(51|vxwS5qUu6CAy%bqxiSLDaSu1Gg?eO(2uQWX=%wWcAzD%;6QQ9!! zG{Dqde2{Aou0 zA~EL5wDsIQZp8N7u8}Ggs4^fjR9w)4#mT-Zy274h~@WgFd2q2d<2XD^+7U^w+Aqf6@h#6a;W zo(27@BXwNuBz_Ue0UDo%IgkLCDg-^Vu&3YIBiYkU!7c*MKrshKr4_ZZ_@y4qJe6B< zB`NHuq`|wotVv%O_a7^qKQOKJb{N8VR&XE7{v$a!kIAs%n`TtN!r&4{3GYA#68UB^=%H~ieeY+1rG02CkL7aO_U&7*5*q0Dd=tr$eRf?bbnDY zwdX8VxTDV0e=c0BJD8sRuOeZ^HK;$xCaqEz84L3~AUMbA@$Vyc=m>BBH~NR7%|&fd z$JZR=2NM;y;3oGfcA$Ed+1A!gBdv$J@h{8|>zET!uAAr^A{}&jZNXK*uBX5}H4(I` z?GI}^Y&pq7H2xWQ9x{p4MaAZB_tx{8B**sOUyKq%lh7myr}qr~17e$PeOse;@(1C$ zN#k9iFqW|s5}K+zy9lU>AiX z@lS2g1aLb6@lyD(i-qxmtn=r!^qF5Fa}O4JzZS_ozhZkA8a&g}m8Pwo46jVX@1RbK z$X(hiynhznh4?e#ju+zfo3~8HEDEQ1-I76C`*+v&E83FqbSr<5Fws{zo8o?X!4@fH z6`k}VX)%%){}$e2bwGp7k(DpQl^5#llq3iTaCoHAiTyOTquFW=rz3#i+J=~Xg$$ih4oJE{rk zv4vCR%`TMhCHxTxE&|}I5uD{(@|ddF26*qd4CdJ{n^ZgBFsD^JFYCc{-|zm;JYt1c zwz+j^u-j3ZTXakCviU%rdiaJec+-`v?5GH6CO&(`iW=%MzlF8fcc(e-J=5l;P}A2E zu7g)LiYMcjQd)vNi4_!_O;&&9h-87GJp~Pf^3yd#WDrfFC(pBO7kr?uGVb-!mM|%Y z{{EM5fM&QlD#)?ZMq?0A6o%1>jB2_?liDxjpE2$O`Sd103CcEoXf(BOq+;^MB2_g=C zX;txB)FM|zn-5L5(9k#mqzroY~!>h=Q zWVcZrO|m{6bDQCqSgx=-{}+Li_0t;8Uw0&{q2`kl$(3BxCv6%|Ex8pvsHQx%ML|yb z3p67eS4zS$;gSjL;ylF>u7+1KS}2PSY=2SpWQi3dCrF@K3G*sUCcxajjJOJA>rt5E zBlW8~Fl>zQpK`I@qZwJ#*%^S}(E#Bqn!d^N*<`kYmPwK7ih?5n2m zy=>_E$~Q+&*9`hfy8QBJhf|ymf4CajFDq-B{r%QhS&`9OkBGW>bLgF|H&(8(?8Mi` z-Zdqdw*54vcn9Y_WkVVC5hP``X6@q9lo{vG5FszwA@9OvQa^&@ps>995%A=;V zG|5+K=mmYZvd!((n`gs(23MvN&n2DpcJFWn$QyE0hB;zA^HO1Bt5yDZ$#FHwjKLWRS znx)JrHB}5F?CJLR1B>o5*E6nrRFZAGF`vTNuLAWG*7`N*N*>=mGi7IQAp{dc4pZ5O zgPP9K3gJ~B6Ft8e7zjunNTyLS+6JeP>W zWc7<}aKWcwej9f+9Eab0ZRh>?I?IaVHBOWGrEPc`&elW1Nt4@Rjz~@`RzvBRS@uEo zo2B=K((KoWm)&VxmX1n4GDU#>9R5|ZGrPsX2Mb81mCeW?cLA9}uSA>8nG&C2$YcO( z^p@qVX~zFqZ7OU}Q7*hzD&551Dt(l!u~C-4 zz2B=eqorRBRZH!BYyx^9%!a)SiS1lBcS6sa+LxH-1aBK(MTl)^y`kDiE-0Fs4;~C~ zE9V5)_c(y)@gkc)gH(A?#$t4dj_(xXU00elwFD)BsY4~%U*_aBwU;zoskAFgZB~e; zoK)4fFLH@IN|Iq~U&<$Zd^ir#C$ekiPqgoN^y!GlH(TlrO?M_0jw9{o# zIum+rXJHbS%a(ahZfA$vB{zDA1!D^rpK5hzS)i$r-d>`KY8bdWcm`HXtjXHA0k0s2 z8nJD2Y?mh{v-+Yqz~cq(_^d;NRmN1Nrfu$q&l{_$R%I&;bW&5=+deKu+Nu{z?WIp8 z7jNovv_yScH}OLK)x{e)ub-ZhYQccbku@;{kzhe6Y3iy(x|McqwRQnHmRHUJ(`po&$FM%h%uh7pXMP4k>N#JVx%Go+&R#ynG2VpD1LMiD5fro|QC6c#^L+(sxI?Z=k%a;AVK| zTyb*ZL1o7uUc9NW2|ek$h>g2n!yK~fPYR3YOOQbR{#D@_W4-)LTkDR>QyNb^bG3jA zpP$ohk=6{^!0q9SMurrahKwcnpPJd#gA>F;3D^9}m)l5GTEe^&)j%!CLU@p`Hr{kv zD6)Vx8!|Cc@O#bAdvkH*paqjUe~463w|J18ze~>!9;a|)J0Qx63Yz?W_`0TiK`*68 z`n0FsxT*TrusYsSFxorQ2mGLJ7UT@^xQo8Uu;gEM-w_qsMpw0TqOZPtF26RPFJ=FL zu|?0gj}pMwhjE>onFnreJy|nUoASgR3-9=2BSSs}8|zlCSnxl1^;G4t#;&ShW5XlH!9w7ZgWAZvxmEXWLPS7mA%c zZ->qubY{%y@@RpjT)}o%TFva=*EnIa>D!vy!3$kN_Srvvu4Q~Y@>UrK<5QG#qbQnd znAi#(??)xe+1x-t6`b%@Z{zklXa|Z7RiNvJCiF~`{O!hbEZSr}N@A`A*lcMueZw>^ z#C^c6r8=zsQnaLYx2Zys8-n^p=|D@JxIpFDbXcZOe|=BaB&CemIy#LZM@LOhPgH$_ zu=ll6;+TE{4g)itg=;Pc3u&WMk~VTYBfky2%EQviwV&%k)$QrEeCS)1OSFWw zO3z;|Wwad)T4I*w_m!> zLLjL?W#u5)?zD4ZX|?}sdgjdAr@z*XR;JM4Q=ktQc^ng!WmDd*<8Dm4@8!D~VAsLb z_4z#hcAzF=C{x5Z`utnwJ7ds#7Riz=@ zMO9Ca6%|VlM`94dvr8YlKz*Dtj0)^Y_;b+N?r3Ob`=em9EX!GjZ zlRVnOy>Gp4*8iqsCD)Cw3Pc9sm9q702P7Fe!cK(+H7b*reC|Uaa)KKzM-lHwkZ9Q$ zz0DycYl)GGiB=Qbd4FbNIb{`8Hb4~uX;p1r3l^qHU-Fv{r4hy7b}? z8@IvqCGXPfH8UP02ch-a=5Jj@m(%4l{PKq`T5D)vUPgfP0vCvFcgN=K%c4|xR1vu@cX`)Q zOB4=5lm&-76`mF%i^&_F +

 

diff --git a/docs/insiders/index.md b/docs/insiders/index.md index 3cd52ed2402..43a10ba564a 100644 --- a/docs/insiders/index.md +++ b/docs/insiders/index.md @@ -199,6 +199,7 @@ You can cancel your sponsorship anytime.[^5] [![Koor]](https://koor.tech/){ target=_blank title="Koor" } [![Astral]](https://astral.sh/){ target=_blank title="Astral" } [![Oikolab]](https://oikolab.com/){ target=_blank title="Oikolab" } +[![Bühler Group]](https://www.buhlergroup.com/){ target=_blank title="Bühler Group" } @@ -234,6 +235,7 @@ You can cancel your sponsorship anytime.[^5] [Koor]: https://raw.githubusercontent.com/squidfunk/mkdocs-material/master/.github/assets/sponsors/sponsor-koor.png [Astral]: https://raw.githubusercontent.com/squidfunk/mkdocs-material/master/.github/assets/sponsors/sponsor-astral.png [Oikolab]: https://raw.githubusercontent.com/squidfunk/mkdocs-material/master/.github/assets/sponsors/sponsor-oikolab.png + [Bühler Group]: https://raw.githubusercontent.com/squidfunk/mkdocs-material/master/.github/assets/sponsors/sponsor-buhler.png
From db568b1e6b28e3402c3b52a62ea8eb9430be6474 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sat, 26 Aug 2023 12:34:51 +0200 Subject: [PATCH 33/40] Added version to info plugin example name --- material/plugins/info/plugin.py | 2 +- src/plugins/info/plugin.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/material/plugins/info/plugin.py b/material/plugins/info/plugin.py index b0bcc71f163..41dc0373ff7 100644 --- a/material/plugins/info/plugin.py +++ b/material/plugins/info/plugin.py @@ -106,7 +106,7 @@ def on_config(self, config): archive = BytesIO() example = input("\nPlease name your bug report (2-4 words): ") example, _ = os.path.splitext(example) - example = slugify(example, "-") + example = "-".join([present, slugify(example, "-")]) # Create self-contained example from project files: list[str] = [] diff --git a/src/plugins/info/plugin.py b/src/plugins/info/plugin.py index b0bcc71f163..41dc0373ff7 100644 --- a/src/plugins/info/plugin.py +++ b/src/plugins/info/plugin.py @@ -106,7 +106,7 @@ def on_config(self, config): archive = BytesIO() example = input("\nPlease name your bug report (2-4 words): ") example, _ = os.path.splitext(example) - example = slugify(example, "-") + example = "-".join([present, slugify(example, "-")]) # Create self-contained example from project files: list[str] = [] From cafdc48a8a1c7d73683ce9f9cafc7966af2df63f Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sat, 26 Aug 2023 13:59:23 +0200 Subject: [PATCH 34/40] Prepare 9.2.4 release --- CHANGELOG | 9 ++++- docs/changelog/index.md | 5 +++ docs/insiders/changelog.md | 6 ++++ docs/setup/setting-up-social-cards.md | 50 ++++++++++++++++++++++++--- material/base.html | 2 +- package-lock.json | 4 +-- package.json | 2 +- 7 files changed, 68 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d95971c509f..6a010f684f9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,12 @@ -mkdocs-material-9.2.4 (2023-xx-xx) +mkdocs-material-9.2.4+insiders-4.40.0 (2023-08-26) + * Added logo, title and description options to social plugin default layouts + * Fixed privacy plugin compatibility issue with Python < 3.10 + * Fixed #5896: Blog plugin errors when using custom index pages + +mkdocs-material-9.2.4 (2023-08-26) + + * Added version to bug report name in info plugin * Updated Afrikaans translations mkdocs-material-9.2.3+insiders-4.39.3 (2023-08-24) diff --git a/docs/changelog/index.md b/docs/changelog/index.md index 7e61f016c37..1bb949d33b7 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -2,6 +2,11 @@ ## Material for MkDocs +### 9.2.4 August 26, 2023 { id="9.2.4" } + +- Added version to bug report name in info plugin +- Updated Afrikaans translations + ### 9.2.3 August 22, 2023 { id="9.2.3" } - Fixed blog plugin rendering wrongly with `markdown.extensions.toc` diff --git a/docs/insiders/changelog.md b/docs/insiders/changelog.md index b74a92468ec..e6d6eb2ab64 100644 --- a/docs/insiders/changelog.md +++ b/docs/insiders/changelog.md @@ -2,6 +2,12 @@ ## Material for MkDocs Insiders +### 4.40.0 August 26, 2023 { id="4.39.3" } + +- Added logo, title and description options to social plugin default layouts +- Fixed privacy plugin compatibility issue with Python < 3.10 +- Fixed #5896: Blog plugin errors when using custom index pages + ### 4.39.3 August 24, 2023 { id="4.39.3" } - Fixed lxml dependency missing in Docker container (4.39.2 regression) diff --git a/docs/setup/setting-up-social-cards.md b/docs/setup/setting-up-social-cards.md index 15581f0e426..14daa420673 100644 --- a/docs/setup/setting-up-social-cards.md +++ b/docs/setup/setting-up-social-cards.md @@ -331,6 +331,46 @@ The following configuration options are available for card generation: font_family: Ubuntu ``` + [`title`](#+social.cards_layout_options.title){ #+social.cards_layout_options.title } + + : [:octicons-tag-24: insiders-4.40.0][Insiders] – Set the social card + title, which takes precedence over `page.title` and `page.meta.title`: + + ``` yaml + plugins: + - social: + cards_layout_options: + title: Social card title + ``` + + [`description`](#+social.cards_layout_options.description){ #+social.cards_layout_options.description } + + : [:octicons-tag-24: insiders-4.40.0][Insiders] – Set the social card + description, which takes precedence over `site_description` and + `page.meta.description`: + + ``` yaml + plugins: + - social: + cards_layout_options: + description: Social card description + ``` + + [`logo`](#+social.cards_layout_options.logo){ #+social.cards_layout_options.logo } + + : [:octicons-tag-24: insiders-4.40.0][Insiders] – Set the logo used as + part of the social card, overriding the `theme.logo` or + `theme.icon.logo` settings which are used as defaults: + + ``` yaml + plugins: + - social: + cards_layout_options: + logo: layouts/logo.png + ``` + + The path of the image must be defined relative to the project root. + [`cards_include`](#+privacy.cards_include){ #+privacy.cards_include } : [:octicons-tag-24: insiders-4.35.0][Insiders] · :octicons-milestone-24: @@ -507,16 +547,16 @@ The following configuration options are available for caching: ## Usage If you want to adjust the title or set a custom description for the social card, -you can set the front matter `title` and `description` properties, which take -precedence over the default values. +you can set the front matter [`title`][Changing the title] and +[`description`][Changing the description] properties, which take precedence over +the defaults, or use: -- [Changing the title] -- [Changing the description] +- [`cards_layout_options.title`](#+social.cards_layout_options.title) +- [`cards_layout_options.description`](#+social.cards_layout_options.description) [Changing the title]: ../reference/index.md#setting-the-page-title [Changing the description]: ../reference/index.md#setting-the-page-description - ### Choosing a font Some fonts do not contain CJK characters, like for example the diff --git a/material/base.html b/material/base.html index 44a77d010e5..2b41684ec2d 100644 --- a/material/base.html +++ b/material/base.html @@ -32,7 +32,7 @@ {% endif %} - + {% endblock %} {% block htmltitle %} {% if page.meta and page.meta.title %} diff --git a/package-lock.json b/package-lock.json index ec05d3791ce..3c2e6e8fec1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mkdocs-material", - "version": "9.2.3", + "version": "9.2.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mkdocs-material", - "version": "9.2.3", + "version": "9.2.4", "license": "MIT", "dependencies": { "clipboard": "^2.0.11", diff --git a/package.json b/package.json index 460a0233d27..fe10b98d96e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mkdocs-material", - "version": "9.2.3", + "version": "9.2.4", "description": "Documentation that simply works", "keywords": [ "mkdocs", From f022873c69bb10b419dfbecab2cc0a2d6ac794b1 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sat, 26 Aug 2023 14:08:27 +0200 Subject: [PATCH 35/40] Updated changelog --- docs/insiders/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/insiders/changelog.md b/docs/insiders/changelog.md index e6d6eb2ab64..77da8830e7f 100644 --- a/docs/insiders/changelog.md +++ b/docs/insiders/changelog.md @@ -2,7 +2,7 @@ ## Material for MkDocs Insiders -### 4.40.0 August 26, 2023 { id="4.39.3" } +### 4.40.0 August 26, 2023 { id="4.40.0" } - Added logo, title and description options to social plugin default layouts - Fixed privacy plugin compatibility issue with Python < 3.10 From fbb7a5e8942629b1acc09c7f296e5396f654a554 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sun, 27 Aug 2023 11:42:11 +0200 Subject: [PATCH 36/40] Blog plugin pagination breaks when disabling directory URLs --- material/plugins/blog/plugin.py | 17 +++++++++++------ src/plugins/blog/plugin.py | 17 +++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index 542bc4b2f80..4645c0081c8 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -369,7 +369,7 @@ def _resolve_post(self, file: File, config: MkDocsConfig): path = self._format_path_for_post(post, config) temp = self._path_to_file(path, config, temp = False) - # Replace post destination file system path and URL + # Replace destination file system path and URL file.dest_uri = temp.dest_uri file.abs_dest_path = temp.abs_dest_path file.url = temp.url @@ -600,18 +600,23 @@ def _generate_pages(self, view: View, config: MkDocsConfig, files: Files): step = self.config.pagination_per_page prev = view - # Compute pagination boundaries and create pages + # Compute pagination boundaries and create pages - pages are internally + # handled as copies of a view, as they map to the same source location for at in range(step, len(view.posts), step): - path = self._format_path_for_pagination(view.url, 1 + at // step) + base, _ = posixpath.splitext(view.file.src_uri) + + # Compute path and create a file for path resolution + path = self._format_path_for_pagination(base, 1 + at // step) file = self._path_to_file(path, config) - # Replace post source file system path and apend to files + # Replace source file system path and append to files file.src_uri = view.file.src_uri file.abs_src_path = view.file.abs_src_path files.append(file) - # Create view and attach to previous page - next = View(view.title, file, config) + # Create view and attach to parent - we don't set the title of the + # view, so authors can override them in the page's content + next = View(None, file, config) self._attach(prev, [ view.previous_page, next, diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index 542bc4b2f80..4645c0081c8 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -369,7 +369,7 @@ def _resolve_post(self, file: File, config: MkDocsConfig): path = self._format_path_for_post(post, config) temp = self._path_to_file(path, config, temp = False) - # Replace post destination file system path and URL + # Replace destination file system path and URL file.dest_uri = temp.dest_uri file.abs_dest_path = temp.abs_dest_path file.url = temp.url @@ -600,18 +600,23 @@ def _generate_pages(self, view: View, config: MkDocsConfig, files: Files): step = self.config.pagination_per_page prev = view - # Compute pagination boundaries and create pages + # Compute pagination boundaries and create pages - pages are internally + # handled as copies of a view, as they map to the same source location for at in range(step, len(view.posts), step): - path = self._format_path_for_pagination(view.url, 1 + at // step) + base, _ = posixpath.splitext(view.file.src_uri) + + # Compute path and create a file for path resolution + path = self._format_path_for_pagination(base, 1 + at // step) file = self._path_to_file(path, config) - # Replace post source file system path and apend to files + # Replace source file system path and append to files file.src_uri = view.file.src_uri file.abs_src_path = view.file.abs_src_path files.append(file) - # Create view and attach to previous page - next = View(view.title, file, config) + # Create view and attach to parent - we don't set the title of the + # view, so authors can override them in the page's content + next = View(None, file, config) self._attach(prev, [ view.previous_page, next, From da21786694e6cef70e617a4d9e8b59af65f24567 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sun, 27 Aug 2023 11:44:30 +0200 Subject: [PATCH 37/40] Documentation --- material/plugins/blog/plugin.py | 2 +- src/plugins/blog/plugin.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index 4645c0081c8..573de2c6f3d 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -605,7 +605,7 @@ def _generate_pages(self, view: View, config: MkDocsConfig, files: Files): for at in range(step, len(view.posts), step): base, _ = posixpath.splitext(view.file.src_uri) - # Compute path and create a file for path resolution + # Compute path and create a file for pagination path = self._format_path_for_pagination(base, 1 + at // step) file = self._path_to_file(path, config) diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index 4645c0081c8..573de2c6f3d 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -605,7 +605,7 @@ def _generate_pages(self, view: View, config: MkDocsConfig, files: Files): for at in range(step, len(view.posts), step): base, _ = posixpath.splitext(view.file.src_uri) - # Compute path and create a file for path resolution + # Compute path and create a file for pagination path = self._format_path_for_pagination(base, 1 + at // step) file = self._path_to_file(path, config) From 568a5c8e1e4fad38af220f811f42cd8ff18551e8 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sun, 27 Aug 2023 12:47:44 +0200 Subject: [PATCH 38/40] Fixed blog title not being consistent in pagination --- material/plugins/blog/plugin.py | 14 ++++++++++---- src/plugins/blog/plugin.py | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index 573de2c6f3d..39212111dbd 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -202,7 +202,14 @@ def on_page_markdown(self, markdown, *, page, config, files): if page in self._resolve_views(self.blog): assert isinstance(page, View) if 0 < page.pages.index(page): - return f"# {page.title}" + main = page.parent + + # We need to use the rendered title of the original view + # if the author set the title in the page's contents, or + # it would be overridden with the one set in mkdocs.yml, + # which would result in inconsistent headings + name = main._title_from_render or main.title + return f"# {name}" # Nothing more to be done for views return @@ -614,9 +621,8 @@ def _generate_pages(self, view: View, config: MkDocsConfig, files: Files): file.abs_src_path = view.file.abs_src_path files.append(file) - # Create view and attach to parent - we don't set the title of the - # view, so authors can override them in the page's content - next = View(None, file, config) + # Create view and attach to previous page + next = View(view.title, file, config) self._attach(prev, [ view.previous_page, next, diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index 573de2c6f3d..39212111dbd 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -202,7 +202,14 @@ def on_page_markdown(self, markdown, *, page, config, files): if page in self._resolve_views(self.blog): assert isinstance(page, View) if 0 < page.pages.index(page): - return f"# {page.title}" + main = page.parent + + # We need to use the rendered title of the original view + # if the author set the title in the page's contents, or + # it would be overridden with the one set in mkdocs.yml, + # which would result in inconsistent headings + name = main._title_from_render or main.title + return f"# {name}" # Nothing more to be done for views return @@ -614,9 +621,8 @@ def _generate_pages(self, view: View, config: MkDocsConfig, files: Files): file.abs_src_path = view.file.abs_src_path files.append(file) - # Create view and attach to parent - we don't set the title of the - # view, so authors can override them in the page's content - next = View(None, file, config) + # Create view and attach to previous page + next = View(view.title, file, config) self._attach(prev, [ view.previous_page, next, From acd70cf04a5ff4ecd955ed46571ebceaf2ddad66 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sun, 27 Aug 2023 12:56:28 +0200 Subject: [PATCH 39/40] Fixed dirty rebuilds for blog plugin --- material/plugins/blog/plugin.py | 2 +- src/plugins/blog/plugin.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index 39212111dbd..9bfb89685d3 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -658,7 +658,7 @@ def _render(self, view: View): # Render excerpts for selected posts posts = [ self._render_post(post.excerpt, view) - for post in posts + for post in posts if post.excerpt ] # Return posts and pagination diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index 39212111dbd..9bfb89685d3 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -658,7 +658,7 @@ def _render(self, view: View): # Render excerpts for selected posts posts = [ self._render_post(post.excerpt, view) - for post in posts + for post in posts if post.excerpt ] # Return posts and pagination From ecdf33681a0f3be80b69747856c173bea4009ab3 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sun, 27 Aug 2023 13:03:47 +0200 Subject: [PATCH 40/40] Prepare 9.2.5 release --- CHANGELOG | 11 +++++++++++ docs/changelog/index.md | 6 ++++++ docs/insiders/changelog.md | 5 +++++ material/base.html | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6a010f684f9..33f3d4731ad 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,14 @@ +mkdocs-material-9-2.5+insiders-4.40.1 (2023-08-27) + + * Fixed #5902: ResizeObserver polyfill not detected by privacy plugin + * Fixed empty category pages in blog plugin (4.40.0 regression) + +mkdocs-material-9-2.5 (2023-08-27) + + * Fixed error in dirty serve mode when using blog plugin + * Fixed page title not being consistent in blog plugin pagination + * Fixed #5899: Blog plugin pagination breaks when disabling directory URLs + mkdocs-material-9.2.4+insiders-4.40.0 (2023-08-26) * Added logo, title and description options to social plugin default layouts diff --git a/docs/changelog/index.md b/docs/changelog/index.md index 1bb949d33b7..11731736a28 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -2,6 +2,12 @@ ## Material for MkDocs +### 9.2.5 August 27, 2023 { id="9.2.5" } + +- Fixed error in dirty serve mode when using blog plugin +- Fixed page title not being consistent in blog plugin pagination +- Fixed #5899: Blog plugin pagination breaks when disabling directory URLs + ### 9.2.4 August 26, 2023 { id="9.2.4" } - Added version to bug report name in info plugin diff --git a/docs/insiders/changelog.md b/docs/insiders/changelog.md index 77da8830e7f..25a7171e9be 100644 --- a/docs/insiders/changelog.md +++ b/docs/insiders/changelog.md @@ -2,6 +2,11 @@ ## Material for MkDocs Insiders +### 4.40.1 August 27, 2023 { id="4.40.1" } + +- Fixed #5902: ResizeObserver polyfill not detected by privacy plugin +- Fixed empty category pages in blog plugin (4.40.0 regression) + ### 4.40.0 August 26, 2023 { id="4.40.0" } - Added logo, title and description options to social plugin default layouts diff --git a/material/base.html b/material/base.html index 2b41684ec2d..0cf6881ea0b 100644 --- a/material/base.html +++ b/material/base.html @@ -32,7 +32,7 @@ {% endif %} - + {% endblock %} {% block htmltitle %} {% if page.meta and page.meta.title %} diff --git a/package-lock.json b/package-lock.json index 3c2e6e8fec1..ffbd80b319e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mkdocs-material", - "version": "9.2.4", + "version": "9.2.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mkdocs-material", - "version": "9.2.4", + "version": "9.2.5", "license": "MIT", "dependencies": { "clipboard": "^2.0.11", diff --git a/package.json b/package.json index fe10b98d96e..c37b23b4c3c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mkdocs-material", - "version": "9.2.4", + "version": "9.2.5", "description": "Documentation that simply works", "keywords": [ "mkdocs",