Link API docs to GitHub source code, refs #464

This commit is contained in:
Simon Willison 2022-08-13 09:24:02 -07:00
commit 45e24deffe
2 changed files with 26 additions and 2 deletions

View file

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
from subprocess import Popen, PIPE
from beanbag_docutils.sphinx.ext.github import github_linkcode_resolve
# This file is execfile()d with the current directory set to its
# containing dir.
@ -30,7 +31,12 @@ from subprocess import Popen, PIPE
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["sphinx.ext.extlinks", "sphinx.ext.autodoc", "sphinx_copybutton"]
extensions = [
"sphinx.ext.extlinks",
"sphinx.ext.autodoc",
"sphinx_copybutton",
"sphinx.ext.linkcode",
]
autodoc_member_order = "bysource"
autodoc_typehints = "description"
@ -38,6 +44,18 @@ extlinks = {
"issue": ("https://github.com/simonw/sqlite-utils/issues/%s", "#"),
}
def linkcode_resolve(domain, info):
return github_linkcode_resolve(
domain=domain,
info=info,
allowed_module_names=["sqlite_utils"],
github_org_id="simonw",
github_repo_id="sqlite-utils",
branch="main",
)
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

View file

@ -32,7 +32,13 @@ setup(
],
extras_require={
"test": ["pytest", "black", "hypothesis", "cogapp"],
"docs": ["furo", "sphinx-autobuild", "codespell", "sphinx-copybutton"],
"docs": [
"furo",
"sphinx-autobuild",
"codespell",
"sphinx-copybutton",
"beanbag-docutils @ https://github.com/simonw/beanbag-docutils/archive/refs/heads/bytes-in-url.zip",
],
"mypy": [
"mypy",
"types-click",