diff --git a/Makefile b/Makefile index eb1e3c09ab32b5fd687a9c6a1d12afe25f3cf070..9cded5de17de85b228d7e25cd35693b3906af8d6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ .PHONY: format lint +GIT_ROOT ?= $(shell git rev-parse --show-toplevel) + format: black . @@ -10,3 +12,7 @@ lint: test: pytest tests + +# Docs +watch-docs: ## Build and watch documentation + sphinx-autobuild docs/ docs/_build/html --open-browser --watch $(GIT_ROOT)/gpt_index/ diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000000000000000000000000000000000000..bbcf904b8a7d30fef3501aa03cde6770868a799b --- /dev/null +++ b/docs/README.md @@ -0,0 +1,54 @@ +# LlamaIndex Documentation + +## A guide for docs contributors + +The `docs` directory contains the sphinx source text for LlamaIndex docs, visit +https://gpt-index.readthedocs.io/ to read the full documentation. + +This guide is made for anyone who's interested in running LlamaIndex documentation locally, +making changes to it and make contributions. LlamaIndex is made by the thriving community +behind it, and you're always welcome to make contributions to the project and the +documentation. + +## Build Docs + +If you haven't already, clone the LlamaIndex Github repo to a local directory: + +```bash +git clone https://github.com/jerryjliu/llama_index.git && cd llama_index +``` + +Install all dependencies required for building docs (mainly `sphinx` and its extension): + +```bash +pip install -r docs/requirements.txt +``` + +Build the sphinx docs: + +```bash +cd docs +make html +``` + +The docs HTML files are now generated under `docs/_build/html` directory, you can preview +it locally with the following command: + +```bash +python -m http.server 8000 -d _build/html +``` + +And open your browser at http://0.0.0.0:8000/ to view the generated docs. + + +##### Watch Docs + +We recommend using sphinx-autobuild during development, which provides a live-reloading +server, that rebuilds the documentation and refreshes any open pages automatically when +changes are saved. This enables a much shorter feedback loop which can help boost +productivity when writing documentation. + +Simply run the following command from LlamaIndex project's root directory: +```bash +make watch-docs +``` diff --git a/docs/guides/primer/usage_pattern.md b/docs/guides/primer/usage_pattern.md index c8196c715d1c0c00a6fafd11dc0cb69c50e7e55e..282d844973921bfc028364a2f0050b4b4819e9e7 100644 --- a/docs/guides/primer/usage_pattern.md +++ b/docs/guides/primer/usage_pattern.md @@ -111,7 +111,7 @@ created for each index during index construction. You can access the docstore associated with a given index through `index.docstore`. -### Inserting Documents +### Inserting Documents or Nodes You can also take advantage of the `insert` capability of indices to insert Document objects one at a time instead of during index construction. @@ -125,9 +125,19 @@ for doc in documents: ``` -See the [Update Index How-To](/how_to/index_structs/update.md) for details and an example notebook. +If you want to insert nodes on directly you can use `insert_nodes` function +instead. -**NOTE**: An `insert_node` function is coming! +```python +from llama_index import GPTSimpleVectorIndex + +# nodes: Sequence[Node] +index = GPTSimpleVectorIndex([]) +index.insert_nodes(nodes) + +``` + +See the [Update Index How-To](/how_to/index_structs/update.md) for details and an example notebook. ### Customizing LLM's diff --git a/docs/requirements.txt b/docs/requirements.txt index 076588e514d5e5588f90187617dd660b41154a75..8d1db1b849bee2118b9090b8855f012cd24ad9a2 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -3,3 +3,5 @@ sphinx>=4.3.0 furo>=2023.3.27 docutils<0.17 myst-parser +sphinx-autobuild +sphinx_rtd_theme