Skip to content

Commit d809deb

Browse files
authored
Merge pull request #165 from leofang/new_docs
Prepare docs for sub-packages
2 parents 4451932 + fa8d482 commit d809deb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+877
-59
lines changed

cuda_bindings/docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?= -j auto
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build/html/${SPHINX_CUDA_BINDINGS_VER}
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -b help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -b $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

cuda_bindings/docs/README.md

Lines changed: 11 additions & 0 deletions

cuda_bindings/docs/build_docs.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
# SPHINX_CUDA_BINDINGS_VER is used to create a subdir under build/html
6+
# (the Makefile file for sphinx-build also honors it if defined)
7+
if [[ -z "${SPHINX_CUDA_BINDINGS_VER}" ]]; then
8+
export SPHINX_CUDA_BINDINGS_VER=$(python -c "from importlib.metadata import version; print(version('cuda-python'))" \
9+
| awk -F'+' '{print $1}')
10+
fi
11+
12+
# build the docs (in parallel)
13+
SPHINXOPTS="-j 4" make html
14+
15+
# for debugging/developing (conf.py), please comment out the above line and
16+
# use the line below instead, as we must build in serial to avoid getting
17+
# obsecure Sphinx errors
18+
#SPHINXOPTS="-v" make html
19+
20+
# to support version dropdown menu
21+
cp ./versions.json build/html
22+
23+
# to have a redirection page (to the latest docs)
24+
cp source/_templates/main.html build/html/index.html
25+
26+
# ensure that the latest docs is the one we built
27+
cp -r build/html/${SPHINX_CUDA_BINDINGS_VER} build/html/latest
28+
29+
# ensure that the Sphinx reference uses the latest docs
30+
cp build/html/latest/objects.inv build/html
File renamed without changes.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
function change_current_version(event) {
2+
event.preventDefault();
3+
4+
var selectedVersion = event.target.textContent;
5+
var currentVersion = document.getElementById('currentVersion');
6+
7+
// need to update both the on-screen state and the internal (persistent) storage
8+
currentVersion.textContent = selectedVersion;
9+
sessionStorage.setItem("currentVersion", selectedVersion);
10+
11+
// Navigate to the clicked URL
12+
window.location.href = event.target.href;
13+
}
14+
15+
16+
function add_version_dropdown(jsonLoc, targetLoc, currentVersion) {
17+
var otherVersionsDiv = document.getElementById('otherVersions');
18+
19+
fetch(jsonLoc)
20+
.then(function(response) {
21+
return response.json();
22+
})
23+
.then(function(data) {
24+
var versions = data;
25+
26+
if (Object.keys(versions).length >= 1) {
27+
var dlElement = document.createElement('dl');
28+
var dtElement = document.createElement('dt');
29+
dtElement.textContent = 'Versions';
30+
dlElement.appendChild(dtElement);
31+
32+
for (var ver in versions) {
33+
var url = versions[ver];
34+
var ddElement = document.createElement('dd');
35+
var aElement = document.createElement('a');
36+
aElement.setAttribute('href', targetLoc + url);
37+
aElement.textContent = ver;
38+
39+
if (ver === currentVersion) {
40+
var strongElement = document.createElement('strong');
41+
strongElement.appendChild(aElement);
42+
aElement = strongElement;
43+
}
44+
45+
ddElement.appendChild(aElement);
46+
// Attach event listeners to version links
47+
ddElement.addEventListener('click', change_current_version);
48+
dlElement.appendChild(ddElement);
49+
}
50+
51+
otherVersionsDiv.innerHTML = '';
52+
otherVersionsDiv.appendChild(dlElement);
53+
}
54+
})
55+
.catch(function(error) {
56+
console.error('Error fetching version.json:', error);
57+
});
58+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE HTML>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="refresh" content="0; url=latest/" />
6+
<link rel="canonical" href="latest/" />
7+
</head>
8+
<body>
9+
<p>If this page does not refresh automatically, then please direct your browser to
10+
<a href="latest/">our latest docs</a>.
11+
</p>
12+
</body>
13+
</html>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
2+
<span class="rst-current-version" data-toggle="rst-current-version">
3+
<span class="fa fa-book"> cuda-bindings</span>
4+
v: <span id="currentVersion">{{ version }}</span>
5+
<span class="fa fa-caret-down"></span>
6+
</span>
7+
<div class="rst-other-versions" id="otherVersions">
8+
<hr/>
9+
</div>
10+
</div>
11+
12+
<script src="{{ pathto('_static/javascripts/version_dropdown.js', 1) }}"></script>
13+
<script>
14+
var jsonLoc = "{{ pathto('../versions.json', 1) }}";
15+
var targetLoc = "{{ pathto('../', 1) }}";
16+
// note: sessionStorage is an html5 construct
17+
var currentVersion = sessionStorage.getItem("currentVersion") || "";
18+
if (!currentVersion) {
19+
currentVersion = document.getElementById('currentVersion').textContent; // default
20+
} else {
21+
document.getElementById('currentVersion').textContent = currentVersion; // update
22+
}
23+
add_version_dropdown(jsonLoc, targetLoc, currentVersion);
24+
</script>

0 commit comments

Comments
 (0)