Skip to content

Commit 84456a0

Browse files
committed
Update docs
1 parent e72a1ac commit 84456a0

7 files changed

Lines changed: 416 additions & 176 deletions

File tree

docs/configuration.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!doctype html>
2-
<html lang="en">
2+
<html lang="en" data-pkg="py">
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -47,7 +47,7 @@
4747
</header>
4848

4949
<aside class="sidebar">
50-
<div class="sidebar-brand">RMP API Docs</div>
50+
<div class="sidebar-brand">RMP API<span class="brand-sub">Python Client</span></div>
5151
<nav>
5252
<ul>
5353
<li><a href="index.html">Home</a></li>

docs/extras.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html lang="en" data-pkg="py">
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -23,7 +23,7 @@
2323
</header>
2424

2525
<aside class="sidebar">
26-
<div class="sidebar-brand">RMP API Docs</div>
26+
<div class="sidebar-brand">RMP API<span class="brand-sub">Python Client</span></div>
2727
<nav><ul>
2828
<li><a href="index.html">Home</a></li>
2929
<li><a href="usage.html">Usage</a></li>

docs/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!doctype html>
2-
<html lang="en">
2+
<html lang="en" data-pkg="py">
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -47,7 +47,7 @@
4747
</header>
4848

4949
<aside class="sidebar">
50-
<div class="sidebar-brand">RMP API Docs</div>
50+
<div class="sidebar-brand">RMP API<span class="brand-sub">Python Client</span></div>
5151
<nav>
5252
<ul>
5353
<li><a href="index.html" class="active">Home</a></li>
@@ -64,7 +64,7 @@ <h1>RateMyProfessors API Client</h1>
6464
<div class="badges">
6565
<a href="https://pypi.org/project/ratemyprofessors-client/"
6666
><img
67-
src="https://img.shields.io/pypi/v/ratemyprofessors-client?color=10b981&cacheSeconds=300"
67+
src="https://img.shields.io/pypi/v/ratemyprofessors-client?color=1b6e53&cacheSeconds=300"
6868
alt="PyPI"
6969
/></a>
7070
<a href="https://pypi.org/project/ratemyprofessors-client/"

docs/reference.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html lang="en" data-pkg="py">
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -23,7 +23,7 @@
2323
</header>
2424

2525
<aside class="sidebar">
26-
<div class="sidebar-brand">RMP API Docs</div>
26+
<div class="sidebar-brand">RMP API<span class="brand-sub">Python Client</span></div>
2727
<nav><ul>
2828
<li><a href="index.html">Home</a></li>
2929
<li><a href="usage.html">Usage</a></li>

docs/script.js

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(function () {
2-
var MOON = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>';
3-
var SUN = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>';
2+
var MOON = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>';
3+
var SUN = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>';
44

55
function isDark() {
66
return document.documentElement.classList.contains('dark');
@@ -28,8 +28,78 @@
2828

2929
buildTOC();
3030
if (typeof hljs !== 'undefined') hljs.highlightAll();
31+
decorateCodeBlocks();
3132
});
3233

34+
var LANG_LABELS = {
35+
bash: 'shell',
36+
sh: 'shell',
37+
python: 'python',
38+
typescript: 'ts',
39+
javascript: 'js',
40+
json: 'json',
41+
};
42+
43+
function decorateCodeBlocks() {
44+
var blocks = document.querySelectorAll('pre > code');
45+
blocks.forEach(function (code) {
46+
var pre = code.parentElement;
47+
48+
var match = (code.className || '').match(/language-([\w-]+)/);
49+
if (match) {
50+
var tag = document.createElement('span');
51+
tag.className = 'code-lang';
52+
tag.textContent = LANG_LABELS[match[1]] || match[1];
53+
pre.appendChild(tag);
54+
}
55+
56+
var btn = document.createElement('button');
57+
btn.className = 'code-copy';
58+
btn.type = 'button';
59+
btn.textContent = 'copy';
60+
btn.setAttribute('aria-label', 'Copy code to clipboard');
61+
btn.addEventListener('click', function () {
62+
copyText(code.innerText, function (ok) {
63+
btn.textContent = ok ? 'copied' : 'failed';
64+
btn.classList.add('copied');
65+
setTimeout(function () {
66+
btn.textContent = 'copy';
67+
btn.classList.remove('copied');
68+
}, 1600);
69+
});
70+
});
71+
pre.appendChild(btn);
72+
});
73+
}
74+
75+
function copyText(text, done) {
76+
if (navigator.clipboard && navigator.clipboard.writeText) {
77+
navigator.clipboard.writeText(text).then(
78+
function () { done(true); },
79+
function () { done(fallbackCopy(text)); }
80+
);
81+
} else {
82+
done(fallbackCopy(text));
83+
}
84+
}
85+
86+
function fallbackCopy(text) {
87+
var ta = document.createElement('textarea');
88+
ta.value = text;
89+
ta.style.position = 'fixed';
90+
ta.style.opacity = '0';
91+
document.body.appendChild(ta);
92+
ta.select();
93+
var ok = false;
94+
try {
95+
ok = document.execCommand('copy');
96+
} catch (e) {
97+
ok = false;
98+
}
99+
document.body.removeChild(ta);
100+
return ok;
101+
}
102+
33103
function buildTOC() {
34104
var list = document.getElementById('toc-list');
35105
var tocEl = document.querySelector('.toc');

0 commit comments

Comments
 (0)