site/docs improvements

This commit is contained in:
Sergey Chernov 2025-11-28 11:25:47 +01:00
parent 26ddb94f5d
commit e584c7aa63
8 changed files with 33 additions and 11 deletions

View File

@ -1,6 +1,10 @@
# OO implementation in Lyng # Object-oriented programming
## Declaration [//]: # (topMenu)
Lyng supports first class OOP constructs, based on classes with multiple inheritance.
## Class Declaration
The class clause looks like The class clause looks like

View File

@ -1,5 +1,7 @@
# Declaring arguments in Lyng # Declaring arguments in Lyng
[//]: # (topMenu)
It is a common thing that occurs in many places in Lyng, function declarations, It is a common thing that occurs in many places in Lyng, function declarations,
lambdas and class declarations. lambdas and class declarations.

View File

@ -1,4 +1,6 @@
# Parallelism in Lyng # Multithreading/parallel execution
[//]: # (topMenu)
Lyng is built to me multithreaded where possible (e.g. all targets byt JS and wasmJS as for now) Lyng is built to me multithreaded where possible (e.g. all targets byt JS and wasmJS as for now)
and cooperatively parallel (coroutine based) everywhere. and cooperatively parallel (coroutine based) everywhere.

View File

@ -1,6 +1,8 @@
# Map literals — refined proposal # Map literals — refined proposal
[//]: # (excludeFromIndex)
Implement JavaScript-like literals for maps. The syntax and semantics align with named arguments in function calls, but map literals are expressions that construct `Map` values. Implement JavaScript-like literals for maps. The syntax and semantics align with named arguments in function calls, but map literals are expressions that construct `Map` values.
Keys can be either: Keys can be either:

View File

@ -1,4 +1,7 @@
# Named arguments proposal # Named arguments in calls
[//]: # (excludeFromIndex)
Extend function/method calls to allow setting arguments by name using colon syntax at call sites. This is especially convenient with many parameters and default values. Extend function/method calls to allow setting arguments by name using colon syntax at call sites. This is especially convenient with many parameters and default values.

View File

@ -1,5 +1,7 @@
# The `when` statement (expression) # The `when` statement (expression)
[//]: # (topMenu)
Lyng provides a concise multi-branch selection with `when`, heavily inspired by Kotlin. In Lyng, `when` is an expression: it evaluates to a value. If the selected branch contains no value (e.g., it ends with `void` or calls a void function like `println`), the whole `when` expression evaluates to `void`. Lyng provides a concise multi-branch selection with `when`, heavily inspired by Kotlin. In Lyng, `when` is an expression: it evaluates to a value. If the selected branch contains no value (e.g., it ends with `void` or calls a void function like `println`), the whole `when` expression evaluates to `void`.
Currently, Lyng implements the "subject" form: `when(value) { ... }`. The subject-less form `when { condition -> ... }` is not implemented yet. Currently, Lyng implements the "subject" form: `when(value) { ... }`. The subject-less form `when { condition -> ... }` is not implemented yet.

View File

@ -379,8 +379,9 @@ suspend fun initDocsDropdown() {
val arr = JSON.parse(text) as Array<String> val arr = JSON.parse(text) as Array<String>
val all = arr.toList().sorted() val all = arr.toList().sorted()
dlog("docs-dd", "index entries=${all.size}") dlog("docs-dd", "index entries=${all.size}")
// Filter excluded by reading each markdown and looking for the marker // Filter excluded by reading each markdown and looking for the marker, and collect titles
val filtered = mutableListOf<String>() val filtered = mutableListOf<String>()
val titles = mutableMapOf<String, String>()
var excluded = 0 var excluded = 0
var failed = 0 var failed = 0
for (path in all) { for (path in all) {
@ -393,8 +394,12 @@ suspend fun initDocsDropdown() {
continue continue
} }
val body = r.text().await() val body = r.text().await()
if (!body.contains("[//]: # (excludeFromIndex)")) { if (!body.contains("[//]: # (excludeFromIndex)") &&
body.contains("[//]: # (topMenu)") ) {
filtered.add(path) filtered.add(path)
// Reuse shared title extractor: first H1 or fallback to file name
val title = extractTitleFromMarkdown(body) ?: path.substringAfterLast('/')
titles[path] = title
} else excluded++ } else excluded++
} catch (t: Throwable) { } catch (t: Throwable) {
failed++ failed++
@ -404,10 +409,10 @@ suspend fun initDocsDropdown() {
dlog("docs-dd", "filtered=${filtered.size} excluded=$excluded failed=$failed") dlog("docs-dd", "filtered=${filtered.size} excluded=$excluded failed=$failed")
// Sort entries by display name (file name) case-insensitively // Sort entries by display name (file name) case-insensitively
val sortedFiltered = filtered.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.substringAfterLast('/') }) val sortedFiltered = filtered.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.substringAfterLast('/') })
// Build items after the static first two existing children (tutorial + divider) // Build items after the static first items (tutorial, optional static entries, divider)
var appended = 0 var appended = 0
sortedFiltered.forEach { path -> sortedFiltered.forEach { path ->
val name = path.substringAfterLast('/') val name = titles[path] ?: path.substringAfterLast('/')
val li = document.createElement("li") val li = document.createElement("li")
val a = document.createElement("a") as HTMLAnchorElement val a = document.createElement("a") as HTMLAnchorElement
a.className = "dropdown-item" a.className = "dropdown-item"

View File

@ -212,12 +212,14 @@
</a> </a>
<ul id="docsDropdownMenu" class="dropdown-menu"> <ul id="docsDropdownMenu" class="dropdown-menu">
<!-- Will be populated at runtime --> <!-- Will be populated at runtime -->
<li><a class="dropdown-item" href="#/docs/tutorial.md" data-route="docs">tutorial</a></li> <li><a class="dropdown-item" href="#/docs/tutorial.md" data-route="docs">Tutorial</a></li>
<li><a class="dropdown-item" href="#/reference" data-route="reference">Reference</a></li>
<li><hr class="dropdown-divider"></li> <li><hr class="dropdown-divider"></li>
</ul> </ul>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#/reference" data-route="reference">Reference</a> <a class="nav-link" href="#/tryling" data-route="tryling">Try in browser</a>
</li> </li>
</ul> </ul>