Skip to content

Commit 12c0e9b

Browse files
authored
fix(docs): local API reference documentation build (#32271)
ensure all relevant packages are correctly processed - cli wasn't included, also fix ValueError
1 parent ed682ae commit 12c0e9b

File tree

9 files changed

+19
-37
lines changed

9 files changed

+19
-37
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ docs_linkcheck:
4141
## api_docs_build: Build the API Reference documentation.
4242
api_docs_build: clean
4343
@echo "📖 Building API Reference documentation..."
44+
uv pip install -e libs/cli
4445
uv run --group docs python docs/api_reference/create_api_rst.py
4546
cd docs/api_reference && uv run --group docs make html
4647
uv run --group docs python docs/api_reference/scripts/custom_formatter.py docs/api_reference/_build/html/

docs/api_reference/create_api_rst.py

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ def _load_package_modules(
202202
if file_path.name.startswith("_"):
203203
continue
204204

205+
if "integration_template" in file_path.parts:
206+
continue
207+
208+
if "project_template" in file_path.parts:
209+
continue
210+
205211
relative_module_name = file_path.relative_to(package_path)
206212

207213
# Skip if any module part starts with an underscore
@@ -495,16 +501,7 @@ def _package_namespace(package_name: str) -> str:
495501

496502
def _package_dir(package_name: str = "langchain") -> Path:
497503
"""Return the path to the directory containing the documentation."""
498-
if package_name in (
499-
"langchain",
500-
"langchain_v1",
501-
"experimental",
502-
"community",
503-
"core",
504-
"cli",
505-
"text-splitters",
506-
"standard-tests",
507-
):
504+
if (ROOT_DIR / "libs" / package_name).exists():
508505
return ROOT_DIR / "libs" / package_name / _package_namespace(package_name)
509506
else:
510507
return (
@@ -666,18 +663,12 @@ def main(dirs: Optional[list] = None) -> None:
666663
print("Starting to build API reference files.")
667664
if not dirs:
668665
dirs = [
669-
dir_
670-
for dir_ in os.listdir(ROOT_DIR / "libs")
671-
if dir_ not in ("cli", "partners", "packages.yml")
672-
and "pyproject.toml" in os.listdir(ROOT_DIR / "libs" / dir_)
673-
]
674-
dirs += [
675-
dir_
676-
for dir_ in os.listdir(ROOT_DIR / "libs" / "partners")
677-
if os.path.isdir(ROOT_DIR / "libs" / "partners" / dir_)
678-
and "pyproject.toml" in os.listdir(ROOT_DIR / "libs" / "partners" / dir_)
666+
p.parent.name
667+
for p in (ROOT_DIR / "libs").rglob("pyproject.toml")
668+
# Exclude packages that are not directly under libs/ or libs/partners/
669+
if p.parent.parent.name in ("libs", "partners")
679670
]
680-
for dir_ in dirs:
671+
for dir_ in sorted(dirs):
681672
# Skip any hidden directories
682673
# Some of these could be present by mistake in the code base
683674
# e.g., .pytest_cache from running tests from the wrong location.
@@ -688,7 +679,7 @@ def main(dirs: Optional[list] = None) -> None:
688679
print("Building package:", dir_)
689680
_build_rst_file(package_name=dir_)
690681

691-
_build_index(dirs)
682+
_build_index(sorted(dirs))
692683
print("API reference files built.")
693684

694685

libs/cli/langchain_cli/cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ def serve(
6767
] = None,
6868
) -> None:
6969
"""Start the LangServe app, whether it's a template or an app."""
70-
# see if is a template
7170
try:
7271
project_dir = get_package_root()
7372
pyproject = project_dir / "pyproject.toml"
7473
get_langserve_export(pyproject)
75-
except KeyError:
74+
except (KeyError, FileNotFoundError):
7675
# not a template
7776
app_namespace.serve(port=port, host=host)
7877
else:

libs/cli/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/partners/chroma/langchain_chroma/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
"""This is the langchain_chroma package.
2-
3-
It contains the Chroma class for handling various tasks.
4-
"""
5-
61
from langchain_chroma.vectorstores import Chroma
72

83
__all__ = [
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"""This package provides the Perplexity integration for LangChain."""
2-
31
from langchain_perplexity.chat_models import ChatPerplexity
42

53
__all__ = ["ChatPerplexity"]
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"""This package provides the xAI integration for LangChain."""
2-
31
from langchain_xai.chat_models import ChatXAI
42

53
__all__ = ["ChatXAI"]

libs/partners/xai/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ target-version = "py39"
5555

5656
[tool.ruff.lint]
5757
select = ["E", "F", "I", "D", "UP", "S"]
58-
ignore = [ "UP007", ]
58+
ignore = [ "UP007", "D104", ]
5959

6060
[tool.coverage.run]
6161
omit = ["tests/*"]
@@ -79,4 +79,4 @@ convention = "google"
7979
"tests/**/*.py" = [
8080
"S101", # Tests need assertions
8181
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
82-
]
82+
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Base Test classes for standard testing.
22
33
To learn how to use these classes, see the
4-
`Integration standard testing <https://python.langchain.com/docs/contributing/how_to/integrations/standard_tests/>`_
4+
`integration standard testing <https://python.langchain.com/docs/contributing/how_to/integrations/standard_tests/>`__
55
guide.
66
"""

0 commit comments

Comments
 (0)