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_post_template ¶
Configure logging mode based on verbosity settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_content
|
str
|
Rendered output from MkDocs. |
required |
template_name
|
str
|
Name of the template used for rendering. |
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
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
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 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 | |
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
984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 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 | |
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.