mkdocs2confluence 0.20.3__tar.gz → 0.20.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mkdocs2confluence-0.20.3/src/mkdocs2confluence.egg-info → mkdocs2confluence-0.20.5}/PKG-INFO +6 -1
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/README.md +5 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/pyproject.toml +1 -1
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5/src/mkdocs2confluence.egg-info}/PKG-INFO +6 -1
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs2confluence.egg-info/SOURCES.txt +1 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/cli.py +4 -7
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/compiler/page.py +13 -6
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/emitter/xhtml.py +56 -37
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/publisher/changelog.py +20 -9
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/publisher/client.py +40 -16
- mkdocs2confluence-0.20.5/src/mkdocs_to_confluence/publisher/digest.py +42 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/publisher/executor.py +36 -26
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/publisher/models.py +1 -1
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/publisher/planner.py +38 -14
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_admonition_titles.py +13 -24
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_changelog_publish.py +25 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_extra_css.py +32 -23
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_publish_client.py +46 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_publish_pipeline.py +133 -25
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/LICENSE +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/setup.cfg +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs2confluence.egg-info/dependency_links.txt +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs2confluence.egg-info/entry_points.txt +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs2confluence.egg-info/requires.txt +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs2confluence.egg-info/top_level.txt +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/__init__.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/compiler/__init__.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/compiler/models.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/emitter/__init__.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/ir/__init__.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/ir/nodes.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/ir/treeutil.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/loader/__init__.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/loader/config.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/loader/extra_css.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/loader/nav.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/loader/page.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/parser/__init__.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/parser/markdown.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/pdf/__init__.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/pdf/generator.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/pdf/render.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/preprocess/__init__.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/preprocess/abbrevs.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/preprocess/captions.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/preprocess/fence.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/preprocess/frontmatter.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/preprocess/icons.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/preprocess/includes.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/preprocess/linkdefs.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/preview/__init__.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/preview/render.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/preview/server.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/publisher/__init__.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/publisher/http_retry.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/skill_installer.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/skills/mkdocs-changelog/SKILL.md +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/skills/mkdocs-changelog/scripts/changelog_data.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/sync/__init__.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/sync/anchoring.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/sync/command.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/sync/comments.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/sync/github.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/sync/platform.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/sync/state.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/transforms/__init__.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/transforms/_kroki.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/transforms/abbrevs.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/transforms/admonition_titles.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/transforms/assets.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/transforms/attachment_previews.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/transforms/captions.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/transforms/editlink.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/transforms/footer.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/transforms/images.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/transforms/internallinks.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/transforms/mermaid.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/transforms/plantuml.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_abbrevs.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_attachment_previews.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_captions.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_changelog_config.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_children_macro.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_cli.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_editlink.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_emitter.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_exclude_properties_config.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_footer.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_frontmatter.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_icons.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_images.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_internallinks.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_ir.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_linkdefs.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_loader.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_mermaid.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_page_loader.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_parser.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_pdf.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_plantuml.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_preprocess.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_preview.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_publish_config.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_server.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_skill_installer.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_sync_anchoring.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_sync_command.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_sync_comments.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_sync_github.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_sync_state.py +0 -0
- {mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/tests/test_treeutil.py +0 -0
{mkdocs2confluence-0.20.3/src/mkdocs2confluence.egg-info → mkdocs2confluence-0.20.5}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs2confluence
|
|
3
|
-
Version: 0.20.
|
|
3
|
+
Version: 0.20.5
|
|
4
4
|
Summary: Publish MkDocs Material pages to Confluence Cloud — admonitions, Mermaid diagrams, tabs, page properties and more
|
|
5
5
|
Author: Anders Hybertz
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -109,6 +109,11 @@ on:
|
|
|
109
109
|
branches: [main]
|
|
110
110
|
paths: ['docs/**', 'mkdocs.yml']
|
|
111
111
|
|
|
112
|
+
# One publish at a time: overlapping runs can race to create the same page.
|
|
113
|
+
concurrency:
|
|
114
|
+
group: confluence-publish
|
|
115
|
+
cancel-in-progress: false
|
|
116
|
+
|
|
112
117
|
jobs:
|
|
113
118
|
publish:
|
|
114
119
|
runs-on: ubuntu-latest
|
|
@@ -66,6 +66,11 @@ on:
|
|
|
66
66
|
branches: [main]
|
|
67
67
|
paths: ['docs/**', 'mkdocs.yml']
|
|
68
68
|
|
|
69
|
+
# One publish at a time: overlapping runs can race to create the same page.
|
|
70
|
+
concurrency:
|
|
71
|
+
group: confluence-publish
|
|
72
|
+
cancel-in-progress: false
|
|
73
|
+
|
|
69
74
|
jobs:
|
|
70
75
|
publish:
|
|
71
76
|
runs-on: ubuntu-latest
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mkdocs2confluence"
|
|
3
|
-
version = "0.20.
|
|
3
|
+
version = "0.20.5"
|
|
4
4
|
description = "Publish MkDocs Material pages to Confluence Cloud — admonitions, Mermaid diagrams, tabs, page properties and more"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = { text = "GPL-3.0-or-later" }
|
{mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5/src/mkdocs2confluence.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs2confluence
|
|
3
|
-
Version: 0.20.
|
|
3
|
+
Version: 0.20.5
|
|
4
4
|
Summary: Publish MkDocs Material pages to Confluence Cloud — admonitions, Mermaid diagrams, tabs, page properties and more
|
|
5
5
|
Author: Anders Hybertz
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -109,6 +109,11 @@ on:
|
|
|
109
109
|
branches: [main]
|
|
110
110
|
paths: ['docs/**', 'mkdocs.yml']
|
|
111
111
|
|
|
112
|
+
# One publish at a time: overlapping runs can race to create the same page.
|
|
113
|
+
concurrency:
|
|
114
|
+
group: confluence-publish
|
|
115
|
+
cancel-in-progress: false
|
|
116
|
+
|
|
112
117
|
jobs:
|
|
113
118
|
publish:
|
|
114
119
|
runs-on: ubuntu-latest
|
{mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs2confluence.egg-info/SOURCES.txt
RENAMED
|
@@ -42,6 +42,7 @@ src/mkdocs_to_confluence/preview/server.py
|
|
|
42
42
|
src/mkdocs_to_confluence/publisher/__init__.py
|
|
43
43
|
src/mkdocs_to_confluence/publisher/changelog.py
|
|
44
44
|
src/mkdocs_to_confluence/publisher/client.py
|
|
45
|
+
src/mkdocs_to_confluence/publisher/digest.py
|
|
45
46
|
src/mkdocs_to_confluence/publisher/executor.py
|
|
46
47
|
src/mkdocs_to_confluence/publisher/http_retry.py
|
|
47
48
|
src/mkdocs_to_confluence/publisher/models.py
|
|
@@ -10,7 +10,7 @@ from pathlib import Path
|
|
|
10
10
|
|
|
11
11
|
from mkdocs_to_confluence import __version__
|
|
12
12
|
from mkdocs_to_confluence.compiler.page import compile_page
|
|
13
|
-
from mkdocs_to_confluence.emitter.xhtml import
|
|
13
|
+
from mkdocs_to_confluence.emitter.xhtml import warn_unknown_admonition_kinds
|
|
14
14
|
from mkdocs_to_confluence.loader.config import load_config
|
|
15
15
|
from mkdocs_to_confluence.loader.nav import find_section, find_section_by_folder, flat_pages, resolve_nav
|
|
16
16
|
from mkdocs_to_confluence.loader.page import PageLoadError, find_page
|
|
@@ -339,8 +339,7 @@ def _parse_out_path(out_arg: str | None) -> tuple[Path, str]:
|
|
|
339
339
|
def _cmd_preview(args: argparse.Namespace) -> None:
|
|
340
340
|
config_path = Path(args.config).resolve()
|
|
341
341
|
config = load_config(config_path)
|
|
342
|
-
|
|
343
|
-
configure_admonitions(config.confluence.admonitions if config.confluence else None)
|
|
342
|
+
warn_unknown_admonition_kinds(config.confluence.admonitions if config.confluence else {})
|
|
344
343
|
|
|
345
344
|
all_nodes = resolve_nav(config)
|
|
346
345
|
|
|
@@ -495,8 +494,7 @@ def _cmd_preview(args: argparse.Namespace) -> None:
|
|
|
495
494
|
def _cmd_publish(args: argparse.Namespace) -> None:
|
|
496
495
|
config_path = Path(args.config).resolve()
|
|
497
496
|
config = load_config(config_path)
|
|
498
|
-
|
|
499
|
-
configure_admonitions(config.confluence.admonitions if config.confluence else None)
|
|
497
|
+
warn_unknown_admonition_kinds(config.confluence.admonitions if config.confluence else {})
|
|
500
498
|
|
|
501
499
|
conf_config = config.confluence
|
|
502
500
|
if conf_config is None:
|
|
@@ -688,8 +686,7 @@ def _cmd_pdf(args: argparse.Namespace) -> None:
|
|
|
688
686
|
|
|
689
687
|
config_path = Path(args.config).resolve()
|
|
690
688
|
config = load_config(config_path)
|
|
691
|
-
|
|
692
|
-
configure_admonitions(config.confluence.admonitions if config.confluence else None)
|
|
689
|
+
warn_unknown_admonition_kinds(config.confluence.admonitions if config.confluence else {})
|
|
693
690
|
|
|
694
691
|
nodes = resolve_nav(config)
|
|
695
692
|
|
{mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/compiler/page.py
RENAMED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from mkdocs_to_confluence.compiler.models import CompileResult
|
|
6
|
-
from mkdocs_to_confluence.emitter.xhtml import emit
|
|
6
|
+
from mkdocs_to_confluence.emitter.xhtml import EmitOptions, emit
|
|
7
7
|
from mkdocs_to_confluence.ir.nodes import ChildrenMacro, FrontMatter, SourceFooter
|
|
8
8
|
from mkdocs_to_confluence.loader.config import MkDocsConfig
|
|
9
9
|
from mkdocs_to_confluence.loader.nav import NavNode
|
|
10
|
-
from mkdocs_to_confluence.loader.page import load_page
|
|
10
|
+
from mkdocs_to_confluence.loader.page import PageLoadError, load_page
|
|
11
11
|
from mkdocs_to_confluence.parser.markdown import parse, parse_inline
|
|
12
12
|
from mkdocs_to_confluence.preprocess.abbrevs import (
|
|
13
13
|
extract_abbreviations,
|
|
@@ -52,10 +52,11 @@ def compile_page(
|
|
|
52
52
|
quiet: bool = False,
|
|
53
53
|
) -> CompileResult:
|
|
54
54
|
"""Run the full compile pipeline for one page and return a typed result."""
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
# load_page raises PageLoadError for a nav entry whose file is missing;
|
|
56
|
+
# never compile it to an empty body, which would blank the published page.
|
|
58
57
|
raw = load_page(node)
|
|
58
|
+
if node.source_path is None: # unreachable after load_page; narrows the type
|
|
59
|
+
raise PageLoadError(f"Cannot load page '{node.title}': no source file.")
|
|
59
60
|
|
|
60
61
|
preprocessed = preprocess_includes(
|
|
61
62
|
raw,
|
|
@@ -128,7 +129,13 @@ def compile_page(
|
|
|
128
129
|
version_message = f"{node_item.commit_sha}: {node_item.commit_summary}"
|
|
129
130
|
|
|
130
131
|
return CompileResult(
|
|
131
|
-
xhtml=emit(
|
|
132
|
+
xhtml=emit(
|
|
133
|
+
ir_nodes,
|
|
134
|
+
EmitOptions(
|
|
135
|
+
styles=config.extra_styles,
|
|
136
|
+
admonition_aliases=config.confluence.admonitions if config.confluence else {},
|
|
137
|
+
),
|
|
138
|
+
),
|
|
132
139
|
attachments=attachments,
|
|
133
140
|
labels=labels,
|
|
134
141
|
confluence_status=confluence_status,
|
{mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/emitter/xhtml.py
RENAMED
|
@@ -18,8 +18,10 @@ from __future__ import annotations
|
|
|
18
18
|
|
|
19
19
|
import html
|
|
20
20
|
import sys
|
|
21
|
+
from collections.abc import Mapping, Sequence
|
|
22
|
+
from contextvars import ContextVar
|
|
23
|
+
from dataclasses import dataclass, field
|
|
21
24
|
from pathlib import Path
|
|
22
|
-
from typing import Sequence
|
|
23
25
|
|
|
24
26
|
from mkdocs_to_confluence.ir.nodes import (
|
|
25
27
|
AbbrevFootnoteNode,
|
|
@@ -68,34 +70,41 @@ from mkdocs_to_confluence.ir.nodes import (
|
|
|
68
70
|
)
|
|
69
71
|
from mkdocs_to_confluence.loader.extra_css import ExtraStyles, styles_to_attr
|
|
70
72
|
|
|
71
|
-
# ──
|
|
73
|
+
# ── Emit options (config-driven, scoped to one emit() call) ────────────────────
|
|
72
74
|
|
|
73
|
-
_styles: ExtraStyles | None = None
|
|
74
75
|
|
|
76
|
+
@dataclass(frozen=True)
|
|
77
|
+
class EmitOptions:
|
|
78
|
+
"""Config-driven settings the emitter applies to a page.
|
|
79
|
+
|
|
80
|
+
Attributes:
|
|
81
|
+
styles: Extra-CSS styles inlined into headings, table cells and inline code.
|
|
82
|
+
admonition_aliases: Custom admonition kinds mapped onto built-in ones,
|
|
83
|
+
from ``confluence.admonitions``.
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
styles: ExtraStyles | None = None
|
|
87
|
+
admonition_aliases: Mapping[str, str] = field(default_factory=dict)
|
|
75
88
|
|
|
76
|
-
def configure_styles(styles: ExtraStyles | None) -> None:
|
|
77
|
-
"""Set the module-level extra-CSS styles used during emit."""
|
|
78
|
-
global _styles
|
|
79
|
-
_styles = styles
|
|
80
89
|
|
|
90
|
+
_DEFAULT_OPTIONS = EmitOptions()
|
|
81
91
|
|
|
82
|
-
#
|
|
92
|
+
# The options of the emit() call in progress. Only emit() sets it, and it resets
|
|
93
|
+
# it when it returns, so no setting outlives the call that passed it.
|
|
94
|
+
_current_options: ContextVar[EmitOptions | None] = ContextVar("_current_options", default=None)
|
|
83
95
|
|
|
84
|
-
_admonition_aliases: dict[str, str] = {}
|
|
85
96
|
|
|
97
|
+
def _options() -> EmitOptions:
|
|
98
|
+
return _current_options.get() or _DEFAULT_OPTIONS
|
|
86
99
|
|
|
87
|
-
def configure_admonitions(aliases: dict[str, str] | None) -> None:
|
|
88
|
-
"""Map custom admonition kinds onto built-in ones, from ``confluence.admonitions``.
|
|
89
100
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
101
|
+
def warn_unknown_admonition_kinds(aliases: Mapping[str, str]) -> None:
|
|
102
|
+
"""Warn about ``confluence.admonitions`` targets that name no built-in kind.
|
|
103
|
+
|
|
104
|
+
Such targets are kept: they resolve through the same fallback as any
|
|
105
|
+
unknown kind, so a typo degrades rather than fails the build.
|
|
93
106
|
"""
|
|
94
|
-
|
|
95
|
-
_admonition_aliases = dict(aliases or {})
|
|
96
|
-
unknown = sorted(
|
|
97
|
-
f"{k} -> {v}" for k, v in _admonition_aliases.items() if v not in _KNOWN_ADMONITION_KINDS
|
|
98
|
-
)
|
|
107
|
+
unknown = sorted(f"{k} -> {v}" for k, v in aliases.items() if v not in _KNOWN_ADMONITION_KINDS)
|
|
99
108
|
if unknown:
|
|
100
109
|
print(
|
|
101
110
|
"warning: confluence.admonitions targets an unknown admonition kind: "
|
|
@@ -104,6 +113,7 @@ def configure_admonitions(aliases: dict[str, str] | None) -> None:
|
|
|
104
113
|
file=sys.stderr,
|
|
105
114
|
)
|
|
106
115
|
|
|
116
|
+
|
|
107
117
|
# ── Admonition kind → Confluence macro name ───────────────────────────────────
|
|
108
118
|
|
|
109
119
|
# Types that map to Confluence's four native panel macros (include built-in icons).
|
|
@@ -176,20 +186,26 @@ _DEFAULT_ADMONITION_TITLES: dict[str, str] = {
|
|
|
176
186
|
# ── Public API ─────────────────────────────────────────────────────────────────
|
|
177
187
|
|
|
178
188
|
|
|
179
|
-
def emit(nodes: Sequence[IRNode]) -> str:
|
|
189
|
+
def emit(nodes: Sequence[IRNode], options: EmitOptions | None = None) -> str:
|
|
180
190
|
"""Convert a sequence of top-level IR nodes to Confluence storage XHTML.
|
|
181
191
|
|
|
182
192
|
Args:
|
|
183
193
|
nodes: Top-level IR nodes as returned by the parser.
|
|
194
|
+
options: Config-driven settings for this page; defaults apply none.
|
|
184
195
|
|
|
185
196
|
Returns:
|
|
186
197
|
A UTF-8 string of valid Confluence storage format XML, without an XML
|
|
187
198
|
declaration (Confluence expects the body fragment only).
|
|
188
199
|
"""
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
200
|
+
token = _current_options.set(options or _DEFAULT_OPTIONS)
|
|
201
|
+
try:
|
|
202
|
+
return _emit_blocks(nodes)
|
|
203
|
+
finally:
|
|
204
|
+
_current_options.reset(token)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def _emit_blocks(nodes: Sequence[IRNode]) -> str:
|
|
208
|
+
return "".join(_emit_node(node) for node in nodes)
|
|
193
209
|
|
|
194
210
|
|
|
195
211
|
# ── Node dispatch ─────────────────────────────────────────────────────────────
|
|
@@ -251,8 +267,9 @@ def _emit_section(node: Section) -> str:
|
|
|
251
267
|
tag = f"h{node.level}"
|
|
252
268
|
title_html = _emit_inlines(node.title)
|
|
253
269
|
style_attr = ""
|
|
254
|
-
|
|
255
|
-
|
|
270
|
+
styles = _options().styles
|
|
271
|
+
if styles:
|
|
272
|
+
style_attr = styles_to_attr(styles.headings.get(f"h{node.level}", {}))
|
|
256
273
|
anchor = ""
|
|
257
274
|
# Emit an anchor macro for every heading so links resolve to the section.
|
|
258
275
|
# Confluence's auto heading-anchors use a different naming scheme than the
|
|
@@ -262,7 +279,7 @@ def _emit_section(node: Section) -> str:
|
|
|
262
279
|
if name:
|
|
263
280
|
anchor = _anchor_macro(name)
|
|
264
281
|
heading = f"{anchor}<{tag}{style_attr}>{title_html}</{tag}>\n"
|
|
265
|
-
body =
|
|
282
|
+
body = _emit_blocks(node.children)
|
|
266
283
|
return heading + body
|
|
267
284
|
|
|
268
285
|
|
|
@@ -398,7 +415,7 @@ def _resolve_admonition_kind(kind: str) -> str:
|
|
|
398
415
|
Order: an explicit ``confluence.admonitions`` alias, then the built-in kinds,
|
|
399
416
|
then ``success`` for anything unrecognised.
|
|
400
417
|
"""
|
|
401
|
-
alias =
|
|
418
|
+
alias = _options().admonition_aliases.get(kind)
|
|
402
419
|
if alias is not None:
|
|
403
420
|
return alias
|
|
404
421
|
if kind in _KNOWN_ADMONITION_KINDS:
|
|
@@ -411,7 +428,7 @@ def _emit_admonition(node: Admonition) -> str:
|
|
|
411
428
|
# follows the resolved kind.
|
|
412
429
|
title = node.title or _DEFAULT_ADMONITION_TITLES.get(node.kind, node.kind.capitalize())
|
|
413
430
|
kind = _resolve_admonition_kind(node.kind)
|
|
414
|
-
body =
|
|
431
|
+
body = _emit_blocks(node.children)
|
|
415
432
|
|
|
416
433
|
# ??? and ???+ → Confluence expand macro (collapsible)
|
|
417
434
|
# ???+ means "expanded by default" — Confluence expand has no such option,
|
|
@@ -511,7 +528,7 @@ def _emit_list_item(item: ListItem) -> str:
|
|
|
511
528
|
parts: list[str] = []
|
|
512
529
|
if first_block > 0:
|
|
513
530
|
parts.append(f"<p>{_emit_inlines(item.children[:first_block])}</p>\n")
|
|
514
|
-
parts.append(
|
|
531
|
+
parts.append(_emit_blocks(item.children[first_block:]))
|
|
515
532
|
return f" <li>{''.join(parts).strip()}</li>\n"
|
|
516
533
|
|
|
517
534
|
|
|
@@ -532,8 +549,9 @@ def _emit_table_row(row: TableRow, *, is_header: bool) -> str:
|
|
|
532
549
|
def _emit_table_cell(cell: TableCell, *, force_header: bool) -> str:
|
|
533
550
|
tag = "th" if (cell.is_header or force_header) else "td"
|
|
534
551
|
props: dict[str, str] = {}
|
|
535
|
-
|
|
536
|
-
|
|
552
|
+
styles = _options().styles
|
|
553
|
+
if styles:
|
|
554
|
+
props = dict(styles.th if tag == "th" else styles.td)
|
|
537
555
|
if cell.align:
|
|
538
556
|
props["text-align"] = cell.align
|
|
539
557
|
style_attr = styles_to_attr(props)
|
|
@@ -542,7 +560,7 @@ def _emit_table_cell(cell: TableCell, *, force_header: bool) -> str:
|
|
|
542
560
|
|
|
543
561
|
|
|
544
562
|
def _emit_blockquote(node: BlockQuote) -> str:
|
|
545
|
-
body =
|
|
563
|
+
body = _emit_blocks(node.children)
|
|
546
564
|
return f"<blockquote>\n{body}</blockquote>\n"
|
|
547
565
|
|
|
548
566
|
|
|
@@ -597,7 +615,7 @@ def _emit_content_tabs(node: ContentTabs) -> str:
|
|
|
597
615
|
# Degrade to a series of expand macros (one per tab)
|
|
598
616
|
parts: list[str] = []
|
|
599
617
|
for tab in node.tabs:
|
|
600
|
-
body =
|
|
618
|
+
body = _emit_blocks(tab.children)
|
|
601
619
|
parts.append(
|
|
602
620
|
'<ac:structured-macro ac:name="expand">\n'
|
|
603
621
|
f' <ac:parameter ac:name="title">{html.escape(tab.label)}</ac:parameter>\n'
|
|
@@ -608,7 +626,7 @@ def _emit_content_tabs(node: ContentTabs) -> str:
|
|
|
608
626
|
|
|
609
627
|
|
|
610
628
|
def _emit_expandable(node: Expandable) -> str:
|
|
611
|
-
body =
|
|
629
|
+
body = _emit_blocks(node.children)
|
|
612
630
|
return (
|
|
613
631
|
'<ac:structured-macro ac:name="expand">\n'
|
|
614
632
|
f' <ac:parameter ac:name="title">{html.escape(node.title)}</ac:parameter>\n'
|
|
@@ -652,7 +670,7 @@ def _emit_grid_cards(node: GridCards) -> str:
|
|
|
652
670
|
parts.append(f' <ac:layout-section ac:type="{layout_type}">\n')
|
|
653
671
|
for card_nodes in row:
|
|
654
672
|
parts.append(" <ac:layout-cell>\n")
|
|
655
|
-
parts.append(
|
|
673
|
+
parts.append(_emit_blocks(card_nodes))
|
|
656
674
|
parts.append(" </ac:layout-cell>\n")
|
|
657
675
|
# Pad last row with empty cells if needed.
|
|
658
676
|
for _ in range(cols - len(row)):
|
|
@@ -760,7 +778,8 @@ def _emit_inline(node: IRNode) -> str:
|
|
|
760
778
|
if isinstance(node, InsertNode):
|
|
761
779
|
return f"<u>{_emit_inlines(node.children)}</u>"
|
|
762
780
|
if isinstance(node, CodeInlineNode):
|
|
763
|
-
|
|
781
|
+
styles = _options().styles
|
|
782
|
+
style_attr = styles_to_attr(styles.code_inline) if styles else ""
|
|
764
783
|
return f"<code{style_attr}>{html.escape(node.code)}</code>"
|
|
765
784
|
if isinstance(node, LinkNode):
|
|
766
785
|
return _emit_link(node)
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import hashlib
|
|
6
5
|
import sys
|
|
7
6
|
from pathlib import Path
|
|
8
7
|
from typing import TYPE_CHECKING
|
|
@@ -12,6 +11,7 @@ import yaml
|
|
|
12
11
|
from mkdocs_to_confluence.compiler.page import compile_page
|
|
13
12
|
from mkdocs_to_confluence.loader.nav import NavNode
|
|
14
13
|
from mkdocs_to_confluence.preprocess.frontmatter import _FRONT_MATTER_RE
|
|
14
|
+
from mkdocs_to_confluence.publisher.digest import page_content_hash
|
|
15
15
|
from mkdocs_to_confluence.publisher.executor import upload_assets
|
|
16
16
|
|
|
17
17
|
if TYPE_CHECKING:
|
|
@@ -74,10 +74,14 @@ def publish_changelog(
|
|
|
74
74
|
|
|
75
75
|
result = compile_page(node, config, link_map or {}, quiet=quiet)
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
content_hash = page_content_hash(result.xhtml, result.attachments, config.docs_dir)
|
|
78
78
|
existing = client.find_page(space_id, title)
|
|
79
79
|
|
|
80
|
-
if
|
|
80
|
+
if (
|
|
81
|
+
existing is not None
|
|
82
|
+
and content_hash is not None
|
|
83
|
+
and client.get_content_hash(str(existing["id"])) == content_hash
|
|
84
|
+
):
|
|
81
85
|
if not quiet:
|
|
82
86
|
print(f" unchanged '{title}' (changelog)")
|
|
83
87
|
return
|
|
@@ -102,15 +106,22 @@ def publish_changelog(
|
|
|
102
106
|
if not quiet:
|
|
103
107
|
print(f" updated '{title}' (changelog)")
|
|
104
108
|
|
|
109
|
+
asset_errors: list[tuple[str, str]] = []
|
|
105
110
|
if result.attachments:
|
|
106
|
-
|
|
111
|
+
_, _, asset_errors = upload_assets(
|
|
112
|
+
page_id, result.attachments, config.docs_dir, client, quiet=quiet
|
|
113
|
+
)
|
|
114
|
+
for name, msg in asset_errors:
|
|
115
|
+
print(f" [warn] changelog: could not upload {name}: {msg}", file=sys.stderr)
|
|
107
116
|
|
|
108
117
|
# content hash is an internal optimization; if it fails the next run just
|
|
109
|
-
# re-publishes, so a failure is self-healing and stays silent.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
# re-publishes, so a failure is self-healing and stays silent. After a failed
|
|
119
|
+
# upload it is not stored, so the next run retries the attachment.
|
|
120
|
+
if content_hash is not None and not asset_errors:
|
|
121
|
+
try:
|
|
122
|
+
client.set_content_hash(page_id, content_hash)
|
|
123
|
+
except Exception:
|
|
124
|
+
pass # non-fatal
|
|
114
125
|
|
|
115
126
|
# labels / full-width / status are user-configured presentation. They must
|
|
116
127
|
# never fail an already-saved page (catch broadly so a transient network
|
{mkdocs2confluence-0.20.3 → mkdocs2confluence-0.20.5}/src/mkdocs_to_confluence/publisher/client.py
RENAMED
|
@@ -21,6 +21,10 @@ from mkdocs_to_confluence.publisher.http_retry import ConfluenceError, http_requ
|
|
|
21
21
|
__all__ = ["ConfluenceClient", "ConfluenceError"]
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
_CONTENT_HASH_KEY = "mk2conf-content-hash"
|
|
25
|
+
_ATTACHMENT_HASHES_KEY = "mk2conf-attachment-hashes"
|
|
26
|
+
|
|
27
|
+
|
|
24
28
|
def _extract_cursor(next_url: str) -> str:
|
|
25
29
|
"""Extract the ``cursor`` query parameter from a pagination ``next`` URL."""
|
|
26
30
|
qs = parse_qs(urlparse(next_url).query)
|
|
@@ -303,14 +307,18 @@ class ConfluenceClient:
|
|
|
303
307
|
|
|
304
308
|
Uses the v1 ``content-appearance-published`` property. Creates the
|
|
305
309
|
property if it does not exist; updates it (with correct version bump)
|
|
306
|
-
when it already
|
|
310
|
+
when it holds another value; writes nothing when the page is already
|
|
311
|
+
full-width.
|
|
307
312
|
"""
|
|
308
313
|
key = "content-appearance-published"
|
|
309
314
|
prop_url = self._v1(f"/content/{page_id}/property/{key}")
|
|
310
315
|
get_resp = self._get(prop_url)
|
|
311
316
|
|
|
312
317
|
if get_resp.status_code == 200:
|
|
313
|
-
|
|
318
|
+
prop = get_resp.json()
|
|
319
|
+
if prop.get("value") == "full-width":
|
|
320
|
+
return
|
|
321
|
+
current_version = prop.get("version", {}).get("number", 1)
|
|
314
322
|
http_request_with_retry(
|
|
315
323
|
lambda: self._http.put(
|
|
316
324
|
prop_url,
|
|
@@ -333,21 +341,37 @@ class ConfluenceClient:
|
|
|
333
341
|
Returns ``None`` on any error (property absent, API failure) so callers
|
|
334
342
|
can safely treat a missing hash as "unknown — must update".
|
|
335
343
|
"""
|
|
336
|
-
|
|
337
|
-
resp = self._get(url)
|
|
338
|
-
if resp.is_error:
|
|
339
|
-
return None
|
|
340
|
-
value = resp.json().get("value", "")
|
|
344
|
+
value = self._get_property_value(page_id, _CONTENT_HASH_KEY)
|
|
341
345
|
return str(value) if value else None
|
|
342
346
|
|
|
343
347
|
def set_content_hash(self, page_id: str, hash_str: str) -> None:
|
|
344
|
-
"""Store *hash_str* as the mk2conf content hash property on *page_id*.
|
|
348
|
+
"""Store *hash_str* as the mk2conf content hash property on *page_id*."""
|
|
349
|
+
self._set_property_value(page_id, _CONTENT_HASH_KEY, hash_str, "set_content_hash")
|
|
350
|
+
|
|
351
|
+
def get_attachment_hashes(self, page_id: str) -> dict[str, str]:
|
|
352
|
+
"""Return the stored ``{attachment name: sha256}`` map for *page_id*.
|
|
345
353
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
optimisation and must never block a publish.
|
|
354
|
+
Returns an empty map on any error, so every attachment counts as
|
|
355
|
+
changed and is uploaded.
|
|
349
356
|
"""
|
|
350
|
-
|
|
357
|
+
value = self._get_property_value(page_id, _ATTACHMENT_HASHES_KEY)
|
|
358
|
+
if not isinstance(value, dict):
|
|
359
|
+
return {}
|
|
360
|
+
return {str(name): str(digest) for name, digest in value.items()}
|
|
361
|
+
|
|
362
|
+
def set_attachment_hashes(self, page_id: str, hashes: dict[str, str]) -> None:
|
|
363
|
+
"""Store the ``{attachment name: sha256}`` map for *page_id*."""
|
|
364
|
+
self._set_property_value(page_id, _ATTACHMENT_HASHES_KEY, hashes, "set_attachment_hashes")
|
|
365
|
+
|
|
366
|
+
def _get_property_value(self, page_id: str, key: str) -> Any:
|
|
367
|
+
"""Return the value of content property *key* on *page_id*, or ``None`` on any error."""
|
|
368
|
+
resp = self._get(self._v1(f"/content/{page_id}/property/{key}"))
|
|
369
|
+
if resp.is_error:
|
|
370
|
+
return None
|
|
371
|
+
return resp.json().get("value")
|
|
372
|
+
|
|
373
|
+
def _set_property_value(self, page_id: str, key: str, value: Any, context: str) -> None:
|
|
374
|
+
"""Create content property *key* on *page_id*, or update it with a version bump."""
|
|
351
375
|
prop_url = self._v1(f"/content/{page_id}/property/{key}")
|
|
352
376
|
get_resp = self._get(prop_url)
|
|
353
377
|
if get_resp.status_code == 200:
|
|
@@ -355,17 +379,17 @@ class ConfluenceClient:
|
|
|
355
379
|
http_request_with_retry(
|
|
356
380
|
lambda: self._http.put(
|
|
357
381
|
prop_url,
|
|
358
|
-
json={"key": key, "value":
|
|
382
|
+
json={"key": key, "value": value, "version": {"number": current_version + 1}},
|
|
359
383
|
),
|
|
360
|
-
|
|
384
|
+
context,
|
|
361
385
|
)
|
|
362
386
|
else:
|
|
363
387
|
http_request_with_retry(
|
|
364
388
|
lambda: self._http.post(
|
|
365
389
|
self._v1(f"/content/{page_id}/property"),
|
|
366
|
-
json={"key": key, "value":
|
|
390
|
+
json={"key": key, "value": value, "version": {"number": 1}},
|
|
367
391
|
),
|
|
368
|
-
|
|
392
|
+
context,
|
|
369
393
|
)
|
|
370
394
|
|
|
371
395
|
def set_page_labels(self, page_id: str, labels: tuple[str, ...]) -> None:
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Content digests that decide whether a page or an attachment must be republished."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import hashlib
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from mkdocs_to_confluence.transforms.assets import make_attachment_name
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def file_digest(path: Path) -> str:
|
|
12
|
+
"""Return the SHA-256 hex digest of the bytes in *path*.
|
|
13
|
+
|
|
14
|
+
Raises
|
|
15
|
+
------
|
|
16
|
+
OSError
|
|
17
|
+
If *path* cannot be read.
|
|
18
|
+
"""
|
|
19
|
+
with path.open("rb") as fh:
|
|
20
|
+
return hashlib.file_digest(fh, "sha256").hexdigest()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def page_content_hash(xhtml: str, attachments: list[Path], docs_dir: Path) -> str | None:
|
|
24
|
+
"""Return the hash that says whether a page, attachments included, has changed.
|
|
25
|
+
|
|
26
|
+
A page without attachments hashes its XHTML alone. With attachments, each
|
|
27
|
+
one's name and content digest are folded in, so a changed file changes the
|
|
28
|
+
hash even when the XHTML that references it does not.
|
|
29
|
+
|
|
30
|
+
Returns ``None`` when an attachment cannot be read: an unknown hash never
|
|
31
|
+
matches the stored one, so the page is published.
|
|
32
|
+
"""
|
|
33
|
+
digest = hashlib.sha256(xhtml.encode())
|
|
34
|
+
if not attachments:
|
|
35
|
+
return digest.hexdigest()
|
|
36
|
+
try:
|
|
37
|
+
entries = sorted((make_attachment_name(p, docs_dir), file_digest(p)) for p in attachments)
|
|
38
|
+
except OSError:
|
|
39
|
+
return None
|
|
40
|
+
for name, file_hash in entries:
|
|
41
|
+
digest.update(f"\0{name}\0{file_hash}".encode())
|
|
42
|
+
return digest.hexdigest()
|