@@ -136,13 +136,26 @@ def generate_class_page(self, class_name: str, class_obj: Any) -> Path:
136136 """Generate a documentation page for a class."""
137137 # Convert module path to file path
138138 # e.g., "plotly.graph_objs.Bar" -> "Bar.md"
139- # e.g., "plotly.graph_objs.bar.Marker" -> "bar/Marker.md"
139+ # e.g., "plotly.graph_objs.bar.Marker" -> "bar-package/Marker.md"
140+ # e.g., "plotly.graph_objs.bar.hoverlabel.Font" -> "bar/hoverlabel-package/Font.md"
140141
141142 parts = class_name .split ('.' )
142143 if len (parts ) > 2 : # plotly.graph_objs.something
143144 # Remove "plotly.graph_objs" prefix
144145 relative_parts = parts [2 :]
145- file_path = self .output_dir / Path (* relative_parts [:- 1 ]) / f"{ parts [- 1 ]} .md"
146+ if len (relative_parts ) == 1 :
147+ # Top-level class: plotly.graph_objs.Bar -> Bar.md
148+ file_path = self .output_dir / f"{ parts [- 1 ]} .md"
149+ else :
150+ # Classes inside packages
151+ parent_parts = relative_parts [:- 1 ]
152+ if len (parent_parts ) == 1 :
153+ # e.g., plotly.graph_objs.bar.Marker -> bar-package/Marker.md
154+ parent_dir = self .output_dir / f"{ parent_parts [0 ]} -package"
155+ else :
156+ # e.g., plotly.graph_objs.bar.hoverlabel.Font -> bar/hoverlabel-package/Font.md
157+ parent_dir = self .output_dir / Path (* parent_parts [:- 1 ]) / f"{ parent_parts [- 1 ]} -package"
158+ file_path = parent_dir / f"{ parts [- 1 ]} .md"
146159 else :
147160 file_path = self .output_dir / f"{ parts [- 1 ]} .md"
148161
@@ -171,6 +184,9 @@ def generate_class_page(self, class_name: str, class_obj: Any) -> Path:
171184 f .write (content )
172185
173186 self .generated_files .add (file_path )
187+
188+ # (No legacy stub generation for class pages)
189+
174190 return file_path
175191
176192 def generate_package_index (self , package_name : str , package_obj : Any ) -> Path :
@@ -179,7 +195,14 @@ def generate_package_index(self, package_name: str, package_obj: Any) -> Path:
179195 parts = package_name .split ('.' )
180196 if len (parts ) > 2 : # plotly.graph_objs.something
181197 relative_parts = parts [2 :]
182- file_path = self .output_dir / Path (* relative_parts ) / "index.md"
198+ # Add -package suffix to avoid conflicts with class names
199+ package_name_with_suffix = f"{ relative_parts [- 1 ]} -package"
200+ if len (relative_parts ) > 1 :
201+ # For nested packages, replace the last part with the suffixed version
202+ file_path = self .output_dir / Path (* relative_parts [:- 1 ]) / package_name_with_suffix / "index.md"
203+ else :
204+ # For top-level packages
205+ file_path = self .output_dir / package_name_with_suffix / "index.md"
183206 else :
184207 # This is the main plotly.graph_objs package
185208 file_path = self .output_dir / "index.md"
@@ -219,7 +242,10 @@ def generate_package_index(self, package_name: str, package_obj: Any) -> Path:
219242 content += "## Packages\n \n "
220243 for subpackage_name in sorted (package_subpackages ):
221244 subpackage_display_name = subpackage_name .split ('.' )[- 1 ]
222- content += f"- [{ subpackage_display_name } ]({ subpackage_display_name } /index.md)\n "
245+ # Always link to local stub within the -package folder to avoid relative path issues
246+ subpackage_folder_name = f"{ subpackage_display_name } -package"
247+ link = f"{ subpackage_folder_name } /index.md"
248+ content += f"- [{ subpackage_display_name } ]({ link } )\n "
223249 content += "\n "
224250
225251 # If no classes or packages, add a note
@@ -277,7 +303,8 @@ def generate_main_index(self) -> Path:
277303 if top_level_packages :
278304 content += "## Packages\n \n "
279305 for short_name , full_name in top_level_packages :
280- content += f"- [{ short_name } ]({ short_name } /index.md)\n "
306+ package_folder_name = f"{ short_name } -package"
307+ content += f"- [{ short_name } ]({ package_folder_name } /index.md)\n "
281308 content += "\n "
282309
283310 if self .inspector .is_deprecated_class ("AngularAxis" ): # Check if any deprecated classes exist
0 commit comments