Skip to content

Commit 54b19b8

Browse files
committed
fix: use branch instead of tag
Signed-off-by: Mateusz Urbanek <[email protected]>
1 parent 3694bfc commit 54b19b8

File tree

10 files changed

+58
-2368
lines changed

10 files changed

+58
-2368
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ build-docs: generate mdbook
119119
MDBOOK_PORT ?= 3000
120120

121121
.PHONY: serve-docs
122-
serve-docs: generate mdbook
122+
serve-docs: generate mdbook build-docs
123123
cd docs; $(MDBOOK) serve --port $(MDBOOK_PORT)
124124

125125
.PHONY: clean

docs/book.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ authors = ["The Kubernetes Authors"]
66
[output.html]
77
git-repository-url = "https://github.com/kubernetes-sigs/container-object-storage-interface/tree/main/docs"
88
edit-url-template = "https://github.com/kubernetes-sigs/container-object-storage-interface/tree/main/docs/{path}"
9-
additional-css = ["custom.css"]
9+
additional-css = ["theme/custom.css"]
10+
theme = "theme"
1011

1112
[preprocessor.generate-version]
1213
renderers = ["html"]

docs/scripts/generate-version.sh

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
jq ".[1]";
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
jq ".[1]"
6+
27
SHA=$(git rev-parse HEAD)
3-
VERSION="Built from: <a target="_blank" href=\"https:\/\/github.com\/kubernetes-sigs\/container-object-storage-interface\/tree\/${SHA}\"><code>${SHA}<\/code><\/a>"
4-
TAG=$(git tag --contains "$SHA" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$')
5-
if [ -n "$TAG" ]; then
6-
VERSION="Version: <a target="_blank" href=\"https:\/\/github.com\/kubernetes-sigs\/container-object-storage-interface\/tree\/${TAG}\"><code>${TAG}<\/code><\/a> ${VERSION}"
8+
VERSION="Commit: <a target="_blank" href=\"https:\/\/github.com\/kubernetes-sigs\/container-object-storage-interface\/tree\/${SHA}\"><code>${SHA}<\/code><\/a>"
9+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
10+
11+
if [ -n "$BRANCH" ]; then
12+
VERSION="Branch: <a target="_blank" href=\"https:\/\/github.com\/kubernetes-sigs\/container-object-storage-interface\/tree\/${BRANCH}\"><code>${BRANCH}<\/code><\/a> ${VERSION}"
713
fi
14+
815
sed "s/VERSION-PLACEHOLDER/${VERSION}/" theme/index-template.hbs > theme/index.hbs
File renamed without changes.

docs/theme/index-template.hbs

+29-29
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,32 @@
2020
<meta name="theme-color" content="#ffffff">
2121

2222
{{#if favicon_svg}}
23-
<link rel="icon" href="{{ path_to_root }}favicon.svg">
23+
<link rel="icon" href="{{ resource "favicon.svg" }}">
2424
{{/if}}
2525
{{#if favicon_png}}
26-
<link rel="shortcut icon" href="{{ path_to_root }}favicon.png">
26+
<link rel="shortcut icon" href="{{ resource "favicon.png" }}">
2727
{{/if}}
28-
<link rel="stylesheet" href="{{ path_to_root }}css/variables.css">
29-
<link rel="stylesheet" href="{{ path_to_root }}css/general.css">
30-
<link rel="stylesheet" href="{{ path_to_root }}css/chrome.css">
28+
<link rel="stylesheet" href="{{ resource "css/variables.css" }}">
29+
<link rel="stylesheet" href="{{ resource "css/general.css" }}">
30+
<link rel="stylesheet" href="{{ resource "css/chrome.css" }}">
3131
{{#if print_enable}}
32-
<link rel="stylesheet" href="{{ path_to_root }}css/print.css" media="print">
32+
<link rel="stylesheet" href="{{ resource "css/print.css" }}" media="print">
3333
{{/if}}
3434

3535
<!-- Fonts -->
36-
<link rel="stylesheet" href="{{ path_to_root }}FontAwesome/css/font-awesome.css">
36+
<link rel="stylesheet" href="{{ resource "FontAwesome/css/font-awesome.css" }}">
3737
{{#if copy_fonts}}
38-
<link rel="stylesheet" href="{{ path_to_root }}fonts/fonts.css">
38+
<link rel="stylesheet" href="{{ resource "fonts/fonts.css" }}">
3939
{{/if}}
4040

4141
<!-- Highlight.js Stylesheets -->
42-
<link rel="stylesheet" href="{{ path_to_root }}highlight.css">
43-
<link rel="stylesheet" href="{{ path_to_root }}tomorrow-night.css">
44-
<link rel="stylesheet" href="{{ path_to_root }}ayu-highlight.css">
42+
<link rel="stylesheet" id="highlight-css" href="{{ resource "highlight.css" }}">
43+
<link rel="stylesheet" id="tomorrow-night-css" href="{{ resource "tomorrow-night.css" }}">
44+
<link rel="stylesheet" id="ayu-highlight-css" href="{{ resource "ayu-highlight.css" }}">
4545

4646
<!-- Custom theme stylesheets -->
4747
{{#each additional_css}}
48-
<link rel="stylesheet" href="{{ ../path_to_root }}{{ this }}">
48+
<link rel="stylesheet" href="{{ resource this }}">
4949
{{/each}}
5050

5151
{{#if mathjax_support}}
@@ -59,7 +59,7 @@
5959
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}";
6060
</script>
6161
<!-- Start loading toc.js asap -->
62-
<script src="{{ path_to_root }}toc.js"></script>
62+
<script src="{{ resource "toc.js" }}"></script>
6363
</head>
6464
<body>
6565
<div id="body-container">
@@ -189,10 +189,9 @@
189189
});
190190
</script>
191191

192-
<div id="version" class="version">
193-
VERSION-PLACEHOLDER
194-
</div>
195-
192+
<div id="version" class="version">
193+
VERSION-PLACEHOLDER
194+
</div>
196195
<div id="content" class="content">
197196
<main>
198197
{{{ content }}}
@@ -284,26 +283,26 @@
284283
{{/if}}
285284

286285
{{#if playground_js}}
287-
<script src="{{ path_to_root }}ace.js"></script>
288-
<script src="{{ path_to_root }}editor.js"></script>
289-
<script src="{{ path_to_root }}mode-rust.js"></script>
290-
<script src="{{ path_to_root }}theme-dawn.js"></script>
291-
<script src="{{ path_to_root }}theme-tomorrow_night.js"></script>
286+
<script src="{{ resource "ace.js" }}"></script>
287+
<script src="{{ resource "editor.js" }}"></script>
288+
<script src="{{ resource "mode-rust.js" }}"></script>
289+
<script src="{{ resource "theme-dawn.js" }}"></script>
290+
<script src="{{ resource "theme-tomorrow_night.js" }}"></script>
292291
{{/if}}
293292

294293
{{#if search_js}}
295-
<script src="{{ path_to_root }}elasticlunr.min.js"></script>
296-
<script src="{{ path_to_root }}mark.min.js"></script>
297-
<script src="{{ path_to_root }}searcher.js"></script>
294+
<script src="{{ resource "elasticlunr.min.js" }}"></script>
295+
<script src="{{ resource "mark.min.js" }}"></script>
296+
<script src="{{ resource "searcher.js" }}"></script>
298297
{{/if}}
299298

300-
<script src="{{ path_to_root }}clipboard.min.js"></script>
301-
<script src="{{ path_to_root }}highlight.js"></script>
302-
<script src="{{ path_to_root }}book.js"></script>
299+
<script src="{{ resource "clipboard.min.js" }}"></script>
300+
<script src="{{ resource "highlight.js" }}"></script>
301+
<script src="{{ resource "book.js" }}"></script>
303302

304303
<!-- Custom JS scripts -->
305304
{{#each additional_js}}
306-
<script src="{{ ../path_to_root }}{{this}}"></script>
305+
<script src="{{ resource this}}"></script>
307306
{{/each}}
308307

309308
{{#if is_print}}
@@ -323,6 +322,7 @@
323322
</script>
324323
{{/if}}
325324
{{/if}}
325+
326326
</div>
327327
</body>
328328
</html>

hack/tools/install-mdbook.sh

+14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -eu
44

55
MDBOOK="${1}"
66
MDBOOK_VERSION="${2}"
7+
CURDIR="${PWD}"
78

89
# If it exists, do not redownload
910
if [ -f "${MDBOOK}-${MDBOOK_VERSION}" ]; then
@@ -50,4 +51,17 @@ ln -sf "${MDBOOK}-${MDBOOK_VERSION}" "${MDBOOK}"
5051
# Clean up
5152
rm -f mdbook.tar.gz
5253

54+
TEMP=$(mktemp -d)
55+
trap 'rm -rf "$TEMP"' EXIT
56+
57+
cd "${TEMP}"
58+
59+
TEMPLATE='<div id="version" class="version">\n VERSION-PLACEHOLDER\n</div>'
60+
61+
"${MDBOOK}" init --theme --title "template" --ignore "none"
62+
63+
cp theme/index.hbs "${CURDIR}/docs/theme/index-template.hbs"
64+
sed -i "/<div id=\"content\" class=\"content\">/i ${TEMPLATE}" "${CURDIR}/docs/theme/index-template.hbs"
65+
66+
5367
echo "$("${MDBOOK}" --version) installed successfully!"

0 commit comments

Comments
 (0)