Skip to content

Commit 7f7d58e

Browse files
authored
Merge branch 'master' into autodoc-links
2 parents 5929da3 + b392228 commit 7f7d58e

File tree

98 files changed

+2616
-1040
lines changed

Some content is hidden

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

98 files changed

+2616
-1040
lines changed

ci/azure/pipelines.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
vmImage: 'windows-2019'
2828
variables:
2929
TARGET: 'x86_64-windows-gnu'
30-
ZIG_LLVM_CLANG_LLD_NAME: 'zig+llvm+lld+clang-${{ variables.TARGET }}-0.10.0-dev.2931+bdf3fa12f'
30+
ZIG_LLVM_CLANG_LLD_NAME: 'zig+llvm+lld+clang-${{ variables.TARGET }}-0.10.0-dev.3524+74673b7f6'
3131
ZIG_LLVM_CLANG_LLD_URL: 'https://ziglang.org/deps/${{ variables.ZIG_LLVM_CLANG_LLD_NAME }}.zip'
3232
steps:
3333
- pwsh: |
@@ -41,6 +41,13 @@ jobs:
4141
Set-Variable -Name ZIGINSTALLDIR -Value "${ZIGBUILDDIR}\dist"
4242
Set-Variable -Name ZIGPREFIXPATH -Value "$(Get-Location)\$(ZIG_LLVM_CLANG_LLD_NAME)"
4343
44+
function CheckLastExitCode {
45+
if (!$?) {
46+
exit 1
47+
}
48+
return 0
49+
}
50+
4451
# Make the `zig version` number consistent.
4552
# This will affect the `zig build` command below which uses `git describe`.
4653
git config core.abbrev 9
@@ -69,6 +76,7 @@ jobs:
6976
-Dstrip `
7077
-Duse-zig-libcxx `
7178
-Dtarget=$(TARGET)
79+
CheckLastExitCode
7280
7381
cd -
7482
@@ -83,19 +91,37 @@ jobs:
8391
- pwsh: |
8492
Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\build\dist"
8593
94+
function CheckLastExitCode {
95+
if (!$?) {
96+
exit 1
97+
}
98+
return 0
99+
}
100+
86101
# Sadly, stage2 is omitted from this build to save memory on the CI server. Once self-hosted is
87102
# built with itself and does not gobble as much memory, we can enable these tests.
88103
#& "$ZIGINSTALLDIR\bin\zig.exe" test "..\test\behavior.zig" -fno-stage1 -fLLVM -I "..\test" 2>&1
104+
#CheckLastExitCode
89105
90106
& "$ZIGINSTALLDIR\bin\zig.exe" build test-toolchain -Dskip-non-native -Dskip-stage2-tests 2>&1
107+
CheckLastExitCode
91108
& "$ZIGINSTALLDIR\bin\zig.exe" build test-std -Dskip-non-native 2>&1
109+
CheckLastExitCode
92110
name: test
93111
displayName: 'Test'
94112
95113
- pwsh: |
96114
Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\build\dist"
97115
116+
function CheckLastExitCode {
117+
if (!$?) {
118+
exit 1
119+
}
120+
return 0
121+
}
122+
98123
& "$ZIGINSTALLDIR\bin\zig.exe" build docs
124+
CheckLastExitCode
99125
timeoutInMinutes: 60
100126
name: doc
101127
displayName: 'Documentation'

ci/srht/update_download_page

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,19 @@ cd "$HOME"
103103

104104
# Upload new stdlib autodocs
105105
mkdir -p docs_to_upload/documentation/master/std/
106-
cp "$ZIGDIR/docs/std/index.html" docs_to_upload/documentation/master/std/index.html
107-
cp "$ZIGDIR/docs/std/data.js" docs_to_upload/documentation/master/std/data.js
108-
cp "$ZIGDIR/docs/std/main.js" docs_to_upload/documentation/master/std/main.js
109-
cp "$LANGREF" docs_to_upload/documentation/master/index.html
110-
$S3CMD put -P --no-mime-magic --recursive --add-header="Cache-Control: max-age=0, must-revalidate" "docs_to_upload/" s3://ziglang.org/
106+
107+
gzip -c -9 "$ZIGDIR/docs/std/index.html" > docs_to_upload/documentation/master/std/index.html
108+
gzip -c -9 "$ZIGDIR/docs/std/data.js" > docs_to_upload/documentation/master/std/data.js
109+
gzip -c -9 "$ZIGDIR/docs/std/main.js" > docs_to_upload/documentation/master/std/main.js
110+
gzip -c -9 "$LANGREF" > docs_to_upload/documentation/master/index.html
111+
$S3CMD put -P --no-mime-magic --recursive --add-header="Content-Encoding:gzip" --add-header="Cache-Control: max-age=0, must-revalidate" "docs_to_upload/" s3://ziglang.org/
112+
113+
## Copy without compression:
114+
# cp "$ZIGDIR/docs/std/index.html" docs_to_upload/documentation/master/std/index.html
115+
# cp "$ZIGDIR/docs/std/data.js" docs_to_upload/documentation/master/std/data.js
116+
# cp "$ZIGDIR/docs/std/main.js" docs_to_upload/documentation/master/std/main.js
117+
# cp "$LANGREF" docs_to_upload/documentation/master/index.html
118+
# $S3CMD put -P --no-mime-magic --recursive --add-header="Cache-Control: max-age=0, must-revalidate" "docs_to_upload/" s3://ziglang.org/
111119

