diff --git a/docs/Makefile b/docs/Makefile index 3b198b52..ad139cf4 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -34,6 +34,8 @@ apidoc: @python $(SOURCEDIR)/remove_string.py @echo "Removing duplicated files" @python $(SOURCEDIR)/remove_files.py + @echo "Renaming and updating file" + @python $(SOURCEDIR)/change_api_file_name.py diff --git a/docs/source/apis/index.rst b/docs/source/apis/index.rst index 6b4af1d2..5f5f7485 100644 --- a/docs/source/apis/index.rst +++ b/docs/source/apis/index.rst @@ -10,26 +10,28 @@ Core The core section of the LightRAG API documentation provides detailed information about the foundational components of the LightRAG system. These components are essential for the basic operations and serve as the building blocks for higher-level functionalities. .. autosummary:: - + core.component core.base_data_class + core.default_prompt_template core.model_client - core.component - core.data_components + + .. core.data_components + core.db - core.default_prompt_template - core.embedder core.functional + core.generator - core.memory - core.parameter - core.prompt_builder - core.retriever core.string_parser + core.embedder + core.retriever + .. core.memory + + core.prompt_builder core.tokenizer core.func_tool core.tool_manager core.types - + core.parameter Components ----------- @@ -38,13 +40,28 @@ The components section of the LightRAG API documentation outlines the detailed s .. autosummary:: - components.agent - components.model_client - componnets.data_process - .. components.reasoning - - components.retriever - components.output_parsers + components.agent.react + + components.model_client.anthropic_client + components.model_client.cohere_client + components.model_client.google_client + components.model_client.groq_client + components.model_client.openai_client + components.model_client.transformers_client + components.model_client.utils + + components.data_process.data_components + components.data_process.text_splitter + + components.reasoning.chain_of_thought + + components.retriever.bm25_retriever + components.retriever.faiss_retriever + components.retriever.llm_retriever + components.retriever.postgres_retriever + components.retriever.reranker_retriever + + components.output_parsers.outputs Evaluation diff --git a/docs/source/change_api_file_name.py b/docs/source/change_api_file_name.py new file mode 100644 index 00000000..bbf7a00f --- /dev/null +++ b/docs/source/change_api_file_name.py @@ -0,0 +1,56 @@ +import os +import re + +def update_file_content(directory): + module_name = directory.split("/")[-1] + + for filename in os.listdir(directory): + if filename.endswith(".rst") and "index" not in filename: + filepath = os.path.join(directory, filename) + with open(filepath, "r+", encoding='utf-8') as file: + lines = file.readlines() + modified = False # To track if modifications have been made + for i in range(len(lines) - 1): + line = lines[i].strip() + next_line = lines[i + 1].strip() + + # Check if the next line is a title underline + if next_line == "=" * len(next_line) and not modified: + # Check if the current line starts with the module_name + if line.startswith(module_name): + # Replace the full module path with only the last segment + new_title = line.split('.')[-1] + lines[i] = new_title + '\n' # Update the title line + modified = True # Mark that modification has been made + # No need to break since we are preserving the rest of the content + + # Rewind and update the file only if modifications were made + if modified: + file.seek(0) + file.writelines(lines) + file.truncate() # Ensure the file is cut off at the new end if it's shorter + print(f"Updated {filepath}") + +# def rename_files(directory): +# remove_prefix = directory.split("/")[-1] + "." +# for filename in os.listdir(directory): +# if filename.endswith(".rst") and remove_prefix in filename: +# new_filename = filename.replace(remove_prefix, '') +# os.rename(os.path.join(directory, filename), os.path.join(directory, new_filename)) +# print(f"Renamed {filename} to {new_filename}") + + +if __name__ == "__main__": + # Specify the directory or directories you want to process + directories = [ + "./source/apis/core", + "./source/apis/components", + "./source/apis/utils", + "./source/apis/eval", + "./source/apis/tracing", + "./source/apis/optim", + ] + for diretory in directories: + update_file_content(diretory) + # rename_files(diretory) + # rename_and_update_files(dir) \ No newline at end of file