Derive the docs section label directly from the source relative_path. Strips the leading 'Mujoco/' prefix and the filename, then joins remaining folders. e.g. 'Mujoco/Components/Geometry/MjGeom.h' → 'Components/Geometry' 'Mujoco/Core/MjArticulation.h' → 'Core'
(rel_path: str)
| 156 | |
| 157 | |
| 158 | def _section_from_path(rel_path: str) -> str: |
| 159 | """ |
| 160 | Derive the docs section label directly from the source relative_path. |
| 161 | Strips the leading 'Mujoco/' prefix and the filename, then joins remaining folders. |
| 162 | e.g. 'Mujoco/Components/Geometry/MjGeom.h' → 'Components/Geometry' |
| 163 | 'Mujoco/Core/MjArticulation.h' → 'Core' |
| 164 | 'URLabGameMode.h' → 'Other' |
| 165 | """ |
| 166 | parts = rel_path.replace('\\', '/').split('/') |
| 167 | # Drop filename (last element) |
| 168 | folders = parts[:-1] |
| 169 | # Strip leading 'Mujoco' folder |
| 170 | if folders and folders[0].lower() == 'mujoco': |
| 171 | folders = folders[1:] |
| 172 | # Strip leading 'Public' if present |
| 173 | if folders and folders[0].lower() == 'public': |
| 174 | folders = folders[1:] |
| 175 | if not folders: |
| 176 | return 'Other' |
| 177 | return '/'.join(folders) |
| 178 | |
| 179 | |
| 180 | def _safe_folder(section: str) -> str: |