112120
git clone --depth 1 git@github.com:ziglang/www.ziglang.org.git
113121
cd www.ziglang.org

lib/docs/index.html

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@
169169
width: 100%;
170170
margin-bottom: 0.8rem;
171171
padding: 0.5rem;
172-
font-size: 1rem;
173172
font-family: var(--ui);
173+
font-size: 1rem;
174174
color: var(--tx-color);
175175
background-color: var(--search-bg-color);
176176
border-top: 0;
@@ -339,8 +339,8 @@
339339
kbd {
340340
display: inline-block;
341341
padding: 0.3em 0.2em;
342-
font-size: 1.2em;
343-
font-size: var(--mono);
342+
font-family: var(--mono);
343+
font-size: 1em;
344344
line-height: 0.8em;
345345
vertical-align: middle;
346346
color: #000;
@@ -612,7 +612,7 @@ <h2><span>Zig Version</span></h2>
612612
</div>
613613
</nav>
614614
</div>
615-
<div class="flex-right">
615+
<div id="docs" class="flex-right">
616616
<div class="wrap">
617617
<section class="docs">
618618
<div style="position: relative">
@@ -654,7 +654,13 @@ <h2>Search Results</h2>
654654
</div>
655655
<div id="sectSearchNoResults" class="hidden">
656656
<h2>No Results Found</h2>
657-
<p>Press escape to exit search and then '?' to see more options.</p>
657+
<p>Here are some things you can try:</p>
658+
<ul>
659+
<li>Check out the <a id="langRefLink">Language Reference</a> for the language itself.</li>
660+
<li>Check out the <a href="https://ziglang.org/learn/">Learn page</a> for other helpful resources for learning Zig.</li>
661+
<li>Use your search engine.</li>
662+
</ul>
663+
<p>Press <kbd>?</kbd> to see keyboard shortcuts and <kbd>Esc</kbd> to return.</p>
658664
</div>
659665
<div id="sectFields" class="hidden">
660666
<h2>Fields</h2>
@@ -716,11 +722,13 @@ <h2>Tests</h2>
716722
<div class="modal">
717723
<h1>Keyboard Shortcuts</h1>
718724
<dl><dt><kbd>?</kbd></dt><dd>Show this help modal</dd></dl>
719-
<dl><dt><kbd>Esc</kbd></dt><dd>Clear focus; close this modal</dd></dl>
720725
<dl><dt><kbd>s</kbd></dt><dd>Focus the search field</dd></dl>
721-
<dl><dt><kbd></kbd></dt><dd>Move up in search results</dd></dl>
722-
<dl><dt><kbd></kbd></dt><dd>Move down in search results</dd></dl>
723-
<dl><dt><kbd></kbd></dt><dd>Go to active search result</dd></dl>
726+
<div style="margin-left: 1em">
727+
<dl><dt><kbd></kbd></dt><dd>Move up in search results</dd></dl>
728+
<dl><dt><kbd></kbd></dt><dd>Move down in search results</dd></dl>
729+
<dl><dt><kbd></kbd></dt><dd>Go to active search result</dd></dl>
730+
</div>
731+
<dl><dt><kbd>Esc</kbd></dt><dd>Clear focus; close this modal</dd></dl>
724732
</div>
725733
</div>
726734
</div>

lib/docs/main.js

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var zigAnalysis;
4141
const domSearch = document.getElementById("search");
4242
const domSectSearchResults = document.getElementById("sectSearchResults");
4343
const domSectSearchAllResultsLink = document.getElementById("sectSearchAllResultsLink");
44-
44+
const domDocs = document.getElementById("docs");
4545
const domListSearchResults = document.getElementById("listSearchResults");
4646
const domSectSearchNoResults = document.getElementById("sectSearchNoResults");
4747
const domSectInfo = document.getElementById("sectInfo");
@@ -52,6 +52,7 @@ var zigAnalysis;
5252
const domHelpModal = document.getElementById("helpModal");
5353
const domSearchPlaceholder = document.getElementById("searchPlaceholder");
5454
const sourceFileUrlTemplate = "/src-viewer/{{file}}#L{{line}}"
55+
const domLangRefLink = document.getElementById("langRefLink");
5556

5657
let lineCounter = 1;
5758
let searchTimer = null;
@@ -118,10 +119,10 @@ var zigAnalysis;
118119
});
119120
domSectSearchAllResultsLink.addEventListener('click', onClickSearchShowAllResults, false);
120121
function onClickSearchShowAllResults(ev) {
121-
ev.preventDefault();
122-
ev.stopPropagation();
123-
searchTrimResults = false;
124-
onHashChange();
122+
ev.preventDefault();
123+
ev.stopPropagation();
124+
searchTrimResults = false;
125+
onHashChange();
125126
}
126127

