From 578fbaee9f31ce248fa38763381b861ef9273a55 Mon Sep 17 00:00:00 2001 From: ZhangJianyu Date: Sun, 10 Nov 2024 20:13:27 +0800 Subject: [PATCH 1/2] support copy all image to html folder --- conf.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/conf.py b/conf.py index 40e46375..a24701ad 100644 --- a/conf.py +++ b/conf.py @@ -4,6 +4,9 @@ import os import sys from datetime import datetime +import glob +import shutil + sys.path.insert(0, os.path.abspath('.')) @@ -131,10 +134,31 @@ # paths that contain custom static files (such as style sheets) html_static_path = ['sphinx/_static'] +def copy_images(src ,dst): + image_types = ["png", "svg"] + for image_type in image_types: + pattern = "{}/**/*.{}".format(src, image_type) + files = glob.glob(pattern, recursive = True) + for file in files: + sub_name = file.replace(src, '') + dst_filename = "{}{}".format(dst, sub_name) + folder = os.path.dirname(dst_filename) + if not os.path.exists(folder): + os.makedirs(folder) + shutil.copy(file, dst_filename) + +def copy_image_to_html(app, docname): + if app.builder.name == 'html': + if os.path.exists(app.srcdir) and os.path.exists(app.outdir): + copy_images(str(app.srcdir) ,str(app.outdir)) + else: + print("No existed {} or {}".format(app.srcdir ,app.outdir)) + def setup(app): app.add_css_file("opea-custom.css") app.add_js_file("opea-custom.js") + app.connect('build-finished', copy_image_to_html) # Disable "Created using Sphinx" in the HTML footer. Default is True. html_show_sphinx = False @@ -150,4 +174,4 @@ def setup(app): rst_epilog = """ .. include:: /sphinx/substitutions.txt -""" +""" \ No newline at end of file From a4b95bc245ef3a497eba365ed54d4b7f1ac7bab1 Mon Sep 17 00:00:00 2001 From: ZhangJianyu Date: Sun, 10 Nov 2024 20:15:39 +0800 Subject: [PATCH 2/2] fix endline Signed-off-by: ZhangJianyu --- conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.py b/conf.py index a24701ad..35051272 100644 --- a/conf.py +++ b/conf.py @@ -174,4 +174,4 @@ def setup(app): rst_epilog = """ .. include:: /sphinx/substitutions.txt -""" \ No newline at end of file +"""