Skip to content

Commit 303719f

Browse files
authored
Add custom header for staging copy and build script (#73)
Fixes #34
2 parents 85ed44e + 3cef181 commit 303719f

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

Sources/TSPL/TSPL.docc/header.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!--
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See https://swift.org/LICENSE.txt for license information
8+
See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
9+
-->
10+
11+
<header id="header" role="banner">
12+
<div class="container">
13+
<aside style="border-radius: 20px; border: 2px solid goldenrod; background: rgba(230, 241, 69, 0.625); padding: 5px; margin: 5px;">
14+
<h3>Important</h3>
15+
<p>
16+
This is the development version of <em>The Swift Programming Language</em> book.
17+
</p>
18+
<p>
19+
For the current shipping book, see <a href="https://docs.swift.org/swift-book/">Swift.org</a>.
20+
To contribute to this documentation, see the <a href="https://github.com/apple/swift-book">swift-book project</a> on GitHub.
21+
</p>
22+
</aside>
23+
</div>
24+
</header>

bin/update-book-preview

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#! /bin/bash
2+
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2022 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
10+
11+
# Updates the GitHub Pages documentation site that's published from the 'docs'
12+
# subdirectory in the 'gh-pages' branch of this repository.
13+
#
14+
# This script should be run by someone with commit access to the 'gh-pages' branch
15+
# at a regular frequency so that the documentation content on the GitHub Pages site
16+
# is up-to-date with the content in this repo.
17+
#
18+
# To use top-of-tree DocC, clone the following repositories:
19+
#
20+
# https://github.com/apple/swift-docc
21+
# https://github.com/apple/swift-docc-render
22+
#
23+
# Then set environment variables to paths in their working directories,
24+
# like the following, before running this script:
25+
#
26+
# DOCC_EXEC=~/git/DocC/.build/arm64-apple-macosx/debug/docc
27+
# DOCC_HTML_DIR=~/git/DocC-Renderer/dist/
28+
29+
set -eu
30+
31+
REMOTE=${1:-origin}
32+
CURRENT_COMMIT_HASH="$(git rev-parse --short HEAD)"
33+
34+
# Start at the top level directory of the repository.
35+
cd "$(git rev-parse --show-toplevel)"
36+
37+
# Check out the 'gh-pages' branch in a subdirectory.
38+
git worktree add --checkout gh-pages "$REMOTE"/gh-pages
39+
40+
# Pretty print DocC JSON output, so that it has a stable ordering and
41+
# can be diffed. This lets us determine whether rebuilding resulted in
42+
# any changes to the content.
43+
export DOCC_JSON_PRETTYPRINT="YES"
44+
45+
# Build documentation, writing output in the gh-pages/docs subdirectory.
46+
swift package \
47+
--allow-writing-to-directory "./gh-pages/docs" \
48+
generate-documentation \
49+
--target TSPL \
50+
--disable-indexing \
51+
--experimental-enable-custom-templates \
52+
--hosting-base-path swift-book \
53+
--output-path "./gh-pages/docs"
54+
55+
# Commit and push our changes to the gh-pages branch
56+
pushd gh-pages
57+
git add docs
58+
59+
if [[ -n "$(git status --porcelain)" ]]
60+
then
61+
echo "Found documentation changes."
62+
echo "Committing the changes to the 'gh-pages' branch and pushing to $REMOTE."
63+
git commit -m "Update GitHub Pages documentation site to '$CURRENT_COMMIT_HASH'."
64+
echo
65+
git push "$REMOTE" HEAD:gh-pages
66+
else
67+
echo "No documentation changes found."
68+
fi
69+
70+
popd
71+
72+
git worktree remove gh-pages

0 commit comments

Comments
 (0)