mkdocs_to_confluence.plugin¶
MkDocs plugin for publishing to Confluence.
BearerAuth ¶
Bases: AuthBase
Attaches OAuth Bearer Token Authentication to the given Request object.
Store the OAuth bearer token used for authentication.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
OAuth access token issued by Atlassian. |
required |
Source code in src/mkdocs_to_confluence/plugin.py
DummyFile ¶
MkdocsWithConfluence ¶
Bases: BasePlugin
MkDocs plugin to publish documentation to Confluence.
Initialize plugin with default settings.
Source code in src/mkdocs_to_confluence/plugin.py
on_nav ¶
Build navigation structure from MkDocs nav.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nav
|
Navigation
|
Navigation object produced by MkDocs. |
required |
config
|
Config
|
Active MkDocs configuration. |
required |
files
|
Files
|
Collection of files included in the build. |
required |
Source code in src/mkdocs_to_confluence/plugin.py
on_files ¶
Count documentation pages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
Files
|
Files selected for the build. |
required |
config
|
Config
|
Active MkDocs configuration. |
required |
Source code in src/mkdocs_to_confluence/plugin.py
on_config ¶
Configure plugin based on environment and settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Config
|
Active MkDocs configuration being initialized. |
required |
Source code in src/mkdocs_to_confluence/plugin.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | |
on_page_markdown ¶
Process markdown content and publish to Confluence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
markdown
|
str
|
Markdown generated by MkDocs for the current page. |
required |
page
|
Page
|
Page metadata within the nav tree. |
required |
config
|
Config
|
Active MkDocs configuration. |
required |
files
|
Files
|
Collection of build file objects. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Markdown that MkDocs should continue to render or return if syncing fails. |
Source code in src/mkdocs_to_confluence/plugin.py
863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 | |
on_post_page ¶
Upload attachments after page is rendered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
Rendered HTML for the page. |
required |
page
|
Page
|
Page metadata used for lookup. |
required |
config
|
Config
|
Active MkDocs configuration. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Rendered HTML that MkDocs should write to disk. |
Source code in src/mkdocs_to_confluence/plugin.py
on_page_content ¶
Process HTML content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
Rendered HTML output. |
required |
page
|
Page
|
Page metadata. |
required |
config
|
Config
|
Active MkDocs configuration. |
required |
files
|
Files
|
Collection of build file objects. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
HTML passed through without modification. |
Source code in src/mkdocs_to_confluence/plugin.py
on_post_build ¶
Export all queued pages and handle orphaned pages after build completes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Config
|
Active MkDocs configuration. |
required |
Source code in src/mkdocs_to_confluence/plugin.py
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 | |
get_file_sha1 ¶
Calculate SHA1 hash of file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str or Path
|
Path to the file on disk. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Hexadecimal SHA1 digest used to tag attachment versions. |
Source code in src/mkdocs_to_confluence/plugin.py
add_or_update_attachment ¶
Add or update attachment on Confluence page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_name
|
str
|
Title of the page that owns the attachment. |
required |
filepath
|
str or Path
|
File to upload or compare against existing attachments. |
required |
Source code in src/mkdocs_to_confluence/plugin.py
get_attachment ¶
Get existing attachment from Confluence page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_id
|
str
|
Identifier of the Confluence page. |
required |
filepath
|
str or Path
|
Path whose filename should be matched remotely. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
dict or None: Attachment metadata when found, otherwise None. |
Source code in src/mkdocs_to_confluence/plugin.py
update_attachment ¶
Update existing attachment on Confluence page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_id
|
str
|
Identifier of the Confluence page. |
required |
filepath
|
str or Path
|
Local file whose contents replace the attachment. |
required |
existing_attachment
|
dict
|
Metadata returned from get_attachment. |
required |
message
|
str
|
Version comment displayed in Confluence history. |
required |
Source code in src/mkdocs_to_confluence/plugin.py
create_attachment ¶
Create new attachment on Confluence page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_id
|
str
|
Identifier of the Confluence page. |
required |
filepath
|
str or Path
|
Local file to upload as a new attachment. |
required |
message
|
str
|
Version comment displayed in Confluence history. |
required |
Source code in src/mkdocs_to_confluence/plugin.py
find_page_id ¶
Find Confluence page ID by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_name
|
str
|
Title of the page to locate. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str or None: Page identifier when found, otherwise None. |
Source code in src/mkdocs_to_confluence/plugin.py
get_page_content ¶
Fetch the current content of a page from Confluence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_id
|
str
|
The Confluence page ID |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str or None: The page content in storage format, or None if fetch failed |
Source code in src/mkdocs_to_confluence/plugin.py
add_page ¶
Create new page in Confluence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_name
|
str
|
Title for the new page. |
required |
parent_page_id
|
str
|
Identifier of the parent page. |
required |
page_content_in_storage_format
|
str
|
Body content in Confluence storage format. |
required |
Source code in src/mkdocs_to_confluence/plugin.py
update_page ¶
Update existing page in Confluence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_name
|
str
|
Title of the page to update. |
required |
page_content_in_storage_format
|
str
|
Body content in Confluence storage format. |
required |
Source code in src/mkdocs_to_confluence/plugin.py
find_page_version ¶
Find current version number of Confluence page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_name
|
str
|
Title of the page to inspect. |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
int or None: Latest version number, or None when the page is missing. |
Source code in src/mkdocs_to_confluence/plugin.py
find_parent_name_of_page ¶
Find parent page name of given Confluence page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Title of the page whose parent is requested. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str or None: Title of the direct parent page, or None when unavailable. |
Source code in src/mkdocs_to_confluence/plugin.py
get_all_child_pages ¶
Get all child pages recursively under a parent page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str
|
The ID of the parent page |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of page dictionaries with 'id' and 'title' keys |
Source code in src/mkdocs_to_confluence/plugin.py
add_page_labels ¶
Add labels to a Confluence page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_id
|
str
|
The ID of the page |
required |
labels
|
list[str]
|
List of label names to add |
required |
Source code in src/mkdocs_to_confluence/plugin.py
delete_page ¶
Delete a Confluence page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_id
|
str
|
The ID of the page to delete |
required |
Source code in src/mkdocs_to_confluence/plugin.py
wait_until ¶
wait_until(
condition: Callable[[], bool] | bool,
interval: float = 0.1,
timeout: int = 10,
max_retries: int = 3,
) -> bool
Wait until a condition is met, with retry mechanism.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
condition
|
Callable[[], bool] | bool
|
The condition to wait for (can be a boolean or callable) |
required |
interval
|
float
|
Time between checks in seconds |
0.1
|
timeout
|
int
|
Maximum time to wait in seconds |
10
|
max_retries
|
int
|
Maximum number of retries if condition is not met |
3
|
Returns:
| Type | Description |
|---|---|
bool
|
True if condition is met, False otherwise |
Source code in src/mkdocs_to_confluence/plugin.py
nostdout ¶
Temporarily silence sys.stdout within the managed context.