forked from langfuse/langfuse-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove_docs.py
More file actions
25 lines (21 loc) 路 825 Bytes
/
Copy pathmove_docs.py
File metadata and controls
25 lines (21 loc) 路 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import json
import shutil
import os
# Load the JSON from the file
with open('./cookbook/_routes.json', 'r') as file:
mappings = json.load(file)
# Iterate over the mappings and copy the file to all destinations, then delete the source
for mapping in mappings:
filename = mapping['notebook']
md_filename = filename.replace('.ipynb', '.md')
source = 'cookbook/' + md_filename
destinations = []
if mapping['docsPath'] is not None:
destinations.append(mapping['docsPath'] + ".md")
# also publish all md files to pages/cookbook/
destinations.append('guides/cookbook/' + md_filename)
for destination in destinations:
full_destination = "pages/" + destination
print(f"cp {source} {full_destination}")
shutil.copy(source, full_destination)
os.remove(source)