99from fastplotlib .layouts import Subplot
1010from fastplotlib import graphics
1111from fastplotlib .graphics import features , selectors
12+ from fastplotlib import tools
1213from fastplotlib import widgets
1314from fastplotlib import utils
1415from fastplotlib import ui
2122GRAPHICS_DIR = API_DIR .joinpath ("graphics" )
2223GRAPHIC_FEATURES_DIR = API_DIR .joinpath ("graphic_features" )
2324SELECTORS_DIR = API_DIR .joinpath ("selectors" )
25+ TOOLS_DIR = API_DIR .joinpath ("tools" )
2426WIDGETS_DIR = API_DIR .joinpath ("widgets" )
2527UI_DIR = API_DIR .joinpath ("ui" )
2628GUIDE_DIR = current_dir .joinpath ("user_guide" )
3133 GRAPHICS_DIR ,
3234 GRAPHIC_FEATURES_DIR ,
3335 SELECTORS_DIR ,
36+ TOOLS_DIR ,
3437 WIDGETS_DIR ,
3538 UI_DIR ,
3639]
@@ -264,7 +267,8 @@ def main():
264267 )
265268
266269 # the rest of this is a mess and can be refactored later
267-
270+ ##############################################################################
271+ # ** Graphic classes ** #
268272 graphic_classes = [getattr (graphics , g ) for g in graphics .__all__ ]
269273
270274 graphic_class_names = [g .__name__ for g in graphic_classes ]
@@ -290,7 +294,7 @@ def main():
290294 source_path = GRAPHICS_DIR .joinpath (f"{ graphic_cls .__name__ } .rst" ),
291295 )
292296 ##############################################################################
293-
297+ # ** GraphicFeature classes ** #
294298 feature_classes = [getattr (features , f ) for f in features .__all__ ]
295299
296300 feature_class_names = [f .__name__ for f in feature_classes ]
@@ -315,7 +319,7 @@ def main():
315319 source_path = GRAPHIC_FEATURES_DIR .joinpath (f"{ feature_cls .__name__ } .rst" ),
316320 )
317321 ##############################################################################
318-
322+ # ** Selector classes ** #
319323 selector_classes = [getattr (selectors , s ) for s in selectors .__all__ ]
320324
321325 selector_class_names = [s .__name__ for s in selector_classes ]
@@ -339,8 +343,35 @@ def main():
339343 modules = ["fastplotlib" ],
340344 source_path = SELECTORS_DIR .joinpath (f"{ selector_cls .__name__ } .rst" ),
341345 )
346+
342347 ##############################################################################
348+ # ** Tools classes ** #
349+ tools_classes = [getattr (tools , t ) for t in tools .__all__ ]
343350
351+ tools_class_names = [t .__name__ for t in tools_classes ]
352+
353+ tools_class_names_str = "\n " .join (["" ] + tools_class_names )
354+
355+ with open (TOOLS_DIR .joinpath ("index.rst" ), "w" ) as f :
356+ f .write (
357+ f"Tools\n "
358+ f"*****\n "
359+ f"\n "
360+ f".. toctree::\n "
361+ f" :maxdepth: 1\n "
362+ f"{ tools_class_names_str } \n "
363+ )
364+
365+ for tool_cls in tools_classes :
366+ generate_page (
367+ page_name = tool_cls .__name__ ,
368+ classes = [tool_cls ],
369+ modules = ["fastplotlib" ],
370+ source_path = TOOLS_DIR .joinpath (f"{ tool_cls .__name__ } .rst" ),
371+ )
372+
373+ ##############################################################################
374+ # ** Widget classes ** #
344375 widget_classes = [getattr (widgets , w ) for w in widgets .__all__ ]
345376
346377 widget_class_names = [w .__name__ for w in widget_classes ]
@@ -365,7 +396,7 @@ def main():
365396 source_path = WIDGETS_DIR .joinpath (f"{ widget_cls .__name__ } .rst" ),
366397 )
367398 ##############################################################################
368-
399+ # ** UI classes ** #
369400 ui_classes = [ui .BaseGUI , ui .Window , ui .EdgeWindow , ui .Popup ]
370401
371402 ui_class_names = [cls .__name__ for cls in ui_classes ]
@@ -410,6 +441,7 @@ def main():
410441 " graphics/index\n "
411442 " graphic_features/index\n "
412443 " selectors/index\n "
444+ " tools/index\n "
413445 " ui/index\n "
414446 " widgets/index\n "
415447 " fastplotlib\n "
@@ -438,6 +470,9 @@ def write_table(name, feature_cls):
438470 f .write ("============\n \n " )
439471
440472 for graphic_cls in [* graphic_classes , * selector_classes ]:
473+ if graphic_cls is graphics .Graphic :
474+ # skip Graphic base class
475+ continue
441476 f .write (f"{ graphic_cls .__name__ } \n " )
442477 f .write ("-" * len (graphic_cls .__name__ ) + "\n \n " )
443478 for name , type_ in graphic_cls ._features .items ():
0 commit comments