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 2 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/'" />
aepanchi marked this conversation as resolved.
Show resolved Hide resolved
aepanchi marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions doc/set_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export DOC_VERSION=2024.3
ethanglaser marked this conversation as resolved.
Show resolved Hide resolved
rm -f sources/doc_version.json
echo "{\"version\":\"$DOC_VERSION\"}" >> sources/doc_version.json
aepanchi marked this conversation as resolved.
Show resolved Hide resolved
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;
}
aepanchi marked this conversation as resolved.
Show resolved Hide resolved
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);
}
aepanchi marked this conversation as resolved.
Show resolved Hide resolved
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 %}
aepanchi marked this conversation as resolved.
Show resolved Hide resolved
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
13 changes: 11 additions & 2 deletions doc/sources/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#
import os
import sys
import json
aepanchi marked this conversation as resolved.
Show resolved Hide resolved

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

sys.path.insert(0, os.path.abspath("../"))

Expand All @@ -42,9 +46,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 +142,10 @@
"titles_only": False,
}

html_context = {
"current_version":version,
"project_name":"scikit-learn-intelex"
}

# 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 +155,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/"
}
]
aepanchi marked this conversation as resolved.
Show resolved Hide resolved
Loading