@@ -136,13 +136,26 @@ def generate_class_page(self, class_name: str, class_obj: Any) -> Path:
136
136
"""Generate a documentation page for a class."""
137
137
# Convert module path to file path
138
138
# 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"
140
141
141
142
parts = class_name .split ('.' )
142
143
if len (parts ) > 2 : # plotly.graph_objs.something
143
144
# Remove "plotly.graph_objs" prefix
144
145
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"
146
159
else :
147
160
file_path = self .output_dir / f"{ parts [- 1 ]} .md"
148
161
@@ -171,6 +184,9 @@ def generate_class_page(self, class_name: str, class_obj: Any) -> Path:
171
184
f .write (content )
172
185
173
186
self .generated_files .add (file_path )
187
+
188
+ # (No legacy stub generation for class pages)
189
+
174
190
return file_path
175
191
176
192
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:
179
195
parts = package_name .split ('.' )
180
196
if len (parts ) > 2 : # plotly.graph_objs.something
181
197
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"
183
206
else :
184
207
# This is the main plotly.graph_objs package
185
208
file_path = self .output_dir / "index.md"
@@ -219,7 +242,10 @@ def generate_package_index(self, package_name: str, package_obj: Any) -> Path:
219
242
content += "## Packages\n \n "
220
243
for subpackage_name in sorted (package_subpackages ):
221
244
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 "
223
249
content += "\n "
224
250
225
251
# If no classes or packages, add a note
@@ -277,7 +303,8 @@ def generate_main_index(self) -> Path:
277
303
if top_level_packages :
278
304
content += "## Packages\n \n "
279
305
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 "
281
308
content += "\n "
282
309
283
310
if self .inspector .is_deprecated_class ("AngularAxis" ): # Check if any deprecated classes exist
0 commit comments