"""Generate task pages for the challenge demo gallery.""" import json from pathlib import Path import mkdocs_gen_files # Load task data task_data_file = Path("docs/challenge/task_data.json") with open(task_data_file) as f: data = json.load(f) # Also copy the task_data.json file to the output with mkdocs_gen_files.open("challenge/task_data.json", "w") as fd: json.dump(data, fd, indent=2) # Room display names room_names = { 'kitchen': 'Kitchen', 'living_room': 'Living Room', 'bedroom': 'Bedroom', 'bathroom': 'Bathroom', 'garage': 'Garage', 'garden': 'Garden', 'childs_room': "Child's Room", 'corridor': 'Corridor', 'utility_room': 'Utility Room' } # Create the demo gallery as index page with all tasks embedded with mkdocs_gen_files.open("challenge/tasks/index.md", "w") as fd: # fd.write("---\n") # fd.write("icon: material/grid\n") # fd.write("---\n\n") fd.write("# Demo Gallery\n\n") fd.write("Browse through all 50 household tasks in our 2025 challenge. Click on any task to view an example of RGB video demonstration.\n\n") # Add controls fd.write('''
Loading tasks...
''') # Add JavaScript with embedded data fd.write('\n ''') # Add styles fd.write(''' ''') # Generate individual task pages (without annotations, with proper video sizing) for task in data['tasks']: task_id = task['id'] task_name = task['name'] # Get task index for numbering task_index = data['tasks'].index(task) # Create file path with zero-padded task number prefix for proper sorting doc_path = Path("challenge", "tasks", f"{task_index:02d}_{task_id}.md") full_doc_path = Path(doc_path) # Generate page content with mkdocs_gen_files.open(full_doc_path, "w") as fd: # Page header fd.write("---\n") fd.write("icon: material/video-outline\n") fd.write("---\n\n") # Title task_index = data['tasks'].index(task) fd.write(f"# Task {task_index}: {task_name}\n\n") # Metadata rooms_display = ', '.join([room_names.get(r, r.title()) for r in task.get('rooms', [])]) duration = task.get('duration', 'N/A') # Format duration as "x minutes y seconds" if isinstance(duration, int): minutes = duration // 60 seconds = duration % 60 if minutes == 0: duration_display = f"{seconds} seconds" elif seconds == 0: duration_display = f"{minutes} minutes" else: duration_display = f"{minutes} minutes {seconds} seconds" else: duration_display = str(duration) fd.write(f"**Rooms:** {rooms_display} \n") fd.write(f"**Duration:** {duration_display} avg \n") # Add task instruction if available if task.get('instruction'): fd.write(f"**Language Instruction:** {task['instruction']} \n") # Link to BEHAVIOR knowledge base (if available) kb_url = f"https://behavior.stanford.edu/knowledgebase/tasks/{task_id}-0.html" fd.write(f"**Full Task Definition:** [View on BEHAVIOR Knowledge Base]({kb_url})\n\n") # Video section - only RGB with proper sizing and minimal controls if task.get('video'): video_url = task['video'] # Extract video ID from URL if it's a Vimeo URL if 'vimeo.com' in video_url: # Add minimal Vimeo parameters: # controls=1 (show controls) # title=0, byline=0, portrait=0 (hide title, author, portrait) # dnt=1 (do not track) # transparent=0 (not transparent) # autopause=0 (don't pause when another video plays) # sidedock=0 (hide the sidebar with sharing, like, etc.) # logo=0 (hide Vimeo logo - requires Plus account or higher) fd.write('
\n') fd.write(f' \n') fd.write('
\n\n') else: # Placeholder when video is not available fd.write('
\n') fd.write('
\n') fd.write(' videocam_off\n') fd.write('

Video demonstration coming soon

\n') fd.write('
\n') fd.write('
\n\n') # Add styles for video fd.write(''' ''') # Set edit path for the generated file mkdocs_gen_files.set_edit_path(full_doc_path, Path("../../docs/challenge/task_data.json"))