@@ -76,7 +76,7 @@ def build_nested_namespace(
7676
7777def get_components_from_metadata (current_doc ):
7878 components = []
79-
79+
8080 for comp_str in current_doc .metadata .get ("components" , []):
8181 component = eval (comp_str )
8282 if isinstance (component , type ):
@@ -85,7 +85,9 @@ def get_components_from_metadata(current_doc):
8585 components .append ((component .__self__ , comp_str ))
8686 elif isinstance (component , SimpleNamespace ) and hasattr (component , "__call__" ):
8787 components .append ((component .__call__ .__self__ , comp_str ))
88-
88+ else :
89+ raise ValueError (f"Invalid component: { component } " )
90+
8991 return components
9092
9193
@@ -132,6 +134,7 @@ def exec_blocks(doc, href):
132134 "docs/recipes/content/grid.md" : "Grid Recipe" ,
133135}
134136
137+
135138def get_component (doc : str , title : str ):
136139 if doc .endswith ("-style.md" ):
137140 return
@@ -162,13 +165,14 @@ def get_component(doc: str, title: str):
162165 return multi_docs (path = route , comp = d , component_list = clist , title = title2 )
163166 if doc .startswith ("docs/library" ):
164167 clist = [title , * get_components_from_metadata (d )]
165- if issubclass (
166- clist [1 ][0 ],
167- (RadixThemesComponent , RadixPrimitiveComponent ),
168- ):
169- component_list [category ].append (clist )
170- else :
171- component_list [category ].append (clist )
168+ if len (clist ) > 1 :
169+ if issubclass (
170+ clist [1 ][0 ],
171+ (RadixThemesComponent , RadixPrimitiveComponent ),
172+ ):
173+ component_list [category ].append (clist )
174+ else :
175+ component_list [category ].append (clist )
172176 if should_skip_compile (doc ):
173177 outblocks .append ((d , route ))
174178 return
@@ -183,12 +187,16 @@ def get_component(doc: str, title: str):
183187 )
184188
185189
186- doc_routes = [
187- library ,
188- custom_components ,
189- overview ,
190- * components_previews_pages ,
191- ] + apiref_pages + cloud_cliref_pages
190+ doc_routes = (
191+ [
192+ library ,
193+ custom_components ,
194+ overview ,
195+ * components_previews_pages ,
196+ ]
197+ + apiref_pages
198+ + cloud_cliref_pages
199+ )
192200
193201
194202for api_route in apiref_pages :
@@ -200,7 +208,7 @@ def get_component(doc: str, title: str):
200208 build_nested_namespace (docs_ns , ["api_reference" ], title , api_route )
201209
202210for doc in sorted (flexdown_docs ):
203- path = doc .split ("/" )[1 :- 1 ]
211+ path = doc .split ("/" )[1 :- 1 ]
204212
205213 title = rx .utils .format .to_snake_case (os .path .basename (doc ).replace (".md" , "" ))
206214 title2 = to_title_case (title )
@@ -224,8 +232,8 @@ def get_component(doc: str, title: str):
224232
225233
226234for doc in flexdown_docs :
227- if ' recipes' in doc :
228- category = doc .split ('/' )[2 ]
235+ if " recipes" in doc :
236+ category = doc .split ("/" )[2 ]
229237 recipes_list [category ].append (doc )
230238
231239for name , ns in docs_ns .__dict__ .items ():
0 commit comments