Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic CI Doc Build #1785

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: publish
'on':
push:
branches:
main

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: install dependencies
run: |
sudo apt update
sudo apt install -y pandoc git
pip3 install -r requirements-doc.txt
cd doc
source set_version.sh
echo Generating version $DOC_VERSION
- name: build docs
run: |
cd doc
source set_version.sh
chmod +x build-doc.sh
./build-doc.sh
sphinx-build -b html sources _build/html
mv _build/html ../../$DOC_VERSION
rm -rf _build
cp versions.json ../..
cp index.html ../..
- name: deploy docs
run: |
cd doc
source set_version.sh
cd ..
git fetch
git checkout -- doc/build-doc.sh
git checkout gh-pages
rm -rf $DOC_VERSION
mv -f ../$DOC_VERSION .
mv ../versions.json .
mv ../index.html .
rm -rf doc
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@github.com"
git add .
git commit -m "latest HTML output"
git push -f https://${GITHUB_ACTOR}:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git HEAD:gh-pages

4 changes: 2 additions & 2 deletions doc/build-doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ cd ..
cp examples/notebooks/*.ipynb doc/$SAMPLES_DIR

# build the documentation
cd doc
make html
# cd doc
# make html
aepanchi marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions doc/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<meta http-equiv="refresh" content="0; URL='https:///intel.github.io/scikit-learn-intelex/2024.3/'" />
7 changes: 7 additions & 0 deletions doc/set_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if [ -z "${DALROOT}" ]; then
export DALROOT=${PREFIX}
fi

export DOC_VERSION=`python -c "import sys; import os; sys.path.append(os.path.join(os.getcwd(), '..', 'scripts')); from version import get_onedal_version; print(get_onedal_version(${DALROOT}))"`

Check notice on line 5 in doc/set_version.sh

View check run for this annotation

codefactor.io / CodeFactor

doc/set_version.sh#L5

Use $(...) notation instead of legacy backticks `...`. (SC2006)
ethanglaser marked this conversation as resolved.
Show resolved Hide resolved
rm -f sources/doc_version.json
echo "{\"version\":\"$DOC_VERSION\"}" >> sources/doc_version.json
8 changes: 8 additions & 0 deletions doc/sources/_static/style.css → doc/sources/_static/custom.css
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,11 @@ div.quotation {

a#wap_dns {display: none;}


button#version-switcher-button {
background-color: #2980b9;
}

div#version-switcher-dropdown {
display: inline;
}
36 changes: 36 additions & 0 deletions doc/sources/_static/version_switcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
fetch("https:///intel.github.io/scikit-learn-intelex/versions.json").then(response => response.text()).then(respText=>
load_versions(respText));


function load_versions(json){
var button = document.getElementById('version-switcher-button')
var container = document.getElementById('version-switcher-dropdown')
var loc = window.location.href;
var s = document.createElement('select');
s.style = "border-radius:5px;"
const versions = JSON.parse(json);
for (entry of versions){
var o = document.createElement('option');
var optionText = '';
if ('name' in entry){
optionText = entry.name;
}else{
optionText = entry.version;
}
o.value = entry.url;
if (current_version == entry.version){
o.selected = true;
optionText = optionText;

Check warning on line 23 in doc/sources/_static/version_switcher.js

View check run for this annotation

codefactor.io / CodeFactor

doc/sources/_static/version_switcher.js#L23

'optionText' is assigned to itself. (no-self-assign)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't understand this assignment

}
o.innerHTML = optionText;
s.append(o);
}
s.addEventListener("change", (event)=> {

Check notice on line 28 in doc/sources/_static/version_switcher.js

View check run for this annotation

codefactor.io / CodeFactor

doc/sources/_static/version_switcher.js#L28

'event' is defined but never used. (no-unused-vars)
var current_url = new URL(window.location.href);
var path = current_url.pathname;
//strip version from path
var page_path = path.substring(project_name.length+current_version.length+3);
window.location.href = s.value + page_path;
});
container.append(s);
}
5 changes: 5 additions & 0 deletions doc/sources/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@
}
</script>
{% endblock %}

{% block menu %}
{% include "versions.html" %}
{{ super() }}
{% endblock %}
22 changes: 22 additions & 0 deletions doc/sources/_templates/versions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div class="version-switcher__container dropdown">
<script>
current_version = "{{current_version}}"
project_name = "{{project_name}}"
</script>
<div id="version-switcher-button"
class="version-switcher__button"
data-bs-toggle="dropdown"
aria-haspopup="listbox"
aria-controls="version-switcher-dropdown"
aria-label="Version switcher list"
style="display:inline-block;padding-left:10px;padding-right:10px;"
>
Choose version <!-- this text may get changed later by javascript -->
<span class="caret"></span>
</div>
<div id="version-switcher-dropdown"
class="version-switcher__menu dropdown-menu list-group-flush py-0"
role="listbox" aria-labelledby="{{ button_id }}">
<!-- dropdown will be populated by javascript on page load -->
</div>
</div>
aepanchi marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 9 additions & 2 deletions doc/sources/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@

# -- Path setup --------------------------------------------------------------

import json

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys

with open("doc_version.json") as jsonFile:
doc_version = json.load(jsonFile)

sys.path.insert(0, os.path.abspath("../"))
ethanglaser marked this conversation as resolved.
Show resolved Hide resolved


Expand All @@ -42,9 +47,9 @@
author = "Intel"

# The short X.Y version
version = "2024.3.0"
version = doc_version["version"]
# The full version, including alpha/beta/rc tags
release = "2024.3.0"
release = version


# -- General configuration ---------------------------------------------------
Expand Down Expand Up @@ -138,6 +143,7 @@
"titles_only": False,
}

html_context = {"current_version": version, "project_name": "scikit-learn-intelex"}
aepanchi marked this conversation as resolved.
Show resolved Hide resolved

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand All @@ -147,6 +153,7 @@

def setup(app):
app.add_css_file("custom.css")
app.add_js_file("version_switcher.js")


# -- Options for HTMLHelp output ---------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions doc/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"name": "2024.3 (latest)",
"version": "2024.3",
"url": "https:///intel.github.io/scikit-learn-intelex/2024.3/"
},
{
"version": "2023.2",
"url": "https:///intel.github.io/scikit-learn-intelex/2023.2/"
}
]
Loading