Skip to content

Commit d4e27fe

Browse files
Add: mike for documentation versioning
1 parent ecabc16 commit d4e27fe

50 files changed

Lines changed: 8360 additions & 8524 deletions

File tree

Some content is hidden

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

.github/workflows/gh-pages.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- dev
78

89
jobs:
910
build-deploy:
@@ -12,6 +13,9 @@ jobs:
1213
# 1. Checkout repo (code + docs)
1314
- name: Checkout repository
1415
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
token: ${{ secrets.GH_PAGES_TOKEN || github.token }}
1519

1620
# 2. Set up Python
1721
- name: Set up Python
@@ -23,19 +27,19 @@ jobs:
2327
- name: Install dependencies
2428
run: |
2529
python -m pip install --upgrade pip
26-
pip install .[dev] # installs mkdocs and all extras
30+
pip install .[dev] mike
2731
28-
# 4. Build doc
29-
- name: Build MkDocs site
32+
# 4. Deploy MkDocs site with mike
33+
- name: Deploy with mike 🚀
3034
env:
3135
PYTHONPATH: ${{ github.workspace }}/PyEyesWeb
32-
run: mkdocs build --verbose
33-
34-
# 5. Push to gh-pages
35-
- name: Deploy to GitHub Pages 🚀
36-
uses: peaceiris/actions-gh-pages@v3
37-
with:
38-
github_token: ${{ secrets.GH_PAGES_TOKEN }}
39-
publish_dir: ./site
40-
publish_branch: gh-pages
41-
force_orphan: true
36+
run: |
37+
git config user.name "github-actions[bot]"
38+
git config user.email "github-actions[bot]@users.noreply.github.com"
39+
40+
if [ "${{ github.ref_name }}" = "main" ]; then
41+
mike deploy --push --update-aliases main latest
42+
mike set-default --push latest
43+
else
44+
mike deploy --push ${{ github.ref_name }}
45+
fi

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,7 @@ demos/Backup
4444
demos/Lib
4545

4646
# Ignore specific files or directories
47-
__*
47+
__*
48+
49+
# Ignore the site directory
50+
site/

docs/javascripts/version-select.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
document.addEventListener("DOMContentLoaded", function() {
2+
// Determine base URL based on environment (localhost vs GitHub Pages)
3+
var isLocalhost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
4+
var baseUrl = isLocalhost ? "" : "/PyEyesWeb";
5+
6+
// Attempt to fetch the versions.json generated by mike
7+
fetch(baseUrl + "/versions.json").then(response => {
8+
if (!response.ok) return null;
9+
return response.json();
10+
}).then(versions => {
11+
if (!versions || versions.length === 0) return;
12+
13+
// Find the current version from the URL path.
14+
var pathSegments = window.location.pathname.split('/').filter(p => p !== "");
15+
// If localhost: /dev/ -> pathSegments[0] is "dev"
16+
// If GitHub: /PyEyesWeb/dev/ -> pathSegments[1] is "dev"
17+
var currentVersion = isLocalhost ? pathSegments[0] : pathSegments[1];
18+
19+
if (!currentVersion) {
20+
currentVersion = versions[0].version; // fallback if at root
21+
}
22+
23+
var select = document.createElement("select");
24+
select.style.margin = "10px auto";
25+
select.style.display = "block";
26+
select.style.width = "90%";
27+
select.style.padding = "5px";
28+
select.style.color = "#000";
29+
select.style.borderRadius = "3px";
30+
select.style.border = "1px solid #ccc";
31+
32+
versions.forEach(function(version) {
33+
var option = document.createElement("option");
34+
option.value = version.version;
35+
option.text = "Version: " + version.title;
36+
if (version.version === currentVersion || version.aliases.includes(currentVersion)) {
37+
option.selected = true;
38+
}
39+
select.appendChild(option);
40+
});
41+
42+
select.addEventListener("change", function() {
43+
window.location.href = baseUrl + "/" + this.value + "/";
44+
});
45+
46+
// Add the dropdown to the readthedocs sidebar search box or navigation container
47+
var searchBox = document.querySelector(".wy-side-nav-search");
48+
if (searchBox) {
49+
searchBox.appendChild(select);
50+
}
51+
}).catch(e => console.error("Error loading versions.json:", e));
52+
});

mkdocs.yml

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ markdown_extensions:
3333
pygments_lang_class: true
3434
- pymdownx.inlinehilite
3535
- pymdownx.keys
36-
- pymdownx.emoji:
37-
emoji_index: !!python/name:material.extensions.emoji.twemoji
38-
emoji_generator: !!python/name:material.extensions.emoji.to_svg
3936
- pymdownx.arithmatex:
4037
generic: true
4138

@@ -44,61 +41,14 @@ theme:
4441
custom_dir: docs/overrides
4542
logo: assets/eyesweb-logo.png
4643
favicon: assets/favicon-32x32.png
47-
icon:
48-
repo: fontawesome/brands/github
49-
# font:
50-
# text: Inter
51-
features:
52-
- navigation.tabs
53-
- navigation.tabs.sticky
54-
- navigation.instant
55-
- navigation.path
56-
- navigation.indexes
57-
- navigation.top
58-
- navigation.footer
59-
# - navigation.expand
60-
- content.code.copy
61-
- content.tabs.link
62-
- content.tooltips
63-
- content.code.annotate
64-
- content.tables.striped
65-
- search.suggest
66-
- search.highlight
67-
- search.share
68-
- toc.follow
69-
- announce.dismiss
70-
palette:
71-
- media: "(prefers-color-scheme: light)"
72-
scheme: default
73-
primary: red
74-
accent: indigo
75-
toggle:
76-
icon: material/weather-night
77-
name: Switch to dark mode
78-
- media: "(prefers-color-scheme: dark)"
79-
scheme: slate
80-
primary: black
81-
accent: red
82-
toggle:
83-
icon: material/weather-sunny
84-
name: Switch to light mode
85-
8644
extra_javascript:
8745
- javascripts/mathjax.js
8846
- https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js
47+
- javascripts/version-select.js
8948

9049
extra_css:
9150
- overrides/extra.css
9251

93-
extra:
94-
social:
95-
- icon: fontawesome/brands/github
96-
link: https://github.com/InfoMusCP
97-
name: GitHub Organization
98-
- icon: material/web
99-
link: http://www.casapaganini.org/index_eng.php
100-
name: Casa Paganini - InfoMus Website
101-
10252
copyright: Copyright © 2025 Casa Paganini - InfoMus, Genoa, Italy. All rights reserved.
10353

10454
nav:

0 commit comments

Comments
 (0)