@@ -204,12 +204,13 @@ def convert_path_to_url(path: Path, remove_first_part: bool = True, url_transfor
204204class DocumentationIndexer :
205205 """Handles cloning, processing, and indexing of documentation."""
206206
207- def __init__ (self , data_dir : Optional [Path ] = None , repos_dir : Optional [Path ] = None ):
207+ def __init__ (self , * , data_dir : Optional [Path ] = None , repos_dir : Optional [ Path ] = None , vector_dir : Optional [Path ] = None ):
208208 """Initialize the DocumentationIndexer.
209209
210210 Args:
211211 data_dir: Directory to store index data. Defaults to user config directory.
212212 repos_dir: Directory to store cloned repositories. Defaults to HOLOVIZ_MCP_REPOS_DIR.
213+ vector_dir: Directory to store vector database. Defaults to config.vector_dir
213214 """
214215 # Use unified config for default paths
215216 config = get_config ()
@@ -221,9 +222,8 @@ def __init__(self, data_dir: Optional[Path] = None, repos_dir: Optional[Path] =
221222 self .repos_dir = repos_dir or config .repos_dir
222223 self .repos_dir .mkdir (parents = True , exist_ok = True )
223224
224- # Use config logic to resolve vector DB path
225- config = get_config ()
226- vector_db_path = config .server .resolve_vector_db_path (config .user_dir )
225+ # Use configurable directory for vector database path
226+ vector_db_path = vector_dir or config .server .vector_db_path
227227 vector_db_path .parent .mkdir (parents = True , exist_ok = True )
228228
229229 # Disable ChromaDB telemetry based on config
@@ -577,7 +577,6 @@ async def extract_docs_from_repo(self, repo_path: Path, project: str, ctx: Conte
577577 regular_count = len (docs ) - reference_count
578578
579579 await log_info (f" 📄 { project } : { len (docs )} total documents ({ regular_count } regular, { reference_count } reference guides)" , ctx )
580-
581580 return docs
582581
583582 async def index_documentation (self , ctx : Context | None = None ):
@@ -591,7 +590,6 @@ async def index_documentation(self, ctx: Context | None = None):
591590 # Clone/update repositories and extract documentation
592591 for repo_name , repo_config in self .config .repositories .items ():
593592 await log_info (f"Processing { repo_name } ..." , ctx )
594-
595593 repo_path = await self .clone_or_update_repo (repo_name , repo_config )
596594 if repo_path :
597595 docs = await self .extract_docs_from_repo (repo_path , repo_name , ctx )
@@ -934,34 +932,32 @@ async def _log_summary_table(self, ctx: Context | None = None):
934932 except Exception as e :
935933 await log_warning (f"Failed to generate summary table: { e } " , ctx )
936934
935+ def run (self ):
936+ """Update the DocumentationIndexer."""
937+ # Configure logging for the CLI
938+ logging .basicConfig (level = logging .INFO , format = "%(asctime)s - %(levelname)s - %(message)s" , handlers = [logging .StreamHandler ()])
937939
938- def main ():
939- """Update the DocumentationIndexer."""
940- # Configure logging for the CLI
941- logging .basicConfig (level = logging .INFO , format = "%(asctime)s - %(levelname)s - %(message)s" , handlers = [logging .StreamHandler ()])
942-
943- logger .info ("🚀 HoloViz MCP Documentation Indexer" )
944- logger .info ("=" * 50 )
940+ logger .info ("🚀 HoloViz MCP Documentation Indexer" )
941+ logger .info ("=" * 50 )
945942
946- async def run_indexer ():
947- indexer = DocumentationIndexer ()
948- logger .info (f"📁 Repository directory: { indexer .repos_dir } " )
949- logger .info (f"💾 Vector database: { indexer .data_dir / 'chroma' } " )
950- logger .info (f"🔧 Configured repositories: { len (indexer .config .repositories )} " )
951- logger .info ("" )
943+ async def run_indexer (indexer = self ):
944+ logger .info (f"📁 Repository directory: { indexer .repos_dir } " )
945+ logger .info (f"💾 Vector database: { indexer .data_dir / 'chroma' } " )
946+ logger .info (f"🔧 Configured repositories: { len (indexer .config .repositories )} " )
947+ logger .info ("" )
952948
953- await indexer .index_documentation ()
949+ await indexer .index_documentation ()
954950
955- # Final summary
956- count = indexer .collection .count ()
957- logger .info ("" )
958- logger .info ("=" * 50 )
959- logger .info ("✅ Indexing completed successfully!" )
960- logger .info (f"📊 Total documents in database: { count } " )
961- logger .info ("=" * 50 )
951+ # Final summary
952+ count = indexer .collection .count ()
953+ logger .info ("" )
954+ logger .info ("=" * 50 )
955+ logger .info ("✅ Indexing completed successfully!" )
956+ logger .info (f"📊 Total documents in database: { count } " )
957+ logger .info ("=" * 50 )
962958
963- asyncio .run (run_indexer ())
959+ asyncio .run (run_indexer ())
964960
965961
966962if __name__ == "__main__" :
967- main ()
963+ DocumentationIndexer (). run ()
0 commit comments