Skip to content

Commit 454096a

Browse files
DOC: Fix version switcher code and update URLs and logos (#2279)
* add code for doc version switcher, new UXL URLs and logos * remove javascripts and htmls from copyright header check * update for 'latest' * set latest as 2025.2 * revert unneeded URL change * remove empty line * add copyright header for JS code
1 parent e8f9aa7 commit 454096a

File tree

12 files changed

+161
-8
lines changed

12 files changed

+161
-8
lines changed

.github/.licenserc.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ header:
4848
# Something in doc/
4949
- 'doc/daal4py/_static/style.css'
5050
- 'doc/daal4py/_templates/layout.html'
51-
- 'doc/sources/_static/style.css'
51+
- 'doc/sources/_static/custom.css'
5252
- 'doc/sources/_templates/footer.html'
5353
- 'doc/sources/_templates/layout.html'
54+
- 'doc/sources/_templates/versions.html'
5455
- 'doc/daal4py/third-party-programs.txt'
5556
- 'doc/third-party-programs-sklearnex.txt'
57+
- 'doc/versions.json'
5658
# requirements
5759
- 'dependencies-dev'
5860
- 'requirements*.txt'

doc/build-doc.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,28 @@ rsync -a --exclude='daal4py_data_science.ipynb' examples/notebooks/*.ipynb doc/$
2929

3030
# build the documentation
3131
cd doc
32-
export O="-W"
33-
make html
32+
export SPHINXOPTS="-W" # used by sphinx-build
33+
export O=${SPHINXOPTS} # makefile overrides SPHINXOPTS
34+
35+
# Build comes in two variants:
36+
# - As a standalone doc (for local development and CI)
37+
# - As a versioned build (for the deployed docs), triggerable by
38+
# passing argument '--gh-pages'.
39+
# In the first case, it will generate a page under '_build' with
40+
# an 'html' folder and a separate 'doctrees'. Only the 'html' part
41+
# is needed to render the docs locally.
42+
# In the second case, it will generate a versioned entry (year.month)
43+
# under '_build', with the doctrees inside that versioned folder.
44+
# Those are directly copyable to the 'gh-pages' branch to be deployed.
45+
if [[ "$*" == *"--gh-pages"* ]]; then
46+
export DOC_VERSION=$(python -c "from sources.conf import version; print(version)")
47+
export SPHINXPROJ=scikit-learn-intelex
48+
export BUILDDIR=_build
49+
export SOURCEDIR=sources
50+
51+
sphinx-build -b html $SOURCEDIR $BUILDDIR/$SPHINXPROJ/$DOC_VERSION
52+
cp versions.json $BUILDDIR/$SPHINXPROJ
53+
echo "<meta http-equiv=\"refresh\" content=\"0; URL='/$SPHINXPROJ/$DOC_VERSION/'\" / >" >> $BUILDDIR/$SPHINXPROJ/index.html
54+
else
55+
make html
56+
fi

doc/sources/_static/style.css renamed to doc/sources/_static/custom.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,11 @@ div.quotation {
121121

122122
a#wap_dns {display: none;}
123123

124+
125+
button#version-switcher-button {
126+
background-color: #2980b9;
127+
}
128+
129+
div#version-switcher-dropdown {
130+
display: inline;
131+
}

doc/sources/_static/favicon.png

745 Bytes
Loading

doc/sources/_static/favicons.png

-467 Bytes
Binary file not shown.
-7.24 KB
Binary file not shown.
31.9 KB
Loading
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright contributors to the oneDAL project
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
function load_versions(json){
15+
var button = document.getElementById('version-switcher-button')
16+
var container = document.getElementById('version-switcher-dropdown')
17+
var loc = window.location.href;
18+
var s = document.createElement('select');
19+
s.style = "border-radius:5px;"
20+
const versions = JSON.parse(json);
21+
for (entry of versions){
22+
var o = document.createElement('option');
23+
var optionText = '';
24+
if ('name' in entry){
25+
optionText = entry.name;
26+
}else{
27+
optionText = entry.version;
28+
}
29+
o.value = entry.url;
30+
if (current_version == entry.version){
31+
o.selected = true;
32+
}
33+
o.innerHTML = optionText;
34+
s.append(o);
35+
}
36+
s.addEventListener("change", ()=> {
37+
var current_url = new URL(window.location.href);
38+
var path = current_url.pathname;
39+
//strip version from path
40+
var page_path = path.substring(project_name.length+current_version.length+3);
41+
window.location.href = s.value + page_path;
42+
});
43+
container.append(s);
44+
}

doc/sources/_templates/layout.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{% block extrahead %}
33
<script defer type="text/javascript" src="https://www.intel.com/content/dam/www/global/wap/performance-config.js" ></script>
44
<script type="text/javascript">
5+
fetch("{{ switcher_url }}").then(response => response.text()).then(respText=> load_versions(respText));
56
// Configure TMS settings
67
var wapLocalCode = 'us-en'; // Dynamically set per localized site, see mapping table for values
78
var wapSection = "scikit-learn"; // WAP team will give you a unique section for your site
@@ -15,3 +16,8 @@
1516
}
1617
</script>
1718
{% endblock %}
19+
20+
{% block menu %}
21+
{% include "versions.html" %}
22+
{{ super() }}
23+
{% endblock %}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<div class="version-switcher__container dropdown">
2+
<script>
3+
current_version = "{{current_version}}"
4+
project_name = "{{project_name}}"
5+
</script>
6+
<div id="version-switcher-button"
7+
class="version-switcher__button"
8+
data-bs-toggle="dropdown"
9+
aria-haspopup="listbox"
10+
aria-controls="version-switcher-dropdown"
11+
aria-label="Version switcher list"
12+
style="display:inline-block;padding-left:10px;padding-right:10px;"
13+
>
14+
Choose version <!-- this text may get changed later by javascript -->
15+
<span class="caret"></span>
16+
</div>
17+
<div id="version-switcher-dropdown"
18+
class="version-switcher__menu dropdown-menu list-group-flush py-0"
19+
role="listbox" aria-labelledby="{{ button_id }}">
20+
<!-- dropdown will be populated by javascript on page load -->
21+
</div>
22+
</div>

0 commit comments

Comments
 (0)