markdown-to-confluence 0.1.10__tar.gz → 0.1.12__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.
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/LICENSE +1 -1
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/PKG-INFO +21 -16
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/README.md +13 -8
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/markdown_to_confluence.egg-info/PKG-INFO +21 -16
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/markdown_to_confluence.egg-info/SOURCES.txt +6 -1
- markdown_to_confluence-0.1.12/markdown_to_confluence.egg-info/entry_points.txt +2 -0
- markdown_to_confluence-0.1.12/markdown_to_confluence.egg-info/requires.txt +7 -0
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/md2conf/__init__.py +2 -2
- markdown_to_confluence-0.1.12/md2conf/__main__.py +140 -0
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/md2conf/api.py +166 -72
- markdown_to_confluence-0.1.12/md2conf/application.py +154 -0
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/md2conf/converter.py +91 -30
- markdown_to_confluence-0.1.12/md2conf/processor.py +91 -0
- markdown_to_confluence-0.1.12/md2conf/properties.py +52 -0
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/setup.cfg +15 -7
- markdown_to_confluence-0.1.12/tests/test_api.py +138 -0
- markdown_to_confluence-0.1.12/tests/test_conversion.py +58 -0
- markdown_to_confluence-0.1.12/tests/test_processor.py +64 -0
- markdown-to-confluence-0.1.10/markdown_to_confluence.egg-info/requires.txt +0 -7
- markdown-to-confluence-0.1.10/md2conf/__main__.py +0 -98
- markdown-to-confluence-0.1.10/md2conf/application.py +0 -104
- markdown-to-confluence-0.1.10/tests/test_api.py +0 -101
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/markdown_to_confluence.egg-info/dependency_links.txt +0 -0
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/markdown_to_confluence.egg-info/top_level.txt +0 -0
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/markdown_to_confluence.egg-info/zip-safe +0 -0
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/md2conf/entities.dtd +0 -0
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/md2conf/py.typed +0 -0
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/pyproject.toml +0 -0
- {markdown-to-confluence-0.1.10 → markdown_to_confluence-0.1.12}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: markdown-to-confluence
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.12
|
|
4
4
|
Summary: Publish Markdown files to Confluence wiki
|
|
5
5
|
Home-page: https://github.com/hunyadi/md2conf
|
|
6
6
|
Author: Levente Hunyadi
|
|
@@ -21,13 +21,13 @@ Classifier: Typing :: Typed
|
|
|
21
21
|
Requires-Python: >=3.8
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
License-File: LICENSE
|
|
24
|
-
Requires-Dist: lxml>=
|
|
25
|
-
Requires-Dist: types-lxml>=
|
|
26
|
-
Requires-Dist: markdown>=3.
|
|
27
|
-
Requires-Dist: types-markdown>=3.
|
|
28
|
-
Requires-Dist: pymdown-extensions>=10.
|
|
29
|
-
Requires-Dist: requests>=2.
|
|
30
|
-
Requires-Dist: types-requests>=2.
|
|
24
|
+
Requires-Dist: lxml>=5.2
|
|
25
|
+
Requires-Dist: types-lxml>=2024.4.14
|
|
26
|
+
Requires-Dist: markdown>=3.6
|
|
27
|
+
Requires-Dist: types-markdown>=3.6
|
|
28
|
+
Requires-Dist: pymdown-extensions>=10.8
|
|
29
|
+
Requires-Dist: requests>=2.32
|
|
30
|
+
Requires-Dist: types-requests>=2.32
|
|
31
31
|
|
|
32
32
|
# Publish Markdown files to Confluence wiki
|
|
33
33
|
|
|
@@ -36,6 +36,7 @@ Contributors to software projects typically write documentation in Markdown form
|
|
|
36
36
|
Replicating documentation to Confluence by hand is tedious, and a lack of automated synchronization with the project repositories where the documents live leads to outdated documentation.
|
|
37
37
|
|
|
38
38
|
This Python package
|
|
39
|
+
|
|
39
40
|
* parses Markdown files,
|
|
40
41
|
* converts Markdown content into the Confluence Storage Format (XHTML),
|
|
41
42
|
* invokes Confluence API endpoints to upload images and content.
|
|
@@ -54,6 +55,7 @@ This Python package
|
|
|
54
55
|
## Getting started
|
|
55
56
|
|
|
56
57
|
In order to get started, you will need
|
|
58
|
+
|
|
57
59
|
* your organization domain name (e.g. `instructure.atlassian.net`),
|
|
58
60
|
* base path for Confluence wiki (typically `/wiki/` for managed Confluence, `/` for on-premise)
|
|
59
61
|
* your Confluence username (e.g. `levente.hunyadi@instructure.com`) (only if required by your deployment),
|
|
@@ -62,7 +64,7 @@ In order to get started, you will need
|
|
|
62
64
|
|
|
63
65
|
### Obtaining an API token
|
|
64
66
|
|
|
65
|
-
1. Log in to https://id.atlassian.com/manage/api-tokens
|
|
67
|
+
1. Log in to <https://id.atlassian.com/manage/api-tokens>.
|
|
66
68
|
2. Click *Create API token*.
|
|
67
69
|
3. From the dialog that appears, enter a memorable and concise *Label* for your token and click *Create*.
|
|
68
70
|
4. Click *Copy to clipboard*, then paste the token to your script, or elsewhere to save.
|
|
@@ -70,6 +72,7 @@ In order to get started, you will need
|
|
|
70
72
|
### Setting up the environment
|
|
71
73
|
|
|
72
74
|
Confluence organization domain, base path, username, API token and space key can be specified at runtime or set as Confluence environment variables (e.g. add to your `~/.profile` on Linux, or `~/.bash_profile` or `~/.zshenv` on MacOS):
|
|
75
|
+
|
|
73
76
|
```bash
|
|
74
77
|
export CONFLUENCE_DOMAIN='instructure.atlassian.net'
|
|
75
78
|
export CONFLUENCE_PATH='/wiki/'
|
|
@@ -136,28 +139,30 @@ Use the `--help` switch to get a full list of supported command-line options:
|
|
|
136
139
|
|
|
137
140
|
```console
|
|
138
141
|
$ python3 -m md2conf --help
|
|
139
|
-
usage: md2conf [-h] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE]
|
|
140
|
-
[-
|
|
142
|
+
usage: md2conf [-h] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE] [-l {debug,info,warning,error,critical}] [-r ROOT_PAGE] [--generated-by GENERATED_BY]
|
|
143
|
+
[--no-generated-by] [--ignore-invalid-url] [--local]
|
|
141
144
|
mdpath
|
|
142
145
|
|
|
143
146
|
positional arguments:
|
|
144
147
|
mdpath Path to Markdown file or directory to convert and publish.
|
|
145
148
|
|
|
146
|
-
|
|
149
|
+
optional arguments:
|
|
147
150
|
-h, --help show this help message and exit
|
|
148
151
|
-d DOMAIN, --domain DOMAIN
|
|
149
152
|
Confluence organization domain.
|
|
150
|
-
-p PATH, --path PATH Base path for
|
|
153
|
+
-p PATH, --path PATH Base path for Confluence (default: '/wiki/').
|
|
151
154
|
-u USERNAME, --username USERNAME
|
|
152
155
|
Confluence user name.
|
|
153
156
|
-a APIKEY, --apikey APIKEY
|
|
154
157
|
Confluence API key. Refer to documentation how to obtain one.
|
|
155
158
|
-s SPACE, --space SPACE
|
|
156
|
-
Confluence space key for pages to be published. If omitted, will default to user
|
|
157
|
-
|
|
158
|
-
-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --loglevel {DEBUG,INFO,WARNING,ERROR,CRITICAL}
|
|
159
|
+
Confluence space key for pages to be published. If omitted, will default to user space.
|
|
160
|
+
-l {debug,info,warning,error,critical}, --loglevel {debug,info,warning,error,critical}
|
|
159
161
|
Use this option to set the log verbosity.
|
|
162
|
+
-r ROOT_PAGE Root Confluence page to create new pages. If omitted, will raise exception when creating new pages.
|
|
160
163
|
--generated-by GENERATED_BY
|
|
161
164
|
Add prompt to pages (default: 'This page has been generated with a tool.').
|
|
162
165
|
--no-generated-by Do not add 'generated by a tool' prompt to pages.
|
|
166
|
+
--ignore-invalid-url Emit a warning but otherwise ignore relative URLs that point to ill-specified locations.
|
|
167
|
+
--local Write XHTML-based Confluence Storage Format files locally without invoking Confluence API.
|
|
163
168
|
```
|
|
@@ -5,6 +5,7 @@ Contributors to software projects typically write documentation in Markdown form
|
|
|
5
5
|
Replicating documentation to Confluence by hand is tedious, and a lack of automated synchronization with the project repositories where the documents live leads to outdated documentation.
|
|
6
6
|
|
|
7
7
|
This Python package
|
|
8
|
+
|
|
8
9
|
* parses Markdown files,
|
|
9
10
|
* converts Markdown content into the Confluence Storage Format (XHTML),
|
|
10
11
|
* invokes Confluence API endpoints to upload images and content.
|
|
@@ -23,6 +24,7 @@ This Python package
|
|
|
23
24
|
## Getting started
|
|
24
25
|
|
|
25
26
|
In order to get started, you will need
|
|
27
|
+
|
|
26
28
|
* your organization domain name (e.g. `instructure.atlassian.net`),
|
|
27
29
|
* base path for Confluence wiki (typically `/wiki/` for managed Confluence, `/` for on-premise)
|
|
28
30
|
* your Confluence username (e.g. `levente.hunyadi@instructure.com`) (only if required by your deployment),
|
|
@@ -31,7 +33,7 @@ In order to get started, you will need
|
|
|
31
33
|
|
|
32
34
|
### Obtaining an API token
|
|
33
35
|
|
|
34
|
-
1. Log in to https://id.atlassian.com/manage/api-tokens
|
|
36
|
+
1. Log in to <https://id.atlassian.com/manage/api-tokens>.
|
|
35
37
|
2. Click *Create API token*.
|
|
36
38
|
3. From the dialog that appears, enter a memorable and concise *Label* for your token and click *Create*.
|
|
37
39
|
4. Click *Copy to clipboard*, then paste the token to your script, or elsewhere to save.
|
|
@@ -39,6 +41,7 @@ In order to get started, you will need
|
|
|
39
41
|
### Setting up the environment
|
|
40
42
|
|
|
41
43
|
Confluence organization domain, base path, username, API token and space key can be specified at runtime or set as Confluence environment variables (e.g. add to your `~/.profile` on Linux, or `~/.bash_profile` or `~/.zshenv` on MacOS):
|
|
44
|
+
|
|
42
45
|
```bash
|
|
43
46
|
export CONFLUENCE_DOMAIN='instructure.atlassian.net'
|
|
44
47
|
export CONFLUENCE_PATH='/wiki/'
|
|
@@ -105,28 +108,30 @@ Use the `--help` switch to get a full list of supported command-line options:
|
|
|
105
108
|
|
|
106
109
|
```console
|
|
107
110
|
$ python3 -m md2conf --help
|
|
108
|
-
usage: md2conf [-h] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE]
|
|
109
|
-
[-
|
|
111
|
+
usage: md2conf [-h] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE] [-l {debug,info,warning,error,critical}] [-r ROOT_PAGE] [--generated-by GENERATED_BY]
|
|
112
|
+
[--no-generated-by] [--ignore-invalid-url] [--local]
|
|
110
113
|
mdpath
|
|
111
114
|
|
|
112
115
|
positional arguments:
|
|
113
116
|
mdpath Path to Markdown file or directory to convert and publish.
|
|
114
117
|
|
|
115
|
-
|
|
118
|
+
optional arguments:
|
|
116
119
|
-h, --help show this help message and exit
|
|
117
120
|
-d DOMAIN, --domain DOMAIN
|
|
118
121
|
Confluence organization domain.
|
|
119
|
-
-p PATH, --path PATH Base path for
|
|
122
|
+
-p PATH, --path PATH Base path for Confluence (default: '/wiki/').
|
|
120
123
|
-u USERNAME, --username USERNAME
|
|
121
124
|
Confluence user name.
|
|
122
125
|
-a APIKEY, --apikey APIKEY
|
|
123
126
|
Confluence API key. Refer to documentation how to obtain one.
|
|
124
127
|
-s SPACE, --space SPACE
|
|
125
|
-
Confluence space key for pages to be published. If omitted, will default to user
|
|
126
|
-
|
|
127
|
-
-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --loglevel {DEBUG,INFO,WARNING,ERROR,CRITICAL}
|
|
128
|
+
Confluence space key for pages to be published. If omitted, will default to user space.
|
|
129
|
+
-l {debug,info,warning,error,critical}, --loglevel {debug,info,warning,error,critical}
|
|
128
130
|
Use this option to set the log verbosity.
|
|
131
|
+
-r ROOT_PAGE Root Confluence page to create new pages. If omitted, will raise exception when creating new pages.
|
|
129
132
|
--generated-by GENERATED_BY
|
|
130
133
|
Add prompt to pages (default: 'This page has been generated with a tool.').
|
|
131
134
|
--no-generated-by Do not add 'generated by a tool' prompt to pages.
|
|
135
|
+
--ignore-invalid-url Emit a warning but otherwise ignore relative URLs that point to ill-specified locations.
|
|
136
|
+
--local Write XHTML-based Confluence Storage Format files locally without invoking Confluence API.
|
|
132
137
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: markdown-to-confluence
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.12
|
|
4
4
|
Summary: Publish Markdown files to Confluence wiki
|
|
5
5
|
Home-page: https://github.com/hunyadi/md2conf
|
|
6
6
|
Author: Levente Hunyadi
|
|
@@ -21,13 +21,13 @@ Classifier: Typing :: Typed
|
|
|
21
21
|
Requires-Python: >=3.8
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
License-File: LICENSE
|
|
24
|
-
Requires-Dist: lxml>=
|
|
25
|
-
Requires-Dist: types-lxml>=
|
|
26
|
-
Requires-Dist: markdown>=3.
|
|
27
|
-
Requires-Dist: types-markdown>=3.
|
|
28
|
-
Requires-Dist: pymdown-extensions>=10.
|
|
29
|
-
Requires-Dist: requests>=2.
|
|
30
|
-
Requires-Dist: types-requests>=2.
|
|
24
|
+
Requires-Dist: lxml>=5.2
|
|
25
|
+
Requires-Dist: types-lxml>=2024.4.14
|
|
26
|
+
Requires-Dist: markdown>=3.6
|
|
27
|
+
Requires-Dist: types-markdown>=3.6
|
|
28
|
+
Requires-Dist: pymdown-extensions>=10.8
|
|
29
|
+
Requires-Dist: requests>=2.32
|
|
30
|
+
Requires-Dist: types-requests>=2.32
|
|
31
31
|
|
|
32
32
|
# Publish Markdown files to Confluence wiki
|
|
33
33
|
|
|
@@ -36,6 +36,7 @@ Contributors to software projects typically write documentation in Markdown form
|
|
|
36
36
|
Replicating documentation to Confluence by hand is tedious, and a lack of automated synchronization with the project repositories where the documents live leads to outdated documentation.
|
|
37
37
|
|
|
38
38
|
This Python package
|
|
39
|
+
|
|
39
40
|
* parses Markdown files,
|
|
40
41
|
* converts Markdown content into the Confluence Storage Format (XHTML),
|
|
41
42
|
* invokes Confluence API endpoints to upload images and content.
|
|
@@ -54,6 +55,7 @@ This Python package
|
|
|
54
55
|
## Getting started
|
|
55
56
|
|
|
56
57
|
In order to get started, you will need
|
|
58
|
+
|
|
57
59
|
* your organization domain name (e.g. `instructure.atlassian.net`),
|
|
58
60
|
* base path for Confluence wiki (typically `/wiki/` for managed Confluence, `/` for on-premise)
|
|
59
61
|
* your Confluence username (e.g. `levente.hunyadi@instructure.com`) (only if required by your deployment),
|
|
@@ -62,7 +64,7 @@ In order to get started, you will need
|
|
|
62
64
|
|
|
63
65
|
### Obtaining an API token
|
|
64
66
|
|
|
65
|
-
1. Log in to https://id.atlassian.com/manage/api-tokens
|
|
67
|
+
1. Log in to <https://id.atlassian.com/manage/api-tokens>.
|
|
66
68
|
2. Click *Create API token*.
|
|
67
69
|
3. From the dialog that appears, enter a memorable and concise *Label* for your token and click *Create*.
|
|
68
70
|
4. Click *Copy to clipboard*, then paste the token to your script, or elsewhere to save.
|
|
@@ -70,6 +72,7 @@ In order to get started, you will need
|
|
|
70
72
|
### Setting up the environment
|
|
71
73
|
|
|
72
74
|
Confluence organization domain, base path, username, API token and space key can be specified at runtime or set as Confluence environment variables (e.g. add to your `~/.profile` on Linux, or `~/.bash_profile` or `~/.zshenv` on MacOS):
|
|
75
|
+
|
|
73
76
|
```bash
|
|
74
77
|
export CONFLUENCE_DOMAIN='instructure.atlassian.net'
|
|
75
78
|
export CONFLUENCE_PATH='/wiki/'
|
|
@@ -136,28 +139,30 @@ Use the `--help` switch to get a full list of supported command-line options:
|
|
|
136
139
|
|
|
137
140
|
```console
|
|
138
141
|
$ python3 -m md2conf --help
|
|
139
|
-
usage: md2conf [-h] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE]
|
|
140
|
-
[-
|
|
142
|
+
usage: md2conf [-h] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE] [-l {debug,info,warning,error,critical}] [-r ROOT_PAGE] [--generated-by GENERATED_BY]
|
|
143
|
+
[--no-generated-by] [--ignore-invalid-url] [--local]
|
|
141
144
|
mdpath
|
|
142
145
|
|
|
143
146
|
positional arguments:
|
|
144
147
|
mdpath Path to Markdown file or directory to convert and publish.
|
|
145
148
|
|
|
146
|
-
|
|
149
|
+
optional arguments:
|
|
147
150
|
-h, --help show this help message and exit
|
|
148
151
|
-d DOMAIN, --domain DOMAIN
|
|
149
152
|
Confluence organization domain.
|
|
150
|
-
-p PATH, --path PATH Base path for
|
|
153
|
+
-p PATH, --path PATH Base path for Confluence (default: '/wiki/').
|
|
151
154
|
-u USERNAME, --username USERNAME
|
|
152
155
|
Confluence user name.
|
|
153
156
|
-a APIKEY, --apikey APIKEY
|
|
154
157
|
Confluence API key. Refer to documentation how to obtain one.
|
|
155
158
|
-s SPACE, --space SPACE
|
|
156
|
-
Confluence space key for pages to be published. If omitted, will default to user
|
|
157
|
-
|
|
158
|
-
-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --loglevel {DEBUG,INFO,WARNING,ERROR,CRITICAL}
|
|
159
|
+
Confluence space key for pages to be published. If omitted, will default to user space.
|
|
160
|
+
-l {debug,info,warning,error,critical}, --loglevel {debug,info,warning,error,critical}
|
|
159
161
|
Use this option to set the log verbosity.
|
|
162
|
+
-r ROOT_PAGE Root Confluence page to create new pages. If omitted, will raise exception when creating new pages.
|
|
160
163
|
--generated-by GENERATED_BY
|
|
161
164
|
Add prompt to pages (default: 'This page has been generated with a tool.').
|
|
162
165
|
--no-generated-by Do not add 'generated by a tool' prompt to pages.
|
|
166
|
+
--ignore-invalid-url Emit a warning but otherwise ignore relative URLs that point to ill-specified locations.
|
|
167
|
+
--local Write XHTML-based Confluence Storage Format files locally without invoking Confluence API.
|
|
163
168
|
```
|
|
@@ -6,6 +6,7 @@ setup.py
|
|
|
6
6
|
markdown_to_confluence.egg-info/PKG-INFO
|
|
7
7
|
markdown_to_confluence.egg-info/SOURCES.txt
|
|
8
8
|
markdown_to_confluence.egg-info/dependency_links.txt
|
|
9
|
+
markdown_to_confluence.egg-info/entry_points.txt
|
|
9
10
|
markdown_to_confluence.egg-info/requires.txt
|
|
10
11
|
markdown_to_confluence.egg-info/top_level.txt
|
|
11
12
|
markdown_to_confluence.egg-info/zip-safe
|
|
@@ -15,5 +16,9 @@ md2conf/api.py
|
|
|
15
16
|
md2conf/application.py
|
|
16
17
|
md2conf/converter.py
|
|
17
18
|
md2conf/entities.dtd
|
|
19
|
+
md2conf/processor.py
|
|
20
|
+
md2conf/properties.py
|
|
18
21
|
md2conf/py.typed
|
|
19
|
-
tests/test_api.py
|
|
22
|
+
tests/test_api.py
|
|
23
|
+
tests/test_conversion.py
|
|
24
|
+
tests/test_processor.py
|
|
@@ -5,9 +5,9 @@ Parses Markdown files, converts Markdown content into the Confluence Storage For
|
|
|
5
5
|
Confluence API endpoints to upload images and content.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
__version__ = "0.1.
|
|
8
|
+
__version__ = "0.1.12"
|
|
9
9
|
__author__ = "Levente Hunyadi"
|
|
10
|
-
__copyright__ = "Copyright 2022-
|
|
10
|
+
__copyright__ = "Copyright 2022-2024, Levente Hunyadi"
|
|
11
11
|
__license__ = "MIT"
|
|
12
12
|
__maintainer__ = "Levente Hunyadi"
|
|
13
13
|
__status__ = "Production"
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import logging
|
|
3
|
+
import os.path
|
|
4
|
+
import sys
|
|
5
|
+
import typing
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
import requests
|
|
10
|
+
|
|
11
|
+
from .api import ConfluenceAPI
|
|
12
|
+
from .application import Application
|
|
13
|
+
from .converter import ConfluenceDocumentOptions
|
|
14
|
+
from .processor import Processor
|
|
15
|
+
from .properties import ConfluenceProperties
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Arguments(argparse.Namespace):
|
|
19
|
+
mdpath: Path
|
|
20
|
+
domain: str
|
|
21
|
+
path: str
|
|
22
|
+
username: str
|
|
23
|
+
apikey: str
|
|
24
|
+
space: str
|
|
25
|
+
loglevel: str
|
|
26
|
+
ignore_invalid_url: bool
|
|
27
|
+
generated_by: Optional[str]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def main() -> None:
|
|
31
|
+
parser = argparse.ArgumentParser()
|
|
32
|
+
parser.prog = os.path.basename(os.path.dirname(__file__))
|
|
33
|
+
parser.add_argument(
|
|
34
|
+
"mdpath", help="Path to Markdown file or directory to convert and publish."
|
|
35
|
+
)
|
|
36
|
+
parser.add_argument("-d", "--domain", help="Confluence organization domain.")
|
|
37
|
+
parser.add_argument(
|
|
38
|
+
"-p", "--path", help="Base path for Confluence (default: '/wiki/')."
|
|
39
|
+
)
|
|
40
|
+
parser.add_argument("-u", "--username", help="Confluence user name.")
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
"-a",
|
|
43
|
+
"--apikey",
|
|
44
|
+
help="Confluence API key. Refer to documentation how to obtain one.",
|
|
45
|
+
)
|
|
46
|
+
parser.add_argument(
|
|
47
|
+
"-s",
|
|
48
|
+
"--space",
|
|
49
|
+
help="Confluence space key for pages to be published. If omitted, will default to user space.",
|
|
50
|
+
)
|
|
51
|
+
parser.add_argument(
|
|
52
|
+
"-l",
|
|
53
|
+
"--loglevel",
|
|
54
|
+
choices=[
|
|
55
|
+
typing.cast(str, logging.getLevelName(level)).lower()
|
|
56
|
+
for level in (
|
|
57
|
+
logging.DEBUG,
|
|
58
|
+
logging.INFO,
|
|
59
|
+
logging.WARN,
|
|
60
|
+
logging.ERROR,
|
|
61
|
+
logging.CRITICAL,
|
|
62
|
+
)
|
|
63
|
+
],
|
|
64
|
+
default=logging.getLevelName(logging.INFO),
|
|
65
|
+
help="Use this option to set the log verbosity.",
|
|
66
|
+
)
|
|
67
|
+
parser.add_argument(
|
|
68
|
+
"-r",
|
|
69
|
+
dest="root_page",
|
|
70
|
+
help="Root Confluence page to create new pages. If omitted, will raise exception when creating new pages.",
|
|
71
|
+
)
|
|
72
|
+
parser.add_argument(
|
|
73
|
+
"--generated-by",
|
|
74
|
+
default="This page has been generated with a tool.",
|
|
75
|
+
help="Add prompt to pages (default: 'This page has been generated with a tool.').",
|
|
76
|
+
)
|
|
77
|
+
parser.add_argument(
|
|
78
|
+
"--no-generated-by",
|
|
79
|
+
dest="generated_by",
|
|
80
|
+
action="store_const",
|
|
81
|
+
const=None,
|
|
82
|
+
help="Do not add 'generated by a tool' prompt to pages.",
|
|
83
|
+
)
|
|
84
|
+
parser.add_argument(
|
|
85
|
+
"--ignore-invalid-url",
|
|
86
|
+
action="store_true",
|
|
87
|
+
default=False,
|
|
88
|
+
help="Emit a warning but otherwise ignore relative URLs that point to ill-specified locations.",
|
|
89
|
+
)
|
|
90
|
+
parser.add_argument(
|
|
91
|
+
"--local",
|
|
92
|
+
action="store_true",
|
|
93
|
+
default=False,
|
|
94
|
+
help="Write XHTML-based Confluence Storage Format files locally without invoking Confluence API.",
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
args = Arguments()
|
|
98
|
+
parser.parse_args(namespace=args)
|
|
99
|
+
|
|
100
|
+
# NOTE: If we switch to modern type aware CLI tool like typer
|
|
101
|
+
# the following line won't be necessary
|
|
102
|
+
args.mdpath = Path(args.mdpath)
|
|
103
|
+
|
|
104
|
+
logging.basicConfig(
|
|
105
|
+
level=getattr(logging, args.loglevel.upper(), logging.INFO),
|
|
106
|
+
format="%(asctime)s - %(levelname)s - %(funcName)s [%(lineno)d] - %(message)s",
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
options = ConfluenceDocumentOptions(
|
|
110
|
+
ignore_invalid_url=args.ignore_invalid_url,
|
|
111
|
+
generated_by=args.generated_by,
|
|
112
|
+
root_page_id=args.root_page,
|
|
113
|
+
)
|
|
114
|
+
properties = ConfluenceProperties(
|
|
115
|
+
args.domain, args.path, args.username, args.apikey, args.space
|
|
116
|
+
)
|
|
117
|
+
if args.local:
|
|
118
|
+
Processor(options, properties).process(args.mdpath)
|
|
119
|
+
else:
|
|
120
|
+
try:
|
|
121
|
+
with ConfluenceAPI(properties) as api:
|
|
122
|
+
Application(
|
|
123
|
+
api,
|
|
124
|
+
options,
|
|
125
|
+
).synchronize(args.mdpath)
|
|
126
|
+
except requests.exceptions.HTTPError as err:
|
|
127
|
+
logging.error(err)
|
|
128
|
+
|
|
129
|
+
# print details for a response with JSON body
|
|
130
|
+
if err.response is not None:
|
|
131
|
+
try:
|
|
132
|
+
logging.error(err.response.json())
|
|
133
|
+
except requests.exceptions.JSONDecodeError:
|
|
134
|
+
pass
|
|
135
|
+
|
|
136
|
+
sys.exit(1)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
if __name__ == "__main__":
|
|
140
|
+
main()
|