| """Configuration file for the Sphinx documentation builder.""" |
|
|
| |
| |
| |
| |
| |
|
|
| |
|
|
| import json |
| import os |
| import sys |
| from pathlib import Path |
|
|
| import toml |
| from docutils import nodes |
| from docutils.parsers.rst.directives.admonitions import BaseAdmonition |
| from docutils.statemachine import StringList |
| from sphinx.util.docutils import SphinxDirective |
|
|
| |
| |
| |
|
|
| _DIR = Path(__file__).parent.absolute() |
| sys.path.insert(0, os.path.abspath(".")) |
| sys.path.insert(0, os.path.abspath("../../libs/langchain")) |
|
|
| with (_DIR.parents[1] / "libs" / "langchain" / "pyproject.toml").open("r") as f: |
| data = toml.load(f) |
| with (_DIR / "guide_imports.json").open("r") as f: |
| imported_classes = json.load(f) |
|
|
|
|
| class ExampleLinksDirective(SphinxDirective): |
| """Directive to generate a list of links to examples. |
| |
| We have a script that extracts links to API reference docs |
| from our notebook examples. This directive uses that information |
| to backlink to the examples from the API reference docs.""" |
|
|
| has_content = False |
| required_arguments = 1 |
|
|
| def run(self): |
| """Run the directive. |
| |
| Called any time :example_links:`ClassName` is used |
| in the template *.rst files.""" |
| class_or_func_name = self.arguments[0] |
| links = imported_classes.get(class_or_func_name, {}) |
| list_node = nodes.bullet_list() |
| for doc_name, link in sorted(links.items()): |
| item_node = nodes.list_item() |
| para_node = nodes.paragraph() |
| link_node = nodes.reference() |
| link_node["refuri"] = link |
| link_node.append(nodes.Text(doc_name)) |
| para_node.append(link_node) |
| item_node.append(para_node) |
| list_node.append(item_node) |
| if list_node.children: |
| title_node = nodes.rubric() |
| title_node.append(nodes.Text(f"Examples using {class_or_func_name}")) |
| return [title_node, list_node] |
| return [list_node] |
|
|
|
|
| class Beta(BaseAdmonition): |
| required_arguments = 0 |
| node_class = nodes.admonition |
|
|
| def run(self): |
| self.content = self.content or StringList( |
| [ |
| ( |
| "This feature is in beta. It is actively being worked on, so the " |
| "API may change." |
| ) |
| ] |
| ) |
| self.arguments = self.arguments or ["Beta"] |
| return super().run() |
|
|
|
|
| def setup(app): |
| app.add_directive("example_links", ExampleLinksDirective) |
| app.add_directive("beta", Beta) |
| app.connect("autodoc-skip-member", skip_private_members) |
|
|
|
|
| def skip_private_members(app, what, name, obj, skip, options): |
| if skip: |
| return True |
| if hasattr(obj, "__doc__") and obj.__doc__ and ":private:" in obj.__doc__: |
| return True |
| if name == "__init__" and obj.__objclass__ is object: |
| |
| return True |
| return None |
|
|
|
|
| |
|
|
| project = "🦜🔗 LangChain" |
| copyright = "2023, LangChain Inc" |
| author = "LangChain, Inc" |
|
|
| html_favicon = "_static/img/brand/favicon.png" |
| html_last_updated_fmt = "%b %d, %Y" |
|
|
|
|
| |
|
|
| |
| |
| |
| extensions = [ |
| "sphinx.ext.autodoc", |
| "sphinx.ext.autodoc.typehints", |
| "sphinx.ext.autosummary", |
| "sphinx.ext.napoleon", |
| "sphinx.ext.viewcode", |
| "sphinxcontrib.autodoc_pydantic", |
| "IPython.sphinxext.ipython_console_highlighting", |
| "myst_parser", |
| "_extensions.gallery_directive", |
| "sphinx_design", |
| "sphinx_copybutton", |
| "sphinxcontrib.googleanalytics", |
| ] |
| source_suffix = [".rst", ".md"] |
|
|
| |
| |
| |
| autodoc_pydantic_model_show_json = False |
| autodoc_pydantic_field_list_validators = False |
| autodoc_pydantic_config_members = False |
| autodoc_pydantic_model_show_config_summary = False |
| autodoc_pydantic_model_show_validator_members = False |
| autodoc_pydantic_model_show_validator_summary = False |
| autodoc_pydantic_model_signature_prefix = "class" |
| autodoc_pydantic_field_signature_prefix = "param" |
| autodoc_member_order = "groupwise" |
| autoclass_content = "both" |
| autodoc_typehints_format = "short" |
| autodoc_typehints = "both" |
|
|
| |
| templates_path = ["templates"] |
|
|
| |
| |
| |
| exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] |
|
|
|
|
| |
|
|
| |
| |
| |
| |
| html_theme = "pydata_sphinx_theme" |
|
|
| |
| |
| |
| html_theme_options = { |
| |
| "sidebar_includehidden": True, |
| "use_edit_page_button": False, |
| |
| |
| |
| |
| |
| |
| |
| "show_prev_next": False, |
| "search_bar_text": "Search", |
| "navigation_with_keys": True, |
| "collapse_navigation": True, |
| "navigation_depth": 3, |
| "show_nav_level": 1, |
| "show_toc_level": 3, |
| "navbar_align": "left", |
| "header_links_before_dropdown": 5, |
| "header_dropdown_text": "Integrations", |
| "logo": { |
| "image_light": "_static/wordmark-api.svg", |
| "image_dark": "_static/wordmark-api-dark.svg", |
| }, |
| "surface_warnings": True, |
| |
| "navbar_start": ["navbar-logo"], |
| |
| "navbar_center": ["navbar-nav"], |
| "navbar_end": ["langchain_docs", "theme-switcher", "navbar-icon-links"], |
| |
| "navbar_persistent": ["search-field"], |
| "article_header_start": ["breadcrumbs"], |
| "article_header_end": [], |
| "article_footer_items": [], |
| "content_footer_items": [], |
| |
| |
| "footer_start": ["copyright"], |
| "footer_center": [], |
| "footer_end": [], |
| |
| |
| |
| |
| |
| |
| |
| "icon_links": [ |
| { |
| |
| "name": "GitHub", |
| |
| "url": "https://github.com/langchain-ai/langchain", |
| |
| "icon": "fa-brands fa-square-github", |
| |
| "type": "fontawesome", |
| }, |
| { |
| "name": "X / Twitter", |
| "url": "https://twitter.com/langchainai", |
| "icon": "fab fa-twitter-square", |
| }, |
| ], |
| "icon_links_label": "Quick Links", |
| "external_links": [], |
| } |
|
|
|
|
| html_context = { |
| "display_github": True, |
| "github_user": "langchain-ai", |
| "github_repo": "langchain", |
| "github_version": "master", |
| "conf_py_path": "/docs/api_reference", |
| } |
|
|
| |
| |
| |
| html_static_path = ["_static"] |
|
|
| |
| |
| html_css_files = ["css/custom.css"] |
| html_use_index = False |
|
|
| myst_enable_extensions = ["colon_fence"] |
|
|
| |
| autosummary_generate = True |
|
|
| html_copy_source = False |
| html_show_sourcelink = False |
|
|
| |
| html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "") |
|
|
| googleanalytics_id = "G-9B66JQQH2F" |
|
|
| |
| if os.environ.get("READTHEDOCS", "") == "True": |
| html_context["READTHEDOCS"] = True |
|
|
| master_doc = "index" |
|
|