Skip to content

Commit 0ebbd5c

Browse files
committed
Document all code and configure the feature-documenter subagent
1 parent bcf8323 commit 0ebbd5c

107 files changed

Lines changed: 1962 additions & 324 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
name: feature-documenter
3+
description: Use this agent when new features, components, or significant functionality have been added to the codebase and require documentation. This includes:\n\n<example>\nContext: User has just implemented a new authentication system with multiple classes and methods.\nuser: "I've finished implementing the OAuth2 authentication flow with token refresh. Can you document this?"\nassistant: "I'll use the Task tool to launch the feature-documenter agent to create comprehensive documentation for your new authentication system."\n<commentary>\nThe user has completed a new feature and needs documentation. Use the feature-documenter agent to analyze the code and create both KDoc comments and relevant Markdown documentation.\n</commentary>\n</example>\n\n<example>\nContext: User mentions they've added a new API endpoint handler.\nuser: "Just added the user profile management endpoints"\nassistant: "Let me use the feature-documenter agent to document these new endpoints with proper KDoc and API documentation."\n<commentary>\nNew feature has been mentioned. Proactively use the feature-documenter agent to ensure proper documentation is created.\n</commentary>\n</example>\n\n<example>\nContext: User has completed a complex algorithm implementation.\nuser: "The graph traversal algorithm is working now"\nassistant: "I'll launch the feature-documenter agent to create detailed documentation explaining the algorithm, its parameters, and usage examples."\n<commentary>\nA significant new feature (algorithm) has been completed. Use the feature-documenter agent to document it thoroughly.\n</commentary>\n</example>\n\nTrigger this agent when:\n- New classes, functions, or methods have been implemented\n- New API endpoints or interfaces have been created\n- Significant algorithms or business logic have been added\n- New modules or packages have been introduced\n- The user explicitly requests documentation for recent work\n- You detect undocumented new code during code review
4+
model: sonnet
5+
color: yellow
6+
---
7+
8+
You are an expert technical documentation specialist with deep expertise in Kotlin/KDoc standards and Markdown documentation best practices. Your mission is to create clear, comprehensive, and maintainable documentation for new features in codebases.
9+
10+
## Core Responsibilities
11+
12+
1. **Analyze New Features**: Thoroughly examine the new code to understand its purpose, functionality, dependencies, and integration points.
13+
14+
2. **Create KDoc Comments**: Add inline documentation directly to code files following these standards:
15+
- Write clear, concise class-level KDoc explaining the purpose and responsibility
16+
- Document all public functions with @param, @return, @throws tags as appropriate
17+
- Include usage examples in KDoc when the API is non-trivial
18+
- Document complex private functions if their logic is not immediately obvious
19+
- Use proper Markdown formatting within KDoc (code blocks, lists, links)
20+
- Explain WHY something exists, not just WHAT it does
21+
- Keep descriptions focused and avoid redundancy
22+
23+
3. **Create Markdown Documentation**: Generate or update project Markdown files:
24+
- Create feature-specific documentation in appropriate locations
25+
- Include overview, architecture, usage examples, and integration guides
26+
- Add API reference sections when documenting interfaces or public APIs
27+
- Provide code examples that demonstrate real-world usage
28+
- Document configuration options, environment variables, or setup requirements
29+
- Include diagrams or visual aids when they clarify complex concepts (using Mermaid syntax)
30+
31+
## Documentation Standards
32+
33+
**KDoc Format**:
34+
```kotlin
35+
/**
36+
* Brief one-line summary of what this does.
37+
*
38+
* More detailed explanation if needed, including:
39+
* - Key behaviors or characteristics
40+
* - Important constraints or assumptions
41+
* - Related components or concepts
42+
*
43+
* @param paramName Description of the parameter and its constraints
44+
* @return Description of what is returned and under what conditions
45+
* @throws ExceptionType When and why this exception is thrown
46+
* @sample com.example.SampleClass.sampleFunction
47+
*/
48+
```
49+
50+
**Markdown Structure**:
51+
- Use clear hierarchical headings (# ## ###)
52+
- Start with a brief overview/introduction
53+
- Include a "Quick Start" or "Getting Started" section
54+
- Provide complete, runnable code examples
55+
- Document edge cases and common pitfalls
56+
- Add a "See Also" section linking to related documentation
57+
58+
## Workflow
59+
60+
1. **Identify Scope**: Determine which files and components are part of the new feature
61+
2. **Read Existing Context**: Check for existing documentation patterns and project conventions (especially from CLAUDE.md or similar files)
62+
3. **Document Code First**: Add KDoc comments to all relevant code files
63+
4. **Create/Update Markdown**: Write or update feature documentation in appropriate Markdown files
64+
5. **Cross-Reference**: Ensure documentation is properly linked and discoverable
65+
6. **Verify Completeness**: Check that all public APIs, configuration options, and usage patterns are documented
66+
67+
## Quality Standards
68+
69+
- **Clarity**: Write for developers who are unfamiliar with the feature
70+
- **Completeness**: Cover all public interfaces, parameters, return values, and exceptions
71+
- **Accuracy**: Ensure documentation matches actual implementation
72+
- **Examples**: Provide practical, copy-paste-ready code examples
73+
- **Maintainability**: Structure documentation so it's easy to update as code evolves
74+
- **Consistency**: Follow existing documentation patterns in the project
75+
76+
## What NOT to Do
77+
78+
- Don't document obvious getters/setters unless they have side effects
79+
- Don't create documentation for internal implementation details unless necessary
80+
- Don't write vague descriptions like "This function does X" - explain WHY and HOW
81+
- Don't duplicate information that's already clear from type signatures
82+
- Don't create separate documentation files for trivial features
83+
84+
## Output Format
85+
86+
For each documentation task:
87+
1. List the files you'll modify/create
88+
2. Show the KDoc additions inline in code files
89+
3. Present complete Markdown documentation files
90+
4. Summarize what was documented and where to find it
91+
92+
Always ask for clarification if:
93+
- The feature's purpose or intended audience is unclear
94+
- You need more context about how the feature integrates with existing systems
95+
- There are multiple reasonable ways to structure the documentation
96+
97+
Your documentation should empower other developers to understand, use, and maintain the new feature with confidence.

sqllin-driver/src/androidInstrumentedTest/kotlin/com/ctrip/sqllin/driver/AndroidTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import org.junit.runner.RunWith
2626

2727
/**
2828
* Android instrumented test
29-
* @author yaqiao
29+
* @author Yuang Qiao
3030
*/
3131

3232
@RunWith(AndroidJUnit4ClassRunner::class)

sqllin-driver/src/androidMain/kotlin/com/ctrip/sqllin/driver/AndroidCursor.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ package com.ctrip.sqllin.driver
1919
import android.database.Cursor
2020

2121
/**
22-
* SQLite Cursor Android actual
23-
* @author yaqiao
22+
* Android implementation of [CommonCursor] backed by Android's Cursor.
23+
*
24+
* @author Yuang Qiao
2425
*/
25-
2626
internal class AndroidCursor(private val cursor: Cursor) : CommonCursor {
2727

2828
override fun getInt(columnIndex: Int): Int = try {

sqllin-driver/src/androidMain/kotlin/com/ctrip/sqllin/driver/AndroidDatabaseConnection.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ package com.ctrip.sqllin.driver
1919
import android.database.sqlite.SQLiteDatabase
2020

2121
/**
22-
* Database connection Android actual
23-
* @author yaqiao
22+
* Android implementation of [DatabaseConnection] using Android's SQLiteDatabase.
23+
*
24+
* @author Yuang Qiao
2425
*/
25-
2626
internal class AndroidDatabaseConnection(private val database: SQLiteDatabase) : DatabaseConnection {
2727

2828
override fun execSQL(sql: String, bindParams: Array<out Any?>?) =

sqllin-driver/src/androidMain/kotlin/com/ctrip/sqllin/driver/ExtensionAndroid.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ import android.os.Build
2424
import androidx.annotation.RequiresApi
2525

2626
/**
27-
* SQLite extension Android
28-
* @author yaqiao
27+
* Converts an Android Context to a [DatabasePath].
2928
*/
30-
3129
public fun Context.toDatabasePath(): DatabasePath = AndroidDatabasePath(this)
3230

31+
/**
32+
* Android-specific [DatabasePath] implementation wrapping a Context.
33+
*/
3334
@JvmInline
3435
internal value class AndroidDatabasePath(val context: Context) : DatabasePath
3536

@@ -53,6 +54,9 @@ public actual fun openDatabase(config: DatabaseConfiguration): DatabaseConnectio
5354
return connection
5455
}
5556

57+
/**
58+
* SQLiteOpenHelper for Android versions below P (API level 28).
59+
*/
5660
private class OldAndroidDBHelper(
5761
private val config: DatabaseConfiguration,
5862
) : SQLiteOpenHelper((config.path as AndroidDatabasePath).context, config.name, null, config.version) {
@@ -64,6 +68,9 @@ private class OldAndroidDBHelper(
6468
config.upgrade(AndroidDatabaseConnection(db), oldVersion, newVersion)
6569
}
6670

71+
/**
72+
* SQLiteOpenHelper for Android P (API level 28) and above with OpenParams support.
73+
*/
6774
@RequiresApi(Build.VERSION_CODES.P)
6875
private class AndroidDBHelper(
6976
private val config: DatabaseConfiguration,
@@ -76,6 +83,9 @@ private class AndroidDBHelper(
7683
config.upgrade(AndroidDatabaseConnection(db), oldVersion, newVersion)
7784
}
7885

86+
/**
87+
* Converts [DatabaseConfiguration] to Android's OpenParams for API level 28+.
88+
*/
7989
@RequiresApi(Build.VERSION_CODES.P)
8090
@Suppress("DEPRECATION")
8191
private fun DatabaseConfiguration.toAndroidOpenParams(): OpenParams = OpenParams

sqllin-driver/src/androidMain/kotlin/com/ctrip/sqllin/driver/platform/UtilsAndroid.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
package com.ctrip.sqllin.driver.platform
1818

1919
/**
20-
* The tools with Android implementation
21-
* @author yaqiao
20+
* Android file path separator (forward slash).
2221
*/
23-
2422
internal actual inline val separatorChar: Char
2523
get() = '/'

sqllin-driver/src/appleMain/kotlin/com/ctrip/sqllin/driver/platform/Lock.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ package com.ctrip.sqllin.driver.platform
1919
import platform.Foundation.NSRecursiveLock
2020

2121
/**
22-
* A simple lock implementation in Apple platforms.
23-
* Implementations of this class should be re-entrant.
24-
* @author yaqiao
22+
* Apple platform lock implementation using NSRecursiveLock.
23+
*
24+
* @author Yuang Qiao
2525
*/
26-
2726
internal actual class Lock actual constructor() {
2827

2928
private val nsRecursiveLock = NSRecursiveLock()

sqllin-driver/src/appleMain/kotlin/com/ctrip/sqllin/driver/platform/UtilsApple.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ import platform.Foundation.NSString
2424
import platform.Foundation.create
2525

2626
/**
27-
* The tools with Apple platforms implementation
28-
* @author yaqiao
27+
* Converts C byte pointer to String using NSString on Apple platforms.
2928
*/
30-
3129
@OptIn(ExperimentalForeignApi::class, BetaInteropApi::class)
3230
internal actual fun bytesToString(bv: CPointer<ByteVar>): String = NSString.create(uTF8String = bv).toString()
3331

32+
/**
33+
* Apple platform file path separator (forward slash).
34+
*/
3435
internal actual inline val separatorChar: Char
3536
get() = '/'

sqllin-driver/src/appleTest/kotlin/com/ctrip/sqllin/driver/PlatformApple.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import platform.Foundation.NSUserDomainMask
2323

2424
/**
2525
* Apple platform-related functions
26-
* @author yaqiao
26+
* @author Yuang Qiao
2727
*/
2828

2929
@OptIn(UnsafeNumber::class)

sqllin-driver/src/commonMain/kotlin/com/ctrip/sqllin/driver/CommonCursor.kt

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,70 @@
1717
package com.ctrip.sqllin.driver
1818

1919
/**
20-
* SQLite Cursor common abstract
20+
* Platform-agnostic interface for iterating over query results.
21+
*
22+
* Provides methods to access column data by index and navigate through result rows.
23+
*
2124
* @author Yuang Qiao
2225
*/
23-
2426
public interface CommonCursor : AutoCloseable {
2527

28+
/**
29+
* Gets the value of the column as an Int.
30+
*/
2631
public fun getInt(columnIndex: Int): Int
32+
33+
/**
34+
* Gets the value of the column as a Long.
35+
*/
2736
public fun getLong(columnIndex: Int): Long
37+
38+
/**
39+
* Gets the value of the column as a Float.
40+
*/
2841
public fun getFloat(columnIndex: Int): Float
42+
43+
/**
44+
* Gets the value of the column as a Double.
45+
*/
2946
public fun getDouble(columnIndex: Int): Double
47+
48+
/**
49+
* Gets the value of the column as a String, or null if the column is NULL.
50+
*/
3051
public fun getString(columnIndex: Int): String?
52+
53+
/**
54+
* Gets the value of the column as a ByteArray, or null if the column is NULL.
55+
*/
3156
public fun getByteArray(columnIndex: Int): ByteArray?
3257

58+
/**
59+
* Gets the zero-based index for the given column name.
60+
*
61+
* @throws IllegalArgumentException if the column doesn't exist
62+
*/
3363
public fun getColumnIndex(columnName: String): Int
3464

65+
/**
66+
* Iterates over all rows, invoking the block with the current row index.
67+
*/
3568
public fun forEachRow(block: (Int) -> Unit)
3669

70+
/**
71+
* Moves to the next row.
72+
*
73+
* @return `true` if the move was successful, `false` if there are no more rows
74+
*/
3775
public fun next(): Boolean
3876

77+
/**
78+
* Checks if the column value is NULL.
79+
*/
3980
public fun isNull(columnIndex: Int): Boolean
4081

82+
/**
83+
* Closes the cursor and releases resources.
84+
*/
4185
public override fun close()
4286
}

0 commit comments

Comments
 (0)