File size: 635 Bytes
e5509f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import glob
from pathlib import Path

assert os.environ['MC_EXAMPLE_SCENES_DIR']
assert os.environ['MC_EXAMPLES_MD_FILE']

with open(os.environ['MC_EXAMPLES_MD_FILE'], "w") as f:

    f.write(f"# Examples for Motion Canvas Scenes in TypeScript\n")

    for filepath in glob.iglob(os.environ['MC_EXAMPLE_SCENES_DIR'] + '/**/*.tsx', recursive=True):
        name = Path(filepath).stem

        f.write(f"\n\n## {name}\n")
        
        # read the file
        with open(filepath, 'r') as scene_file:
            content = scene_file.read()

        f.write(f"```tsx\n")    
        f.write(content)
        f.write(f"```\n")