Thin the app's comments
The same pass the server had, on the Kotlin side: comments restating what the code says are gone, and the ones recording a measurement, a constraint or an incident are kept but cut to a few lines each. 6540 comment lines to 5674, and 920 lines off the app. Two doc comments had drifted onto the item above the one they describe -- `contextAfter`'s onto `sessionWorking` in Events.kt, and `UsageMonitor`'s equivalent on the server was fixed in the previous commit. Each is back on its own item, which is the only non-comment line this diff moves. The comments are reflowed to the column limit at their own indentation: several were written wide, and ktfmt re-wrapped them into lines holding a single orphan word. `/tmp` script, not kept -- ktfmt is idempotent over the result, which is the check. Left alone deliberately: this codebase's remaining comment density is high because the comments carry things the code cannot say -- what a null means, what a number was measured against, which bug a guard exists for. Of the 238 one-line doc comments in the app, five were pure restatement of the name and were removed; the rest each say something the signature does not. ktfmtFormat, compileDebugKotlin, lintDebug and testDebugUnitTest pass; cargo test (127), clippy --all-targets and fmt still clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
79682f03a7
commit
edc39c7371
68 files changed
+2077
-2997
No files matched your search
@@ -30,14 +30,12 @@ import org.intellij.markdown.ast.getTextInNode
|
||||
* sits on, scrolling sideways rather than wrapping.
|
||||
*
|
||||
* The renderer's own fence drew the same block in plain text. The scanner that colours a tool
|
||||
* call's command colours a reply's code the same way, through [highlighted] and one palette, so a
|
||||
* `kotlin` fence and the Kotlin a tool wrote are the same colours. A fence in a language [scan] has
|
||||
* no rules for is plain rather than wrongly coloured: [fenceLanguage] answers null for those, and
|
||||
* plain is what the reader would have seen before.
|
||||
* call's command colours a reply's code the same way, so a `kotlin` fence and the Kotlin a tool
|
||||
* wrote are the same colours. A fence in a language [scan] has no rules for is plain rather than
|
||||
* wrongly coloured.
|
||||
*
|
||||
* Finding the code is still the library's: which children of the node are the fence markers, the
|
||||
* language word and the code between them is its knowledge of the parser, and [MarkdownCodeFence]
|
||||
* hands out the code and the language and leaves the drawing to the block it is given.
|
||||
* language word and the code between them is its knowledge of the parser.
|
||||
*/
|
||||
@Composable
|
||||
fun CodeFence(
|
||||
@@ -67,14 +65,12 @@ fun CodeBlock(
|
||||
/**
|
||||
* The code inside a fence or indented block, and the highlighter's language for its info word.
|
||||
*
|
||||
* Which children of the node are the fence markers, the language word and the code between them is
|
||||
* the library's knowledge of the parser, copied from its `MarkdownCodeFence` rather than called:
|
||||
* that one is a composable, and the whole point of this function is that [warm] can run it on a
|
||||
* background thread and highlight the same string the drawing will ask for. Two extractions would
|
||||
* be two keys, and the warmed answer would be silently missed at every fence.
|
||||
* Copied from the library's `MarkdownCodeFence` rather than called: that one is a composable, and
|
||||
* the whole point here is that [warm] can run this on a background thread and highlight the same
|
||||
* string the drawing will ask for. Two extractions would be two keys, and the warmed answer would
|
||||
* be silently missed at every fence.
|
||||
*
|
||||
* Null for a fence too short to hold anything -- an unterminated one still arriving, which the
|
||||
* library skips as invalid.
|
||||
* Null for a fence too short to hold anything -- an unterminated one still arriving.
|
||||
*/
|
||||
fun fenceContent(content: String, node: ASTNode): Pair<String, Language?>? {
|
||||
val word =
|
||||
@@ -97,7 +93,6 @@ fun fenceContent(content: String, node: ASTNode): Pair<String, Language?>? {
|
||||
*
|
||||
* The renderer's own block, less what nothing here needs: the same background, corner, padding and
|
||||
* sideways scroll, without the shadow, the border and the empty pointer handler it also carried.
|
||||
* The vertical margin is the renderer's too, kept so a reply's fences sit where they always have.
|
||||
*/
|
||||
@Composable
|
||||
private fun CodeBlockText(
|
||||
@@ -117,8 +112,7 @@ private fun CodeBlockText(
|
||||
.semantics { isTraversalGroup = true }
|
||||
) {
|
||||
BasicText(
|
||||
// No language while the block is still being written, which is what draws it plain;
|
||||
// see [MarkdownRoot]'s `streaming`.
|
||||
// No language while the block is still being written, which is what draws it plain.
|
||||
replies.highlighted(code, language.takeUnless { streaming }),
|
||||
style = style,
|
||||
modifier = Modifier.horizontalScroll(rememberScrollState()).padding(padding.codeBlock),
|
||||
@@ -141,14 +135,12 @@ fun fenceLanguage(name: String?): Language? =
|
||||
* The highlighter's language for a *file*, from its name.
|
||||
*
|
||||
* The same table [fenceLanguage] reads, deliberately: it already keys on the extensions people
|
||||
* write after the backticks -- `kt`, `rs`, `py` -- because the extension is as often what gets
|
||||
* written there as the language's name. One table rather than two, so a language added for fences
|
||||
* is a language added for files and neither can be the one somebody forgot.
|
||||
* write after the backticks. One table rather than two, so a language added for fences is a
|
||||
* language added for files and neither can be the one somebody forgot.
|
||||
*
|
||||
* The extension is the part after the *last* dot, which is what makes `build.gradle.kts` Kotlin and
|
||||
* `Cargo.toml` TOML. A leading dot is not one: `.bashrc` has no extension, it has a name that
|
||||
* starts with a dot, and reading `bashrc` as an extension would look up a word no table has. A name
|
||||
* with no dot at all -- `Makefile`, `LICENSE` -- is likewise null, and null is drawn plain.
|
||||
* The extension is the part after the *last* dot, which is what makes `build.gradle.kts` Kotlin. A
|
||||
* leading dot is not one: `.bashrc` has no extension, it has a name that starts with a dot. A name
|
||||
* with no dot at all -- `Makefile` -- is likewise null, and null is drawn plain.
|
||||
*/
|
||||
fun fileLanguage(name: String): Language? {
|
||||
val dot = name.lastIndexOf('.')
|
||||
@@ -206,10 +198,9 @@ private val FENCE_LANGUAGES: Map<String, Language> =
|
||||
)
|
||||
|
||||
/**
|
||||
* Every fence in [parse], as the code and language [highlight] will be asked for.
|
||||
*
|
||||
* Walks the whole tree rather than the top level: a fence inside a list item or a quote is drawn
|
||||
* the same way and costs the same to lex.
|
||||
* Every fence in [parse], as the code and language [highlight] will be asked for. Walks the whole
|
||||
* tree rather than the top level: a fence inside a list item or a quote is drawn the same way and
|
||||
* costs the same to lex.
|
||||
*/
|
||||
fun fences(parse: State): List<Pair<String, Language?>> {
|
||||
val success = parse as? State.Success ?: return emptyList()
|
||||
|
||||
Reference in new issue
Block a user