Skip to content

Commit f955051

Browse files
authored
Merge pull request #654 from pinecone-io/claude/sdk-docs-broken-links-ad9424
docs(sphinx): redirect pre-10.0 page URLs and publish a sitemap
2 parents 52185a4 + 0fbf0e1 commit f955051

4 files changed

Lines changed: 171 additions & 1 deletion

File tree

docs/_templates/redirect.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>This page has moved</title>
6+
<link rel="canonical" href="${to_uri}">
7+
<meta http-equiv="refresh" content="0; url=${to_uri}">
8+
<script>
9+
(function () {
10+
var target = "${to_uri}";
11+
var hash = window.location.hash;
12+
// Classes that were renamed or moved to a different page in 10.0. Each row is
13+
// the old autodoc id, the reference/ page the class now lives on, and its new
14+
// id. A hash is either the class id itself or that id followed by ".<member>",
15+
// and the member name is kept. Old ids are unique across the old pages, so
16+
// one table serves every stub that forwards into reference/.
17+
var classes = [
18+
["pinecone.db_data.Index", "sync-index.html", "pinecone.index.Index"],
19+
["pinecone.db_data.IndexAsyncio", "async-index.html", "pinecone.async_client.async_index.AsyncIndex"],
20+
["pinecone.inference.Inference", "pinecone.html", "pinecone.client.inference.Inference"],
21+
["pinecone.inference.AsyncioInference", "async-pinecone.html", "pinecone.async_client.inference.AsyncInference"],
22+
["pinecone.PineconeAsyncio", "async-pinecone.html", "pinecone.async_client.pinecone.AsyncPinecone"],
23+
["pinecone.grpc.PineconeGRPC", "pinecone.html", "pinecone.Pinecone"],
24+
["pinecone.grpc.GRPCIndex", "grpc.html", "pinecone.grpc.GrpcIndex"],
25+
["pinecone.Admin", "admin.html", "pinecone.admin.Admin"],
26+
["pinecone.admin.resources.ApiKeyResource", "admin.html", "pinecone.admin.api_keys.ApiKeys"],
27+
["pinecone.admin.resources.OrganizationResource", "admin.html", "pinecone.admin.organizations.Organizations"],
28+
["pinecone.admin.resources.ProjectResource", "admin.html", "pinecone.admin.projects.Projects"]
29+
];
30+
// Section anchors the old landing page linked to, which now map to a whole page.
31+
var sections = {
32+
"rest.html#db-data-plane": "sync-index.html",
33+
"asyncio.html#db-data-plane": "async-index.html",
34+
"grpc.html#db-data-plane": "grpc.html"
35+
};
36+
var page = window.location.pathname.split("/").pop();
37+
var dir = "reference/";
38+
var moved = sections[page + hash];
39+
if (target.indexOf("#") !== -1) {
40+
// The target names its own section; the old fragment has nothing to add.
41+
hash = "";
42+
} else if (moved) {
43+
target = dir + moved;
44+
hash = "";
45+
} else if (hash && target.indexOf(dir) === 0) {
46+
var id = hash.substring(1);
47+
for (var i = 0; i < classes.length; i++) {
48+
var oldId = classes[i][0];
49+
if (id === oldId || id.indexOf(oldId + ".") === 0) {
50+
target = dir + classes[i][1];
51+
hash = "#" + classes[i][2] + id.substring(oldId.length);
52+
break;
53+
}
54+
}
55+
}
56+
window.location.replace(target + hash);
57+
})();
58+
</script>
59+
</head>
60+
<body>
61+
<p>This page has moved to <a href="${to_uri}">${to_uri}</a>.</p>
62+
</body>
63+
</html>

docs/conf.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"sphinx_copybutton",
2020
"sphinx_tabs.tabs",
2121
"myst_parser",
22+
"sphinx_reredirects",
23+
"sphinx_sitemap",
2224
]
2325

2426
html_theme = "furo"
@@ -27,6 +29,39 @@
2729
html_static_path = ["_static"]
2830
html_title = "Python SDK documentation"
2931

32+
# Published at this URL by .github/workflows/build-and-publish-docs.yaml. Sphinx
33+
# emits <link rel="canonical"> on every page from it and sphinx-sitemap needs it
34+
# to write absolute URLs.
35+
html_baseurl = "https://sdk.pinecone.io/python/"
36+
sitemap_url_scheme = "{link}"
37+
# Viewcode source listings and the generated index pages carry no content of
38+
# their own; keep the sitemap to pages worth a search result.
39+
sitemap_excludes = ["_modules/*", "search.html", "genindex.html", "py-modindex.html"]
40+
41+
# Pages the 10.0 restructure removed. Each becomes a stub that forwards to its
42+
# replacement and carries autodoc anchors across, so search results, bookmarks,
43+
# and blog links written against the flat pre-10.0 layout keep resolving.
44+
redirect_html_template_file = "_templates/redirect.html"
45+
redirects = {
46+
"rest": "reference/pinecone.html",
47+
"asyncio": "reference/async-pinecone.html",
48+
"grpc": "reference/grpc.html",
49+
"admin": "reference/admin.html",
50+
"upgrading": "migration/v10-migration.html",
51+
"client-configuration": "getting-started/authentication.html",
52+
"working-with-indexes": "how-to/indexes/serverless.html",
53+
"db_control/collections": "../how-to/collections.html",
54+
"db_control/serverless-indexes": "../how-to/indexes/serverless.html",
55+
"db_control/pod-indexes": "../how-to/indexes/pod.html",
56+
"db_control/shared-index-actions": "../how-to/indexes/serverless.html",
57+
"db_control/shared-index-configs": "../how-to/indexes/serverless.html",
58+
"db_data/index-usage-byov": "../how-to/vectors/upsert-and-query.html",
59+
"inference/inference-api": "../how-to/inference/embeddings.html",
60+
# Published with the 10.0 release candidates, removed when the preview
61+
# namespace graduated.
62+
"reference/preview": "../migration/v10-migration.html#preview-namespace-removed",
63+
}
64+
3065
exclude_patterns = [
3166
"_build",
3267
"Thumbs.db",

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ docs = [
5252
"myst-parser>=4.0",
5353
"sphinx-copybutton",
5454
"sphinx-tabs",
55+
"sphinx-reredirects>=0.1.6",
56+
"sphinx-sitemap>=2.9.0",
5557
]
5658

5759
[project.urls]

uv.lock

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

0 commit comments

Comments
 (0)