127128
domPrivDeclsBox.addEventListener(
@@ -163,6 +164,13 @@ var zigAnalysis;
163164
window.addEventListener("keydown", onWindowKeyDown, false);
164165
onHashChange();
165166

167+
let langRefVersion = zigAnalysis.params.zigVersion;
168+
if (!/^\d+\.\d+\.\d+$/.test(langRefVersion)) {
169+
// the version is probably not released yet
170+
langRefVersion = "master";
171+
}
172+
domLangRefLink.href = `https://ziglang.org/documentation/${langRefVersion}/`;
173+
166174
function renderTitle() {
167175
let list = curNav.pkgNames.concat(curNav.declNames);
168176
let suffix = " - Zig";
@@ -3154,6 +3162,23 @@ var zigAnalysis;
31543162
domSearch.blur();
31553163
}
31563164

3165+
// hide the modal if it's visible or return to the previous result page and unfocus the search
3166+
function onEscape(ev) {
3167+
if (!domHelpModal.classList.contains("hidden")) {
3168+
domHelpModal.classList.add("hidden");
3169+
ev.preventDefault();
3170+
ev.stopPropagation();
3171+
} else {
3172+
domSearch.value = "";
3173+
domSearch.blur();
3174+
domSearchPlaceholder.classList.remove("hidden");
3175+
curSearchIndex = -1;
3176+
ev.preventDefault();
3177+
ev.stopPropagation();
3178+
startSearch();
3179+
}
3180+
}
3181+
31573182
function onSearchKeyDown(ev) {
31583183
switch (getKeyString(ev)) {
31593184
case "Enter":
@@ -3170,19 +3195,15 @@ var zigAnalysis;
31703195
ev.stopPropagation();
31713196
return;
31723197
case "Esc":
3173-
domSearch.value = "";
3174-
domSearch.blur();
3175-
curSearchIndex = -1;
3176-
ev.preventDefault();
3177-
ev.stopPropagation();
3178-
startSearch();
3179-
return;
3198+
onEscape(ev);
3199+
return
31803200
case "Up":
31813201
moveSearchCursor(-1);
31823202
ev.preventDefault();
31833203
ev.stopPropagation();
31843204
return;
31853205
case "Down":
3206+
// TODO: make the page scroll down if the search cursor is out of the screen
31863207
moveSearchCursor(1);
31873208
ev.preventDefault();
31883209
ev.stopPropagation();
@@ -3251,19 +3272,18 @@ var zigAnalysis;
32513272
function onWindowKeyDown(ev) {
32523273
switch (getKeyString(ev)) {
32533274
case "Esc":
3254-
if (!domHelpModal.classList.contains("hidden")) {
3255-
domHelpModal.classList.add("hidden");
3275+
onEscape(ev);
3276+
break;
3277+
case "s":
3278+
if (domHelpModal.classList.contains("hidden")) {
3279+
domSearch.focus();
3280+
domSearch.select();
3281+
domDocs.scrollTo(0, 0);
32563282
ev.preventDefault();
32573283
ev.stopPropagation();
3284+
startAsyncSearch();
32583285
}
32593286
break;
3260-
case "s":
3261-
domSearch.focus();
3262-
domSearch.select();
3263-
ev.preventDefault();
3264-
ev.stopPropagation();
3265-
startAsyncSearch();
3266-
break;
32673287
case "?":
32683288
ev.preventDefault();
32693289
ev.stopPropagation();
@@ -3279,6 +3299,7 @@ var zigAnalysis;
32793299
domHelpModal.style.top =
32803300
window.innerHeight / 2 - domHelpModal.clientHeight / 2 + "px";
32813301
domHelpModal.focus();
3302+
domSearch.blur();
32823303
}
32833304

32843305
function clearAsyncSearch() {
@@ -3304,7 +3325,7 @@ var zigAnalysis;
33043325
list.sort();
33053326
return list;
33063327
}
3307-
3328+
33083329
function renderSearch() {
33093330
let matchedItems = [];
33103331
let ignoreCase = curNavSearch.toLowerCase() === curNavSearch;
@@ -3393,13 +3414,13 @@ var zigAnalysis;
33933414
const text = lastPkgName + "." + match.path.declNames.join(".");
33943415
const href = navLink(match.path.pkgNames, match.path.declNames);
33953416

3396-
matchedItemsHTML += "<li><a href=\""+ href +"\">"+ text + "</a></li>";
3417+
matchedItemsHTML += "<li><a href=\"" + href + "\">" + text + "</a></li>";
33973418
}
33983419

33993420
// Replace the search results using our newly constructed HTML string
34003421
domListSearchResults.innerHTML = matchedItemsHTML;
34013422
if (searchTrimmed) {
3402-
domSectSearchAllResultsLink.classList.remove("hidden");
3423+
domSectSearchAllResultsLink.classList.remove("hidden");
34033424
}
34043425
renderSearchCursor();
34053426

0 commit comments

Comments
 (0)