Skip to content

Commit f376a46

Browse files
committed
Fix docs build
1 parent 418e317 commit f376a46

File tree

5 files changed

+66
-58
lines changed

5 files changed

+66
-58
lines changed

.github/workflows/docs.yml

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ on:
77

88
jobs:
99
build:
10+
name: "Docs CI"
1011
runs-on: ubuntu-latest
1112

1213
steps:
1314
- name: Checkout Source
1415
uses: actions/checkout@v2
1516
with:
16-
# require all of history to see all tagged versions' docs
17+
# require history to get back to last tag for version number of brnaches
1718
fetch-depth: 0
1819
submodules: true
1920

@@ -22,49 +23,32 @@ jobs:
2223
with:
2324
python-version: "3.7"
2425

25-
- name: Install Packages
26-
# Can delete this if you don't use graphviz in your docs
27-
run: sudo apt-get install graphviz
28-
2926
- name: Install Python Dependencies
3027
run: |
3128
pip install pipenv
3229
pipenv install --dev --deploy --python $(which python) && pipenv graph
3330
34-
- name: Deploy index
35-
# We pin to the SHA, not the tag, for security reasons.
36-
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
37-
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3
38-
with:
39-
github_token: ${{ secrets.GITHUB_TOKEN }}
40-
publish_dir: .github/pages
41-
keep_files: true
31+
- name: Build Docs
32+
run: pipenv run docs
4233

43-
- name: Checkout gh-pages
44-
# As we already did a deploy of gh-pages above, it is guaranteed to be there
45-
# so check it out so we can selectively build docs below
46-
uses: actions/checkout@v2
34+
- uses: jungwinter/split@v1
35+
id: split
4736
with:
48-
ref: gh-pages
49-
path: build/html
50-
51-
- name: Maybe use sphinx-multiversion
52-
# If we are building master or a tag we will publish
53-
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
54-
# So use the args we normally pass to sphinx-build, but run sphinx-multiversion
55-
run: mv $(pipenv --venv)/bin/sphinx-multiversion $(pipenv --venv)/bin/sphinx-build
37+
msg: ${{ github.ref }}
38+
seperator: /
39+
maxsplit: 2
5640

57-
- name: Build Docs
58-
run: pipenv run docs
41+
- name: Move to versioned directory
42+
# e.g. master or 0.1.2
43+
run: mv build/html ".github/pages/${{ steps.split.outputs._2 }}"
5944

6045
- name: Publish Docs to gh-pages
6146
# Only master and tags are published
62-
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
47+
if: "${{ github.repository_owner == 'dls-controls' }}"
6348
# We pin to the SHA, not the tag, for security reasons.
6449
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
6550
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3
6651
with:
6752
github_token: ${{ secrets.GITHUB_TOKEN }}
68-
publish_dir: build/html
53+
publish_dir: .github/pages
6954
keep_files: true
70-

Pipfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ verify_ssl = true
77
pytest-cov = "*"
88
pytest-flake8 = "*"
99
sphinx-rtd-theme = "*"
10-
# switch to main repo after PR https://github.com/Holzhaus/sphinx-multiversion/pull/60 is merged
11-
sphinx-multiversion = {editable = true,git = "https://github.com/dls-controls/sphinx-multiversion.git",ref = "only-arg"}
1210
setuptools-dso = "*"
1311
aioca = "*"
1412
pytest-asyncio = "*"

Pipfile.lock

Lines changed: 21 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/_templates/layout.html

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,36 @@
1010
<!-- Include Index in the sidebar -->
1111
<!-- https://stackoverflow.com/a/37843854 -->
1212
<a href="{{pathto('genindex.html', 1)}}">Index</a>
13-
<!-- Include all versions of the docs -->
14-
<!-- https://holzhaus.github.io/sphinx-multiversion/master/templates.html -->
15-
{% if versions %}
13+
<!-- Add versions for selected branches + tags -->
1614
<p class="caption"><span class="caption-text">Versions</span></p>
17-
<ul>
18-
{%- for item in versions|reverse %}
19-
<li><a href="{{ item.url }}">{{ item.name }}</a></li>
20-
{%- endfor %}
21-
</ul>
22-
{% endif %}
15+
<ul id="versions"></ul>
16+
<script>
17+
// Versions to add, will be filtered by dirs
18+
var versions = ['master'];
19+
var dirs = new Set();
20+
function addVersion(name) {
21+
if (dirs.has(name)) {
22+
var li = document.createElement("li");
23+
var a = document.createElement("a");
24+
a.href = 'https://dls-controls.github.io/pythonIoc/' + name;
25+
a.innerText = name;
26+
li.appendChild(a)
27+
document.getElementById('versions').appendChild(li);
28+
}
29+
}
30+
Promise.all([
31+
// Find gh-pages directories
32+
fetch("https://api.github.com/repos/dls-controls/pythonIoc/contents?ref=gh-pages")
33+
.then(response => response.json())
34+
.then(data => data.forEach(function(e) {
35+
if (e.type == "dir") dirs.add(e.name);
36+
})),
37+
// Add tags that have pages
38+
fetch('https://api.github.com/repos/dls-controls/pythonIoc/tags')
39+
.then(response => response.json())
40+
.then(data => data.forEach(function(e) {
41+
versions.push(e.name);
42+
}))
43+
]).then(_ => versions.forEach(addVersion))
44+
</script>
2345
{% endblock %}

docs/conf.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
'sphinx.ext.intersphinx',
5050
# Add links to source code in API docs
5151
'sphinx.ext.viewcode',
52-
# Add multiple versions of documentation on CI
53-
'sphinx_multiversion',
5452
]
5553

5654
# If true, Sphinx will warn about all references where the target cannot
@@ -133,14 +131,6 @@
133131
html_logo = 'images/softioc-logo.svg'
134132
html_favicon = 'images/softioc-favicon.ico'
135133

136-
# sphinx-multiversion config
137-
smv_rebuild_tags = False
138-
smv_tag_whitelist = r'^\d+\.\d+.*$' # only document tags with form 0.9*
139-
smv_branch_whitelist = r'^master$' # only branch to document is master
140-
smv_outputdir_format = '{ref.name}'
141-
smv_prefer_remote_refs = False
142-
smv_remote_whitelist = 'origin|github'
143-
144134
# Common links that should be available on every page
145135
rst_epilog = """
146136
.. _epicscorelibs: https://github.com/mdavidsaver/epicscorelibs

0 commit comments

Comments
 (0)