Skip to content

Commit

Permalink
support copy all image to html folder (#247)
Browse files Browse the repository at this point in the history
Signed-off-by: ZhangJianyu <[email protected]>
  • Loading branch information
NeoZhangJianyu authored Nov 11, 2024
1 parent 016942a commit d967a94
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import os
import sys
from datetime import datetime
import glob
import shutil


sys.path.insert(0, os.path.abspath('.'))

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d967a94

Please sign in to comment.