Repository navigation
Expand file tree
/
Copy pathextra.js
More file actions
140 lines (127 loc) · 5.45 KB
/
Copy pathextra.js
File metadata and controls
140 lines (127 loc) · 5.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
function cleanupClipboardText(targetSelector) {
const targetElement = document.querySelector(targetSelector);
// exclude "Generic Prompt" and "Generic Output" spans from copy
const excludedClasses = ["gp", "go"];
const clipboardText = Array.from(targetElement.childNodes)
.filter(
(node) =>
!excludedClasses.some((className) =>
node?.classList?.contains(className),
),
)
.map((node) => node.textContent)
.filter((s) => s != "");
return clipboardText.join("").trim();
}
// Sets copy text to attributes lazily using an Intersection Observer.
function setCopyText() {
// The `data-clipboard-text` attribute allows for customized content in the copy
// See: https://www.npmjs.com/package/clipboard#copy-text-from-attribute
const attr = "clipboardText";
// all "copy" buttons whose target selector is a <code> element
const elements = document.querySelectorAll(
'button[data-clipboard-target$="code"]',
);
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
// target in the viewport that have not been patched
if (
entry.intersectionRatio > 0 &&
entry.target.dataset[attr] === undefined
) {
entry.target.dataset[attr] = cleanupClipboardText(
entry.target.dataset.clipboardTarget,
);
}
});
});
elements.forEach((elt) => {
observer.observe(elt);
});
}
// Using the document$ observable is particularly important if you are using instant loading since
// it will not result in a page refresh in the browser
// See `How to integrate with third-party JavaScript libraries` guideline:
// https://squidfunk.github.io/mkdocs-material/customization/?h=javascript#additional-javascript
document$.subscribe(function () {
setCopyText();
});
// Use client-side redirects for anchors that have moved.
// Other redirects should use `redirect_maps` in the `mkdocs.yml` file instead.
(function () {
let redirect_maps = {
"concepts/projects/#managing-dependencies":
"concepts/projects/dependencies/",
"concepts/projects/#project-metadata": "concepts/projects/layout/",
"concepts/projects/#defining-entry-points":
"concepts/projects/config/#entry-points",
"concepts/projects/#build-systems":
"concepts/projects/config/#build-systems",
"concepts/projects/#configuring-project-packaging":
"concepts/projects/config/#project-packaging",
"concepts/projects/#creating-projects": "concepts/projects/init/",
"concepts/projects/#project-environments":
"concepts/projects/layout/#the-project-environment",
"concepts/projects/#configuring-the-project-environment-path":
"concepts/projects/config/#project-environment-path",
"concepts/projects/#project-lockfile":
"concepts/projects/layout/#the-lockfile",
"concepts/projects/#platform-specific-dependencies":
"concepts/projects/dependencies/#platform-specific-dependencies",
"concepts/projects/#running-commands": "concepts/projects/run/",
"concepts/projects/#building-projects": "concepts/projects/build/",
"concepts/projects/#build-isolation":
"concepts/projects/config/#build-isolation",
"concepts/projects/dependencies/#dependency-specifiers-pep-508":
"concepts/projects/dependencies/#dependency-specifiers",
"concepts/projects/dependencies/#importing-dependencies":
68F4
div>
"concepts/projects/dependencies/#importing-dependencies-from-requirements-files",
"concepts/projects/layout/#pylock-toml":
"concepts/projects/layout/#relationship-to-pylock-toml",
"concepts/projects/run/#legacy-windows-scripts":
"concepts/projects/run/#legacy-scripts-on-windows",
"concepts/projects/sync/#checking-if-the-lockfile-is-up-to-date":
"concepts/projects/sync/#checking-the-lockfile",
"concepts/projects/sync/#retaining-extraneous-packages":
"concepts/projects/sync/#handling-of-extraneous-packages",
"concepts/authentication/#git-authentication":
"concepts/authentication/git/",
"concepts/authentication/#git-credential-helpers":
"concepts/authentication/git/#git-credential-helpers",
"concepts/authentication/#http-authentication":
"concepts/authentication/http/",
"concepts/authentication/#using-netrc-files":
"concepts/authentication/http/#using-netrc-files",
"concepts/authentication/#using-the-keyring":
"concepts/authentication/http/#using-the-keyring",
"concepts/authentication/#authentication-with-alternative-package-indexes":
"concepts/authentication/http/#authentication-with-alternative-package-indexes",
"concepts/authentication/#custom-ca-certificates":
"concepts/authentication/certificates/",
"concepts/authentication/#hugging-face-support":
"concepts/authentication/third-party/#hugging-face-support",
};
// The prefix for the site, see `site_dir` in `mkdocs.yml`
let site_dir = "uv";
function get_path() {
var path = window.location.pathname;
// Trim the site prefix
if (path.startsWith("/" + site_dir + "/")) {
path = path.slice(site_dir.length + 2);
}
// Always include a trailing `/`
if (!path.endsWith("/")) {
path = path + "/";
}
// Check for an anchor
var anchor = window.location.hash.substring(1);
if (!anchor) {
return path;
}
return path + "#" + anchor;
}
let path = get_path();
if (path && redirect_maps.hasOwnProperty(path)) {
window.location.replace("/" + site_dir + "/" + redirect_maps[path]);
}
})();