import os import json docs_dir = os.path.dirname(os.path.abspath(__file__)) dirs_to_process = ['01_overview', '02_journeys_and_tutorials', '03_pricing', '04_features', '05_transit_mawasalati', '06_investors', '07_marketing', '08_security', '10_food_orders'] docs_data = {} for d in dirs_to_process: dir_path = os.path.join(docs_dir, d) if os.path.exists(dir_path): for root, _, files in os.walk(dir_path): for file in files: if file.endswith('.md'): full_path = os.path.join(root, file) rel_path = os.path.relpath(full_path, docs_dir) # Use forward slashes for URLs rel_path = rel_path.replace('\\', '/') with open(full_path, 'r', encoding='utf-8') as f: docs_data[rel_path] = f.read() # Write to a JS file output_path = os.path.join(docs_dir, 'docs-data.js') with open(output_path, 'w', encoding='utf-8') as f: f.write('const docsData = ') json.dump(docs_data, f, ensure_ascii=False) f.write(';\n') print(f"Successfully generated {output_path} with {len(docs_data)} files.")