-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Roland Meyer
committed
Nov 13, 2021
1 parent
8a68dae
commit 90225ed
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Publish Documentation | ||
on: | ||
push: | ||
branches: [ develop ] | ||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: setup python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
- name: Process files | ||
run: | | ||
python scripts/publish-docs.py | ||
- name: Upload FTP | ||
uses: sebastianpopp/ftp-action@releases/v2 | ||
with: | ||
host: ${{ secrets.FTP_SERVER }} | ||
user: ${{ secrets.FTP_USERNAME }} | ||
password: ${{ secrets.FTP_PASSWORD }} | ||
localDir: "processed-docs" | ||
remoteDir: "." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.idea/ | ||
venv | ||
processed-docs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import re | ||
from os import listdir | ||
from os import makedirs | ||
from os.path import abspath | ||
from os.path import basename | ||
from os.path import dirname | ||
from os.path import isfile | ||
from os.path import join | ||
|
||
CURRENT_DIR = dirname(abspath(__file__)) | ||
|
||
INPUT_DIR = join(join(CURRENT_DIR, '..'), 'docs') | ||
OUTPUT_DIR = join(join(CURRENT_DIR, '..'), 'processed-docs') | ||
|
||
|
||
def main(): | ||
makedirs(OUTPUT_DIR, exist_ok=True) | ||
markdown_files = _get_markdown_files() | ||
|
||
for in_file in markdown_files: | ||
out_file = _get_processed_file_name(in_file) | ||
|
||
with open(in_file, 'r') as ifp: | ||
with open(out_file, 'w') as ofp: | ||
while True: | ||
line = ifp.readline() | ||
if not line: | ||
break | ||
ofp.write(_process_line(line)) | ||
|
||
|
||
def _get_markdown_files(): | ||
files = [ | ||
join(INPUT_DIR, file) | ||
for file in listdir(INPUT_DIR) | ||
] | ||
return [ | ||
file | ||
for file in files | ||
if isfile(file) and file.endswith('.md') | ||
] | ||
|
||
|
||
def _get_processed_file_name(in_file): | ||
return join(OUTPUT_DIR, basename(in_file)) | ||
|
||
|
||
def _process_line(line): | ||
# Process markdown links to other markdown files | ||
result = re.sub(r'(\[[^]]+]\([^)]+)\.md([^)]*\))', r'\1\2', line) | ||
# Process markdown image references | ||
result = re.sub(r'(!\[[^]]+]\()\.\.(/assets/[^)]+\))', r'\1\2', result) | ||
# Process HTML image references | ||
result = re.sub(r'( src=")\.\.(/assets/[^"]+")', r'\1\2', result) | ||
|
||
return result | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |