$title
$subtitle
$content
diff --git a/doc/docgen.md b/doc/docgen.md
index 34023f1eb8..52d855e6a9 100644
--- a/doc/docgen.md
+++ b/doc/docgen.md
@@ -735,6 +735,24 @@ with a hyperlink to your own code repository.
In the case of Nim's own documentation, the `commit` value is just a commit
hash to append to a formatted URL to https://github.com/nim-lang/Nim.
+Substitution via environment variables
+--------------------------------------
+
+A simple substitution using environment variables is available.
+A reference written as ``|name|`` is replaced during documentation generation if
+a matching variable is provided. You can define it via the compiler with
+``--putenv``. This is useful for injecting values like version strings or
+build-specific text.
+
+ ```nim
+ ## |foo|
+ ```
+
+ ```cmd
+ nim --putenv:foo=bar doc filename.nim
+ ```
+
+The generated html will contain ``bar`` instead of ``foo``.
Other Input Formats
===================
diff --git a/doc/nimdoc.css b/doc/nimdoc.css
index 893395d248..f4ac27b28d 100644
--- a/doc/nimdoc.css
+++ b/doc/nimdoc.css
@@ -155,7 +155,8 @@ body {
margin-left: 1%; }
@media print {
- #global-links, .link-seesrc, .theme-switch-wrapper, #searchInputDiv, .search-groupby {
+ #global-links, .link-seesrc, .theme-switch-wrapper, #searchInputDiv, .search-groupby,
+ #nav-burger, #nav-overlay, .three.columns {
display:none;
}
.columns {
@@ -174,6 +175,7 @@ body {
height: 100vh;
position: sticky;
top: 0px;
+ left: 0px;
overflow-y: auto;
padding: 2px;
}
@@ -187,9 +189,67 @@ body {
width: 100%;
margin-left: 0; }
+#nav-burger, #nav-overlay {
+ display: none;
+}
+
@media screen and (max-width: 860px) {
+ #nav-burger {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ position: fixed;
+ top: 0.25em;
+ left: 0.25em;
+ z-index: 200;
+ width: 1.6rem;
+ height: 1.6rem;
+ font-size: 1.25em;
+ cursor: pointer;
+ border-radius: 4px;
+ background-color: var(--secondary-background);
+ color: var(--text);
+ border: 1px solid var(--border);
+ user-select: none;
+ opacity: 0.55;
+ }
+ #nav-burger:hover {
+ background-color: var(--third-background);
+ }
+ #nav-toggle:checked ~ .container .three.columns {
+ transform: translateX(0);
+ }
+ #nav-toggle:checked ~ #nav-overlay {
+ opacity: 1;
+ pointer-events: auto;
+ }
+ #nav-overlay {
+ display: block;
+ position: fixed;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ right: 0;
+ z-index: 99; /* below sidebar */
+ background: rgba(0, 0, 0, 0.35);
+ opacity: 0;
+ pointer-events: none;
+ transition: opacity 0.22s ease;
+ }
.three.columns {
- display: none;
+ display: block;
+ position: fixed;
+ left: 0;
+ width: min(80vw, 24em);
+ padding-top: 1.6em;
+ height: 100vh; /* Fallback */
+ height: 100dvh;
+ overflow-y: auto;
+ z-index: 100;
+ background-color: var(--secondary-background);
+ box-shadow: 2px 0 12px rgba(0,0,0,0.25);
+ transform: translateX(-110%);
+ transition: transform 0.25s ease;
}
.nine.columns {
width: 100%;
@@ -199,6 +259,8 @@ body {
body {
font-size: 1em;
line-height: 1.35;
+ margin-left: 0.35em;
+ margin-right: 0.35em;
}
}
@@ -357,6 +419,10 @@ img {
h1.title {
page-break-before: avoid; }
+
+ .nine.columns h1:first-of-type {
+ page-break-before: avoid;
+ }
p, h2, h3 {
orphans: 3;
@@ -424,6 +490,22 @@ h5 {
h6 {
font-size: 1.1em; }
+@media screen and (max-width: 860px) {
+ h1.title {
+ font-size: 2em;
+ }
+ h1 {
+ font-size: 1.5em;
+ margin-top: 1.5em;
+ margin-bottom: 0.75em;
+ }
+ h2 {
+ margin-top: 1.3em;
+ }
+ h3 {
+ margin-top: 1.2em;
+ }
+}
ul, ol {
padding: 0;
@@ -607,6 +689,15 @@ pre {
border-radius: 6px;
}
+@media screen and (max-width: 860px) {
+ pre {
+ font-stretch: semi-condensed;
+ letter-spacing: -0.25px;
+ line-height: 1.25;
+ padding: 0.33em;
+ }
+}
+
.copyToClipBoardBtn {
visibility: hidden;
position: absolute;
diff --git a/koch.nim b/koch.nim
index bd3ac7e283..0fd0e365c9 100644
--- a/koch.nim
+++ b/koch.nim
@@ -16,7 +16,7 @@ const
ChecksumsStableCommit = "0b8e46379c5bc1bf73d8b3011908389c60fb9b98" # 2.0.1
SatStableCommit = "e63eaea8baf00bed8bcd5a29ffd8823abb265b39"
- NimonyStableCommit = "ea20829a61fc770f858ea2afa59c5c5e7edbae70" # unversioned \
+ NimonyStableCommit = "bbfb21529845567c55b67d176354daef0e7d6c29" # unversioned \
# Note that Nimony uses Nim as a git submodule but we don't want to install
# Nimony's dependency to Nim as we are Nim. So a `git clone` without --recursive
# is **required** here.
diff --git a/lib/pure/collections/sequtils.nim b/lib/pure/collections/sequtils.nim
index 3dba087aa8..299349a05a 100644
--- a/lib/pure/collections/sequtils.nim
+++ b/lib/pure/collections/sequtils.nim
@@ -1092,7 +1092,7 @@ template mapIt*(s: typed, op: untyped): untyped =
type OutType = typeof((
block:
- var it{.inject.}: typeof(items(s), typeOfIter);
+ var it{.inject, used.}: typeof(items(s), typeOfIter);
op), typeOfProc)
when OutType is not (proc):
# Here, we avoid to create closures in loops.
diff --git a/lib/pure/collections/sets.nim b/lib/pure/collections/sets.nim
index 7d92aab5a7..8a69304898 100644
--- a/lib/pure/collections/sets.nim
+++ b/lib/pure/collections/sets.nim
@@ -130,6 +130,7 @@ proc initHashSet*[A](initialSize = defaultInitialSize): HashSet[A] =
var a = initHashSet[int]()
a.incl(3)
assert len(a) == 1
+
result = default(HashSet[A])
result.init(initialSize)
@@ -139,7 +140,7 @@ proc `[]`*[A](s: var HashSet[A], key: A): var A =
##
## This is useful when one overloaded `hash` and `==` but still needs
## reference semantics for sharing.
- var hc: Hash
+ var hc = default(Hash)
var index = rawGet(s, key, hc)
if index >= 0: result = s.data[index].key
else:
@@ -165,7 +166,7 @@ proc contains*[A](s: HashSet[A], key: A): bool =
assert values.contains(2)
assert 2 in values
- var hc: Hash
+ var hc = default(Hash)
var index = rawGet(s, key, hc)
result = index >= 0
@@ -670,6 +671,7 @@ proc initOrderedSet*[A](initialSize = defaultInitialSize): OrderedSet[A] =
var a = initOrderedSet[int]()
a.incl(3)
assert len(a) == 1
+
result = OrderedSet[A]()
result.init(initialSize)
@@ -710,7 +712,7 @@ proc contains*[A](s: OrderedSet[A], key: A): bool =
assert values.contains(2)
assert 2 in values
- var hc: Hash
+ var hc = default(Hash)
var index = rawGet(s, key, hc)
result = index >= 0
@@ -889,8 +891,6 @@ proc `$`*[A](s: OrderedSet[A]): string =
## ```
dollarImpl()
-
-
iterator items*[A](s: OrderedSet[A]): A =
## Iterates over keys in the ordered set `s` in insertion order.
##
diff --git a/nimdoc/extlinks/project/expected/_._/util.html b/nimdoc/extlinks/project/expected/_._/util.html
index 32dab9216a..37be00501e 100644
--- a/nimdoc/extlinks/project/expected/_._/util.html
+++ b/nimdoc/extlinks/project/expected/_._/util.html
@@ -23,6 +23,9 @@
+
+
+
nimdoc/extlinks/util
diff --git a/nimdoc/extlinks/project/expected/doc/manual.html b/nimdoc/extlinks/project/expected/doc/manual.html
index 2946f803ab..dbdfb6193c 100644
--- a/nimdoc/extlinks/project/expected/doc/manual.html
+++ b/nimdoc/extlinks/project/expected/doc/manual.html
@@ -23,6 +23,9 @@
+
+
+
Nothing User Manual
diff --git a/nimdoc/extlinks/project/expected/main.html b/nimdoc/extlinks/project/expected/main.html
index 2aaf19b3af..7ee68ca119 100644
--- a/nimdoc/extlinks/project/expected/main.html
+++ b/nimdoc/extlinks/project/expected/main.html
@@ -23,6 +23,9 @@
+
+
+
nimdoc/extlinks/project/main
diff --git a/nimdoc/extlinks/project/expected/sub/submodule.html b/nimdoc/extlinks/project/expected/sub/submodule.html
index cd95a9c54e..1b38da944f 100644
--- a/nimdoc/extlinks/project/expected/sub/submodule.html
+++ b/nimdoc/extlinks/project/expected/sub/submodule.html
@@ -23,6 +23,9 @@
+
+
+
nimdoc/extlinks/project/sub/submodule
diff --git a/nimdoc/extlinks/project/expected/theindex.html b/nimdoc/extlinks/project/expected/theindex.html
index cf250edd16..d3706a4af5 100644
--- a/nimdoc/extlinks/project/expected/theindex.html
+++ b/nimdoc/extlinks/project/expected/theindex.html
@@ -23,6 +23,9 @@
+
+
+
Index
Documents:
Nothing User Manual.
Modules:
../util,
main,
sub/submodule.
API symbols
diff --git a/nimdoc/rst2html/expected/rst_examples.html b/nimdoc/rst2html/expected/rst_examples.html
index a267041331..ceadfeb5a3 100644
--- a/nimdoc/rst2html/expected/rst_examples.html
+++ b/nimdoc/rst2html/expected/rst_examples.html
@@ -23,6 +23,9 @@
+
+
+
Not a Nim Manual
diff --git a/nimdoc/test_doctype/expected/test_doctype.html b/nimdoc/test_doctype/expected/test_doctype.html
index 2cbf6ec0f8..548deb37e3 100644
--- a/nimdoc/test_doctype/expected/test_doctype.html
+++ b/nimdoc/test_doctype/expected/test_doctype.html
@@ -23,6 +23,9 @@
+
+
+
nimdoc/test_doctype/test_doctype
diff --git a/nimdoc/test_out_index_dot_html/expected/index.html b/nimdoc/test_out_index_dot_html/expected/index.html
index 4370f0df8a..e287ec60fa 100644
--- a/nimdoc/test_out_index_dot_html/expected/index.html
+++ b/nimdoc/test_out_index_dot_html/expected/index.html
@@ -23,6 +23,9 @@
+
+
+
nimdoc/test_out_index_dot_html/foo
diff --git a/nimdoc/test_out_index_dot_html/expected/theindex.html b/nimdoc/test_out_index_dot_html/expected/theindex.html
index ca7c2d7af8..24c4f2df4a 100644
--- a/nimdoc/test_out_index_dot_html/expected/theindex.html
+++ b/nimdoc/test_out_index_dot_html/expected/theindex.html
@@ -23,6 +23,9 @@
+
+
+
Index
Modules:
index.
API symbols
diff --git a/nimdoc/testproject/expected/nimdoc.out.css b/nimdoc/testproject/expected/nimdoc.out.css
index 893395d248..f4ac27b28d 100644
--- a/nimdoc/testproject/expected/nimdoc.out.css
+++ b/nimdoc/testproject/expected/nimdoc.out.css
@@ -155,7 +155,8 @@ body {
margin-left: 1%; }
@media print {
- #global-links, .link-seesrc, .theme-switch-wrapper, #searchInputDiv, .search-groupby {
+ #global-links, .link-seesrc, .theme-switch-wrapper, #searchInputDiv, .search-groupby,
+ #nav-burger, #nav-overlay, .three.columns {
display:none;
}
.columns {
@@ -174,6 +175,7 @@ body {
height: 100vh;
position: sticky;
top: 0px;
+ left: 0px;
overflow-y: auto;
padding: 2px;
}
@@ -187,9 +189,67 @@ body {
width: 100%;
margin-left: 0; }
+#nav-burger, #nav-overlay {
+ display: none;
+}
+
@media screen and (max-width: 860px) {
+ #nav-burger {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ position: fixed;
+ top: 0.25em;
+ left: 0.25em;
+ z-index: 200;
+ width: 1.6rem;
+ height: 1.6rem;
+ font-size: 1.25em;
+ cursor: pointer;
+ border-radius: 4px;
+ background-color: var(--secondary-background);
+ color: var(--text);
+ border: 1px solid var(--border);
+ user-select: none;
+ opacity: 0.55;
+ }
+ #nav-burger:hover {
+ background-color: var(--third-background);
+ }
+ #nav-toggle:checked ~ .container .three.columns {
+ transform: translateX(0);
+ }
+ #nav-toggle:checked ~ #nav-overlay {
+ opacity: 1;
+ pointer-events: auto;
+ }
+ #nav-overlay {
+ display: block;
+ position: fixed;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ right: 0;
+ z-index: 99; /* below sidebar */
+ background: rgba(0, 0, 0, 0.35);
+ opacity: 0;
+ pointer-events: none;
+ transition: opacity 0.22s ease;
+ }
.three.columns {
- display: none;
+ display: block;
+ position: fixed;
+ left: 0;
+ width: min(80vw, 24em);
+ padding-top: 1.6em;
+ height: 100vh; /* Fallback */
+ height: 100dvh;
+ overflow-y: auto;
+ z-index: 100;
+ background-color: var(--secondary-background);
+ box-shadow: 2px 0 12px rgba(0,0,0,0.25);
+ transform: translateX(-110%);
+ transition: transform 0.25s ease;
}
.nine.columns {
width: 100%;
@@ -199,6 +259,8 @@ body {
body {
font-size: 1em;
line-height: 1.35;
+ margin-left: 0.35em;
+ margin-right: 0.35em;
}
}
@@ -357,6 +419,10 @@ img {
h1.title {
page-break-before: avoid; }
+
+ .nine.columns h1:first-of-type {
+ page-break-before: avoid;
+ }
p, h2, h3 {
orphans: 3;
@@ -424,6 +490,22 @@ h5 {
h6 {
font-size: 1.1em; }
+@media screen and (max-width: 860px) {
+ h1.title {
+ font-size: 2em;
+ }
+ h1 {
+ font-size: 1.5em;
+ margin-top: 1.5em;
+ margin-bottom: 0.75em;
+ }
+ h2 {
+ margin-top: 1.3em;
+ }
+ h3 {
+ margin-top: 1.2em;
+ }
+}
ul, ol {
padding: 0;
@@ -607,6 +689,15 @@ pre {
border-radius: 6px;
}
+@media screen and (max-width: 860px) {
+ pre {
+ font-stretch: semi-condensed;
+ letter-spacing: -0.25px;
+ line-height: 1.25;
+ padding: 0.33em;
+ }
+}
+
.copyToClipBoardBtn {
visibility: hidden;
position: absolute;
diff --git a/nimdoc/testproject/expected/subdir/subdir_b/utils.html b/nimdoc/testproject/expected/subdir/subdir_b/utils.html
index 3d994aca66..6e56d9d93d 100644
--- a/nimdoc/testproject/expected/subdir/subdir_b/utils.html
+++ b/nimdoc/testproject/expected/subdir/subdir_b/utils.html
@@ -23,6 +23,9 @@
+
+
+
subdir/subdir_b/utils
diff --git a/nimdoc/testproject/expected/testproject.html b/nimdoc/testproject/expected/testproject.html
index 2a5e9aa8a8..7bf409cfff 100644
--- a/nimdoc/testproject/expected/testproject.html
+++ b/nimdoc/testproject/expected/testproject.html
@@ -23,6 +23,9 @@
+
+
+
testproject
diff --git a/nimdoc/testproject/expected/theindex.html b/nimdoc/testproject/expected/theindex.html
index 62b9da9a2a..f676ade775 100644
--- a/nimdoc/testproject/expected/theindex.html
+++ b/nimdoc/testproject/expected/theindex.html
@@ -23,6 +23,9 @@