Merge branch 'devel' into pr_exportc_error

This commit is contained in:
ringabout
2026-03-23 20:52:58 +08:00
committed by GitHub
19 changed files with 250 additions and 11 deletions

View File

@@ -248,6 +248,9 @@ doc.file = """<?xml version="1.0" encoding="utf-8" ?>
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">&#9776;</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">$title</h1>$subtitle
$content

View File

@@ -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
===================

View File

@@ -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;

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.
##

View File

@@ -23,6 +23,9 @@
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">&#9776;</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">nimdoc/extlinks/util</h1>
<div class="row">

View File

@@ -23,6 +23,9 @@
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">&#9776;</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">Nothing User Manual</h1>

View File

@@ -23,6 +23,9 @@
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">&#9776;</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">nimdoc/extlinks/project/main</h1>
<div class="row">

View File

@@ -23,6 +23,9 @@
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">&#9776;</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">nimdoc/extlinks/project/sub/submodule</h1>
<div class="row">

View File

@@ -23,6 +23,9 @@
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">&#9776;</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">Index</h1>
Documents: <a href="doc/manual.html">Nothing User Manual</a>.<br/><p />Modules: <a href="_._/util.html">../util</a>, <a href="main.html">main</a>, <a href="sub/submodule.html">sub/submodule</a>.<br/><p /><h2>API symbols</h2>

View File

@@ -23,6 +23,9 @@
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">&#9776;</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">Not a Nim Manual</h1>
<div class="row">

View File

@@ -23,6 +23,9 @@
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">&#9776;</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">nimdoc/test_doctype/test_doctype</h1>
<div class="row">

View File

@@ -23,6 +23,9 @@
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">&#9776;</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">nimdoc/test_out_index_dot_html/foo</h1>
<div class="row">

View File

@@ -23,6 +23,9 @@
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">&#9776;</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">Index</h1>
Modules: <a href="index.html">index</a>.<br/><p /><h2>API symbols</h2>

View File

@@ -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;

View File

@@ -23,6 +23,9 @@
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">&#9776;</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">subdir/subdir_b/utils</h1>
<div class="row">

View File

@@ -23,6 +23,9 @@
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">&#9776;</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">testproject</h1>
<div class="row">

View File

@@ -23,6 +23,9 @@
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">&#9776;</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">Index</h1>
Modules: <a href="subdir/subdir_b/utils.html">subdir/subdir_b/utils</a>, <a href="testproject.html">testproject</a>.<br/><p /><h2>API symbols</h2>