@@ -263,6 +263,10 @@ class MkDocs:
263263 def __init__ (self , handlers : list [Handler ] | None = None ):
264264 self .handlers = handlers
265265
266+ def _get_handlers (self , config : dict ) -> list [Handler ]:
267+ """Get handlers from instance or load from config."""
268+ return self .handlers if self .handlers is not None else self .load_handlers (config )
269+
266270 def path_to_url (self , path : pathlib .Path ) -> str :
267271 if str (path ).lower () in ('readme.md' , 'index.md' , 'index.html' ):
268272 # 'README.md' -> '/'
@@ -411,7 +415,7 @@ def build(self):
411415 $ mkdocs build
412416 """
413417 config = self .load_config ('mkdocs.toml' )
414- handlers = self .handlers if self . handlers is not None else self . load_handlers (config )
418+ handlers = self ._get_handlers (config )
415419 resources , templates = self .load_resources (handlers )
416420 env = self .load_env (templates )
417421 md = self .load_md (config )
@@ -428,7 +432,7 @@ def serve(self):
428432 $ mkdocs serve
429433 """
430434 config = self .load_config ('mkdocs.toml' )
431- handlers = self .handlers if self . handlers is not None else self . load_handlers (config )
435+ handlers = self ._get_handlers (config )
432436 resources , templates = self .load_resources (handlers )
433437 env = self .load_env (templates )
434438 md = self .load_md (config )
0 commit comments