mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 14:49:29 +00:00
add experimental ref (#8435)
This commit is contained in:
parent
fab24457bc
commit
2db2987b1b
1
.gitignore
vendored
1
.gitignore
vendored
@ -162,6 +162,7 @@ docs/.docusaurus/
|
|||||||
docs/.cache-loader/
|
docs/.cache-loader/
|
||||||
docs/_dist
|
docs/_dist
|
||||||
docs/api_reference/api_reference.rst
|
docs/api_reference/api_reference.rst
|
||||||
|
docs/api_reference/experimental_api_reference.rst
|
||||||
docs/api_reference/_build
|
docs/api_reference/_build
|
||||||
docs/api_reference/*/
|
docs/api_reference/*/
|
||||||
!docs/api_reference/_static/
|
!docs/api_reference/_static/
|
||||||
|
@ -23,6 +23,7 @@ from sphinx.util.docutils import SphinxDirective
|
|||||||
_DIR = Path(__file__).parent.absolute()
|
_DIR = Path(__file__).parent.absolute()
|
||||||
sys.path.insert(0, os.path.abspath("."))
|
sys.path.insert(0, os.path.abspath("."))
|
||||||
sys.path.insert(0, os.path.abspath("../../libs/langchain"))
|
sys.path.insert(0, os.path.abspath("../../libs/langchain"))
|
||||||
|
sys.path.insert(0, os.path.abspath("../../libs/experimental"))
|
||||||
|
|
||||||
with (_DIR.parents[1] / "libs" / "langchain" / "pyproject.toml").open("r") as f:
|
with (_DIR.parents[1] / "libs" / "langchain" / "pyproject.toml").open("r") as f:
|
||||||
data = toml.load(f)
|
data = toml.load(f)
|
||||||
|
@ -5,13 +5,15 @@ from pathlib import Path
|
|||||||
|
|
||||||
ROOT_DIR = Path(__file__).parents[2].absolute()
|
ROOT_DIR = Path(__file__).parents[2].absolute()
|
||||||
PKG_DIR = ROOT_DIR / "libs" / "langchain" / "langchain"
|
PKG_DIR = ROOT_DIR / "libs" / "langchain" / "langchain"
|
||||||
|
EXP_DIR = ROOT_DIR / "libs" / "experimental" / "langchain_experimental"
|
||||||
WRITE_FILE = Path(__file__).parent / "api_reference.rst"
|
WRITE_FILE = Path(__file__).parent / "api_reference.rst"
|
||||||
|
EXP_WRITE_FILE = Path(__file__).parent / "experimental_api_reference.rst"
|
||||||
|
|
||||||
|
|
||||||
def load_members() -> dict:
|
def load_members(dir: Path) -> dict:
|
||||||
members: dict = {}
|
members: dict = {}
|
||||||
for py in glob.glob(str(PKG_DIR) + "/**/*.py", recursive=True):
|
for py in glob.glob(str(dir) + "/**/*.py", recursive=True):
|
||||||
module = py[len(str(PKG_DIR)) + 1 :].replace(".py", "").replace("/", ".")
|
module = py[len(str(dir)) + 1 :].replace(".py", "").replace("/", ".")
|
||||||
top_level = module.split(".")[0]
|
top_level = module.split(".")[0]
|
||||||
if top_level not in members:
|
if top_level not in members:
|
||||||
members[top_level] = {"classes": [], "functions": []}
|
members[top_level] = {"classes": [], "functions": []}
|
||||||
@ -26,12 +28,10 @@ def load_members() -> dict:
|
|||||||
return members
|
return members
|
||||||
|
|
||||||
|
|
||||||
def construct_doc(members: dict) -> str:
|
def construct_doc(pkg: str, members: dict) -> str:
|
||||||
full_doc = """\
|
full_doc = f"""\
|
||||||
.. _api_reference:
|
|
||||||
|
|
||||||
=============
|
=============
|
||||||
API Reference
|
``{pkg}`` API Reference
|
||||||
=============
|
=============
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -40,12 +40,12 @@ API Reference
|
|||||||
functions = _members["functions"]
|
functions = _members["functions"]
|
||||||
if not (classes or functions):
|
if not (classes or functions):
|
||||||
continue
|
continue
|
||||||
section = f":mod:`langchain.{module}`"
|
section = f":mod:`{pkg}.{module}`"
|
||||||
full_doc += f"""\
|
full_doc += f"""\
|
||||||
{section}
|
{section}
|
||||||
{'=' * (len(section) + 1)}
|
{'=' * (len(section) + 1)}
|
||||||
|
|
||||||
.. automodule:: langchain.{module}
|
.. automodule:: {pkg}.{module}
|
||||||
:no-members:
|
:no-members:
|
||||||
:no-inherited-members:
|
:no-inherited-members:
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ API Reference
|
|||||||
full_doc += f"""\
|
full_doc += f"""\
|
||||||
Classes
|
Classes
|
||||||
--------------
|
--------------
|
||||||
.. currentmodule:: langchain
|
.. currentmodule:: {pkg}
|
||||||
|
|
||||||
.. autosummary::
|
.. autosummary::
|
||||||
:toctree: {module}
|
:toctree: {module}
|
||||||
@ -70,7 +70,7 @@ Classes
|
|||||||
full_doc += f"""\
|
full_doc += f"""\
|
||||||
Functions
|
Functions
|
||||||
--------------
|
--------------
|
||||||
.. currentmodule:: langchain
|
.. currentmodule:: {pkg}
|
||||||
|
|
||||||
.. autosummary::
|
.. autosummary::
|
||||||
:toctree: {module}
|
:toctree: {module}
|
||||||
@ -83,10 +83,14 @@ Functions
|
|||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
members = load_members()
|
lc_members = load_members(PKG_DIR)
|
||||||
full_doc = construct_doc(members)
|
lc_doc = ".. _api_reference:\n\n" + construct_doc("langchain", lc_members)
|
||||||
with open(WRITE_FILE, "w") as f:
|
with open(WRITE_FILE, "w") as f:
|
||||||
f.write(full_doc)
|
f.write(lc_doc)
|
||||||
|
exp_members = load_members(EXP_DIR)
|
||||||
|
exp_doc = ".. _experimental_api_reference:\n\n" + construct_doc("langchain_experimental", exp_members)
|
||||||
|
with open(EXP_WRITE_FILE, "w") as f:
|
||||||
|
f.write(exp_doc)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -45,6 +45,9 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="sk-nav-link nav-link" href="{{ pathto('api_reference') }}">API</a>
|
<a class="sk-nav-link nav-link" href="{{ pathto('api_reference') }}">API</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="sk-nav-link nav-link" href="{{ pathto('experimental_api_reference') }}">Experimental</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="sk-nav-link nav-link" target="_blank" rel="noopener noreferrer" href="https://python.langchain.com/">Python Docs</a>
|
<a class="sk-nav-link nav-link" target="_blank" rel="noopener noreferrer" href="https://python.langchain.com/">Python Docs</a>
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user