| |
| |
| |
| |
| |
|
|
| |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| import datetime |
| import importlib |
| import inspect |
| import os |
| import posixpath |
|
|
| from sphinx.application import Sphinx |
| from sphinx.writers.html5 import HTML5Translator |
|
|
| |
|
|
| project = "Sentence Transformers" |
| copyright = str(datetime.datetime.now().year) |
| author = "Nils Reimers, Tom Aarsen" |
|
|
|
|
| |
|
|
| |
| |
| |
| extensions = [ |
| "sphinx.ext.napoleon", |
| "sphinx.ext.autodoc", |
| "myst_parser", |
| "sphinx_markdown_tables", |
| "sphinx_copybutton", |
| "sphinx.ext.intersphinx", |
| "sphinx.ext.linkcode", |
| "sphinx_inline_tabs", |
| "sphinxcontrib.mermaid", |
| "sphinx_toolbox.collapse", |
| ] |
|
|
| |
| templates_path = ["_templates"] |
|
|
| |
| |
| |
| include_patterns = [ |
| "docs/**", |
| "sentence_transformers/**/.py", |
| "examples/**", |
| "index.rst", |
| ] |
|
|
| intersphinx_mapping = { |
| "datasets": ("https://huggingface.co/docs/datasets/main/en/", None), |
| "transformers": ("https://huggingface.co/docs/transformers/main/en/", None), |
| "huggingface_hub": ("https://huggingface.co/docs/huggingface_hub/main/en/", None), |
| "optimum": ("https://huggingface.co/docs/optimum/main/en/", None), |
| "peft": ("https://huggingface.co/docs/peft/main/en/", None), |
| "torch": ("https://pytorch.org/docs/stable/", None), |
| } |
|
|
|
|
| |
|
|
| |
| |
| |
| html_theme = "sphinx_rtd_theme" |
|
|
| html_theme_options = { |
| "logo_only": True, |
| "canonical_url": "https://www.sbert.net", |
| "collapse_navigation": False, |
| "navigation_depth": 3, |
| } |
|
|
| |
| |
| |
| html_static_path = ["_static", "img/hf-logo.svg"] |
|
|
| |
| |
| html_extra_path = [".htaccess"] |
|
|
| html_css_files = [ |
| "css/custom.css", |
| ] |
|
|
| html_js_files = [ |
| "js/custom.js", |
| ] |
|
|
| html_show_sourcelink = False |
| html_context = { |
| "display_github": True, |
| "github_user": "UKPLab", |
| "github_repo": "sentence-transformers", |
| "github_version": "master/", |
| } |
|
|
| html_logo = "img/logo.png" |
| html_favicon = "img/favicon.ico" |
|
|
| autoclass_content = "both" |
|
|
| |
| myst_heading_anchors = 3 |
|
|
|
|
| |
| def linkcode_resolve(domain, info): |
| |
| if domain == "js" or info["module"] == "connect4": |
| return |
|
|
| assert domain == "py", "expected only Python objects" |
|
|
| mod = importlib.import_module(info["module"]) |
| if "." in info["fullname"]: |
| objname, attrname = info["fullname"].split(".") |
| obj = getattr(mod, objname) |
| try: |
| |
| obj = getattr(obj, attrname) |
| except AttributeError: |
| |
| return None |
| else: |
| obj = getattr(mod, info["fullname"]) |
| obj = inspect.unwrap(obj) |
|
|
| try: |
| file = inspect.getsourcefile(obj) |
| lines = inspect.getsourcelines(obj) |
| except TypeError: |
| |
| return None |
| file = os.path.relpath(file, os.path.abspath("..")) |
| if not file.startswith("sentence_transformers"): |
| |
| return None |
| start, end = lines[1], lines[1] + len(lines[0]) - 1 |
|
|
| return f"https://github.com/UKPLab/sentence-transformers/blob/master/{file}#L{start}-L{end}" |
|
|
|
|
| def visit_download_reference(self, node): |
| root = "https://github.com/UKPLab/sentence-transformers/tree/master" |
| atts = {"class": "reference download", "download": ""} |
|
|
| if not self.builder.download_support: |
| self.context.append("") |
| elif "refuri" in node: |
| atts["class"] += " external" |
| atts["href"] = node["refuri"] |
| self.body.append(self.starttag(node, "a", "", **atts)) |
| self.context.append("</a>") |
| elif "reftarget" in node and "refdoc" in node: |
| atts["class"] += " external" |
| atts["href"] = posixpath.join(root, os.path.dirname(node["refdoc"]), node["reftarget"]) |
| self.body.append(self.starttag(node, "a", "", **atts)) |
| self.context.append("</a>") |
| else: |
| self.context.append("") |
|
|
|
|
| HTML5Translator.visit_download_reference = visit_download_reference |
|
|
|
|
| def setup(app: Sphinx): |
| pass |
|
|