Skip to content

Commit 5ddda1e

Browse files
committed
refactor: Move install script to docs
1 parent 9d47e45 commit 5ddda1e

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

docs/conf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
# Add any Sphinx extension module names here, as strings. They can be
1414
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
1515
# ones.
16-
extensions = []
16+
sys.path += ['.']
17+
extensions = [
18+
'sphinxcontrib_rawfiles',
19+
]
20+
rawfiles = ['install.sh']
1721

1822
# Add any paths that contain templates here, relative to this directory.
1923
templates_path = ['_templates']

docs/install.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
# Automatically installs swiftenv and run's swiftenv install.
4+
# This script was designed for usage in CI systems.
5+
6+
git clone --depth 1 https://github.com/kylef/swiftenv.git ~/.swiftenv
7+
export SWIFTENV_ROOT="$HOME/.swiftenv"
8+
export PATH="$SWIFTENV_ROOT/bin:$SWIFTENV_ROOT/shims:$PATH"
9+
10+
if [ -f ".swift-version" ] || [ -n "$SWIFT_VERSION" ]; then
11+
swiftenv install -s
12+
else
13+
swiftenv rehash
14+
fi

docs/sphinxcontrib_rawfiles.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
import os
3+
import shutil
4+
5+
def on_html_collect_pages(app):
6+
for f in app.builder.config.rawfiles:
7+
src = os.path.join(app.srcdir, f)
8+
dst = os.path.join(app.builder.outdir, f)
9+
if os.path.isfile(src):
10+
shutil.copy(src, dst)
11+
else:
12+
shutil.copytree(src, dst)
13+
14+
return ()
15+
16+
def setup(app):
17+
app.add_config_value('rawfiles', [], 'html')
18+
app.connect("html-collect-pages", on_html_collect_pages)

0 commit comments

Comments
 (0)