From 4414b5a396fa00f2cfeca385445d0fd6077bed93 Mon Sep 17 00:00:00 2001 From: Ryan McConnell Date: Mon, 23 Mar 2026 05:35:27 -0400 Subject: [PATCH 1/6] small `sets.nim` cleanup in std (#25628) mainly to fix `Uninit` warnings for projects that elevate it to an error. Other changes are stylistic about redundancy or white-space consistency. --- lib/pure/collections/sets.nim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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. ## From 57e15cd9a4fb11e02fcc55be714f3628d3687cff Mon Sep 17 00:00:00 2001 From: Zoom Date: Mon, 23 Mar 2026 15:31:51 +0400 Subject: [PATCH 2/6] nimdoc: Add a nav-burger to display the panel on mobile (#25606) Small changes to the default html template and the `nimdoc.css`. Adds a burger button to show the navigation panel when on narrow screens/mobile. Displayed when the panel gets hidden. Second element click or click on the dimmed background ides the panel. # Demo: ![burger-action](https://github.com/user-attachments/assets/a10bd626-95a1-4a04-80bb-c159c85ac1a7) --- config/nimdoc.cfg | 3 + doc/nimdoc.css | 64 ++++++++++++++++++- .../extlinks/project/expected/_._/util.html | 3 + .../extlinks/project/expected/doc/manual.html | 3 + nimdoc/extlinks/project/expected/main.html | 3 + .../project/expected/sub/submodule.html | 3 + .../extlinks/project/expected/theindex.html | 3 + nimdoc/rst2html/expected/rst_examples.html | 3 + .../test_doctype/expected/test_doctype.html | 3 + .../expected/index.html | 3 + .../expected/theindex.html | 3 + nimdoc/testproject/expected/nimdoc.out.css | 64 ++++++++++++++++++- .../expected/subdir/subdir_b/utils.html | 3 + nimdoc/testproject/expected/testproject.html | 3 + nimdoc/testproject/expected/theindex.html | 3 + 15 files changed, 163 insertions(+), 4 deletions(-) diff --git a/config/nimdoc.cfg b/config/nimdoc.cfg index 99751f79df..4f608bc4f1 100644 --- a/config/nimdoc.cfg +++ b/config/nimdoc.cfg @@ -248,6 +248,9 @@ doc.file = """
+ + +

$title

$subtitle $content diff --git a/doc/nimdoc.css b/doc/nimdoc.css index 893395d248..ff77a51cb8 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%; 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..ff77a51cb8 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%; 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 @@
+ + +

Index

Modules: subdir/subdir_b/utils, testproject.

API symbols

From 446d903fc1f0330d4b273580c747945ffd7e1cc6 Mon Sep 17 00:00:00 2001 From: Zoom Date: Mon, 23 Mar 2026 16:00:07 +0400 Subject: [PATCH 3/6] nimdoc: CSS: tighter on mobile; fix h1 print page break (#25607) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Small optimizations for mobile, makes code render slightly tighter. - `font-stretch: semi-condensed;` for pre works if the user's font provides such a face, shouldn’t change the rendering with the default. - Removes an excessive page break after the page header when printing. Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> --- doc/nimdoc.css | 31 ++++++++++++++++++++++ nimdoc/testproject/expected/nimdoc.out.css | 31 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/doc/nimdoc.css b/doc/nimdoc.css index ff77a51cb8..f4ac27b28d 100644 --- a/doc/nimdoc.css +++ b/doc/nimdoc.css @@ -259,6 +259,8 @@ body { body { font-size: 1em; line-height: 1.35; + margin-left: 0.35em; + margin-right: 0.35em; } } @@ -417,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; @@ -484,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; @@ -667,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/nimdoc.out.css b/nimdoc/testproject/expected/nimdoc.out.css index ff77a51cb8..f4ac27b28d 100644 --- a/nimdoc/testproject/expected/nimdoc.out.css +++ b/nimdoc/testproject/expected/nimdoc.out.css @@ -259,6 +259,8 @@ body { body { font-size: 1em; line-height: 1.35; + margin-left: 0.35em; + margin-right: 0.35em; } } @@ -417,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; @@ -484,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; @@ -667,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; From c33df006c5297da75bd8f93f811131f6653db1c2 Mon Sep 17 00:00:00 2001 From: Zoom Date: Mon, 23 Mar 2026 16:00:55 +0400 Subject: [PATCH 4/6] nimdoc: Document environment variable substitution (#25623) Documents environment variable substitution. Didn't find it mentioned anywhere, even though it's used widely by the compiler docs. --- doc/docgen.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 =================== From 7ef16ec7a13b9845a7afd587abcae1aca6f05cb0 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 23 Mar 2026 20:28:19 +0800 Subject: [PATCH 5/6] Update NimonyStableCommit to a new version (#25638) --- koch.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From fb6fa9697907e387b1408320a070c263ad19201b Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 23 Mar 2026 20:31:09 +0800 Subject: [PATCH 6/6] fixes #25626; Fix injection variable declaration in sequtils.nim (#25629) fixes #25626 This pull request introduces a small change to the `mapIt` template in `sequtils.nim`. The update adds the `used` pragma to the injected `it` variable, which can help suppress unused variable warnings in certain cases. - Added the `used` pragma to the injected `it` variable in the `mapIt` template to prevent unused variable warnings. or it should give a better warning or something if `it` is not used --- lib/pure/collections/sequtils.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.