site/docs improvements
This commit is contained in:
parent
26ddb94f5d
commit
e584c7aa63
@ -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
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
# Declaring arguments in Lyng
|
||||
|
||||
[//]: # (topMenu)
|
||||
|
||||
It is a common thing that occurs in many places in Lyng, function declarations,
|
||||
lambdas and class declarations.
|
||||
|
||||
|
||||
@ -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)
|
||||
and cooperatively parallel (coroutine based) everywhere.
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
|
||||
# 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.
|
||||
|
||||
Keys can be either:
|
||||
|
||||
@ -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.
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
# 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`.
|
||||
|
||||
Currently, Lyng implements the "subject" form: `when(value) { ... }`. The subject-less form `when { condition -> ... }` is not implemented yet.
|
||||
|
||||
@ -379,8 +379,9 @@ suspend fun initDocsDropdown() {
|
||||
val arr = JSON.parse(text) as Array<String>
|
||||
val all = arr.toList().sorted()
|
||||
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 titles = mutableMapOf<String, String>()
|
||||
var excluded = 0
|
||||
var failed = 0
|
||||
for (path in all) {
|
||||
@ -393,8 +394,12 @@ suspend fun initDocsDropdown() {
|
||||
continue
|
||||
}
|
||||
val body = r.text().await()
|
||||
if (!body.contains("[//]: # (excludeFromIndex)")) {
|
||||
if (!body.contains("[//]: # (excludeFromIndex)") &&
|
||||
body.contains("[//]: # (topMenu)") ) {
|
||||
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++
|
||||
} catch (t: Throwable) {
|
||||
failed++
|
||||
@ -404,10 +409,10 @@ suspend fun initDocsDropdown() {
|
||||
dlog("docs-dd", "filtered=${filtered.size} excluded=$excluded failed=$failed")
|
||||
// Sort entries by display name (file name) case-insensitively
|
||||
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
|
||||
sortedFiltered.forEach { path ->
|
||||
val name = path.substringAfterLast('/')
|
||||
val name = titles[path] ?: path.substringAfterLast('/')
|
||||
val li = document.createElement("li")
|
||||
val a = document.createElement("a") as HTMLAnchorElement
|
||||
a.className = "dropdown-item"
|
||||
|
||||
@ -212,12 +212,14 @@
|
||||
</a>
|
||||
<ul id="docsDropdownMenu" class="dropdown-menu">
|
||||
<!-- Will be populated at runtime -->
|
||||
<li><a class="dropdown-item" href="#/docs/tutorial.md" data-route="docs">tutorial</a></li>
|
||||
<li><hr class="dropdown-divider"></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>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
<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>
|
||||
</ul>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user