mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-23 09:09:21 -05:00
34 lines
982 B
Python
34 lines
982 B
Python
import os
|
|
import shutil
|
|
import subprocess
|
|
|
|
|
|
def main():
|
|
src_dir = os.path.join(os.getcwd(), "src")
|
|
for dir in os.listdir(src_dir):
|
|
category = dir
|
|
category_dir = os.path.join(src_dir, dir)
|
|
if os.path.isdir(category_dir):
|
|
for file in os.listdir(category_dir):
|
|
if file.endswith(".md"):
|
|
build_and_copy_demo(category, file)
|
|
|
|
|
|
def build_and_copy_demo(category, md_name):
|
|
name = md_name[:-3]
|
|
example_dir = f"../../examples/{name}"
|
|
if os.path.exists(example_dir):
|
|
p = subprocess.Popen(["trunk", "build"], cwd=example_dir)
|
|
p.wait()
|
|
|
|
example_output_path = os.path.join(example_dir, "dist")
|
|
target_path = os.path.join("book", category, name, "demo")
|
|
|
|
print(f"Copying demo from {example_output_path} to {target_path}")
|
|
|
|
shutil.copytree(example_output_path, target_path,
|
|
dirs_exist_ok=True)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|