Skip to content

Commit 176f885

Browse files
author
Patrick Hoette
committed
Add more documentation
1 parent 840ee0e commit 176f885

32 files changed

Lines changed: 2134 additions & 428 deletions

.idea/copyright/MIT_Move.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/profiles_settings.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.junie/guidelines.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# M2Utility Project Guidelines
2+
3+
## Project Overview
4+
5+
M2Utility is a utility library designed to be used across a wide variety of projects. It provides flexible, extensible utilities that support a broad range of use cases. The project is structured as a multi-module Kotlin library with cross-platform (KMP) support.
6+
7+
## Code Style
8+
9+
### Kotlin Style Guide
10+
11+
We follow the [official Kotlin style guide](https://kotlinlang.org/docs/coding-conventions.html) with the following additional requirements:
12+
13+
- Use 4 spaces for indentation
14+
- Maximum line length is 120 characters
15+
- Use trailing commas in multi-line lists/arrays/parameters
16+
- Prefer named parameters for improved readability for functions with multiple parameters, especially when parameters share the same type
17+
- Always prefer explicit null handling; avoid `!!` (not null asserts) unless absolutely unavoidable
18+
- Use `require`, `requireNotNull`, `check`, `checkNotNull`, and `error` functions to enforce invariants early, and document these checks in KDoc comments
19+
20+
### Documentation
21+
22+
#### KDoc Comments
23+
24+
- All public APIs must have KDoc comments
25+
- Use proper markdown formatting in KDoc
26+
- Include code examples where appropriate using markdown code blocks
27+
- Document all parameters, return values, and exceptions
28+
29+
#### KDoc Tags
30+
31+
- `@param` - Document all parameters with their purpose and constraints
32+
- `@property` - Document properties in classes, especially in data classes
33+
- `@return` - Document return values (not needed for functions returning `Unit`)
34+
- `@throws` - Document exceptions that the function explicitly throws
35+
- `@constructor` - Document class constructors when they have specific behavior
36+
- `@receiver` - Document extension function receivers to explain context
37+
- `@sample` - Use to reference sample code when available
38+
- `@deprecated` - Not supported by KDoc, use the `@Deprecated` annotation instead
39+
40+
#### Markdown Style
41+
42+
- Markdown headers should have a blank line above and below them
43+
- For Markdown headers use proper Title Casing (APA style)
44+
- For strong emphasis (bold) use `__text__`
45+
- For weak emphasis (italic) use `*text*`
46+
- Lists, code blocks, and quotes should have a blank line above and below them (except when they are part of a list)
47+
- Images should have a proper alt text and where possible a light and dark version as supported by GitHub
48+
- The Markdown dialect for md files is the GitHub flavor and for KDoc its the base Markdown dialect as supported by KDoc
49+
- Code blocks should always have a language specified where possible
50+
- For code references in Markdown either use a code block, inline code formatting (backticks), or for KDoc a KDoc style reference (example: `uses [SomeClass] to do things`)
51+
52+
#### Deprecation
53+
54+
For deprecated elements:
55+
56+
- Add `@Deprecated` annotation with appropriate deprecation level and message
57+
- Include `replaceWith` parameter when possible to guide users to the new API
58+
- Document the reason for deprecation and migration path in KDoc
59+
60+
Example:
61+
62+
```kotlin
63+
/**
64+
* This method performs an operation that is now deprecated.
65+
*/
66+
@Deprecated(
67+
message = "Use newMethod() instead which provides better performance",
68+
replaceWith = ReplaceWith("newMethod()"),
69+
level = DeprecationLevel.WARNING
70+
)
71+
fun oldMethod() {
72+
// Implementation
73+
newMethod() // Delegate to new method when possible
74+
}
75+
```
76+
77+
### Changelog
78+
79+
- Follow the [Keep a Changelog](https://keepachangelog.com/) format
80+
- Group changes under: Added, Changed, Deprecated, Removed, Fixed, Security, or Dependencies
81+
- Version numbers are a single number incremented by 1 for each release
82+
- Older releases are not maintained for this internal project
83+
- For new releases the current date should be included in the header
84+
- Change entries should be prefix with the correct module like `- __test:__ Added some function`
85+
- For breaking changes a `(Breaking)` should be suffixed to the change module prefix like `- __test (Breaking): Changed parameters of some function`
86+
87+
### Module Documentation
88+
89+
- Each module should have a comprehensive README.md
90+
- README files should be properly formatted for Dokka to generate documentation HTML for GitHub Pages
91+
- Include module purpose, main components, usage examples, and integration instructions for larger systems/functionality only
92+
93+
## Code Quality
94+
95+
### Static Analysis
96+
97+
All code must pass:
98+
99+
- Android lint checks
100+
- Detekt analysis (configuration in detekt-config.yml)
101+
- SonarQube analysis
102+
103+
### Testing Requirements
104+
105+
- All new code should have appropriate unit tests
106+
- Follow Behavior-Driven Testing principles with Given-When-Then structure
107+
- Test coverage should be maintained or improved with new code
108+
- Testing shared code should be prioritized over platform-specific tests where possible
109+
- Where relevant use a @ParameterizedTest
110+
- Bug fixes should have tests for them where possible
111+
112+
### Testing Stack
113+
114+
- JUnit 5 for test framework
115+
- MockK for mocking
116+
- EasyRandom for test data generation
117+
- Turbine for testing Flow
118+
- Custom utilities from test and test-android modules
119+
120+
## Design Principles
121+
122+
- **Flexibility**: Code should be adaptable to different use cases
123+
- **Extensibility**: Design for extension through inheritance or composition
124+
- **Reusability**: Components should be reusable across different projects
125+
- **Maintainability**: Code should be easy to understand and maintain
126+
- **Performance**: Consider performance implications, especially for utility functions
127+
128+
## API Design and Maintenance
129+
130+
### Public API Guidelines
131+
132+
- For any public-facing API (including internal expect/actual in KMP), changes should:
133+
- Avoid breaking changes unless justified and properly documented
134+
- Consider using deprecation cycles (WARNING → ERROR → removal over releases)
135+
- For expect/actual declarations make sure to document platform specific implementations clearly. Also avoid leaking platform-specific concepts into common code
136+
- When APIs are only available on some targets explicitly mention it in KDoc
137+
138+
### Coroutines
139+
140+
- Use structured concurrency. Avoid GlobalScope (as per coroutine best practices)
141+
- Document coroutine context switches or expectations clearly in the KDocs
142+
- Prefer suspend functions and flows over callbacks
143+
144+
## Versioning and Maintenance
145+
146+
- Version numbers are incremented by 1 for each release
147+
- Only the latest version is maintained
148+
- Breaking changes should be clearly documented in the changelog
149+
150+
## Dependencies Management
151+
152+
### Dependency Guidelines
153+
154+
- New dependencies should only be added when needed and only exposed using API in very rare exceptions
155+
- Use Kotlin stdlib and kotlinx libraries over alternatives where feasible
156+
- Dependencies that impact public API require extra scrutiny
157+
158+
### Gradle Version Catalogue
159+
160+
- New dependencies should be added using the Gradle version catalogue system
161+
- Use the standard `gradle/libs.versions.toml` file for version declarations
162+
- Follow the established pattern for declaring library versions and dependencies

gradle/libs.versions.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
[versions]
22
accompanist = "0.32.0"
33
activityCompose = "1.9.2"
4-
android-gradle = "8.5.2"
4+
android-gradle = "8.11.1"
55
coil = "2.7.0"
66
composeBom = "2024.09.01"
77
composeCompiler = "1.5.8"
88
coreKtx = "1.13.1"
99
detekt = "1.23.5"
1010
flexmark = "0.64.8"
11-
immutableCollections = "0.3.7"
11+
immutableCollections = "0.4.0"
1212
jvm = "17"
1313
kodeview = "0.9.0"
14-
kotlin = "2.0.10"
14+
kotlin = "2.2.0"
15+
coreKtxVersion = "1.16.0"
1516

1617
[libraries]
1718
accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" }
@@ -33,6 +34,7 @@ flexmark-superscript = { module = "com.vladsch.flexmark:flexmark-ext-superscript
3334
flexmark-tables = { module = "com.vladsch.flexmark:flexmark-ext-tables", version.ref = "flexmark" }
3435
immutable-collections = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "immutableCollections" }
3536
kodeview = { module = "dev.snipme:kodeview", version.ref = "kodeview" }
37+
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtxVersion" }
3638

3739
[plugins]
3840
android-application = { id = "com.android.application", version.ref = "android-gradle" }
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1+
#
2+
# Copyright © 2025 Framna
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5+
# documentation files (the ?Software?), to deal in the Software without restriction, including without limitation
6+
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
7+
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8+
#
9+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
10+
# the Software.
11+
#
12+
# THE SOFTWARE IS PROVIDED ?AS IS?, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
13+
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
15+
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
16+
# IN THE SOFTWARE.
17+
#
18+
119
#Sat Oct 01 16:01:34 CEST 2022
220
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip
21+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
422
distributionPath=wrapper/dists
523
zipStorePath=wrapper/dists
624
zipStoreBase=GRADLE_USER_HOME

markymark/build.gradle.kts

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Copyright © 2025 Framna
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5+
* documentation files (the “Software”), to deal in the Software without restriction, including without limitation
6+
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
7+
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
10+
* the Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
13+
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
15+
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
16+
* IN THE SOFTWARE.
17+
*/
18+
119
@file:Suppress("UnstableApiUsage")
220

321
plugins {
@@ -48,6 +66,7 @@ android {
4866
"-P",
4967
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=${rootDir.absolutePath}/compose_metrics"
5068
)
69+
jvmTarget = "17"
5170
}
5271

5372
lint {
@@ -59,37 +78,11 @@ android {
5978
}
6079
}
6180

62-
afterEvaluate {
63-
publishing {
64-
publications {
65-
create<MavenPublication>("mavenRelease") {
66-
groupId = BuildConstants.Namespace
67-
version = BuildConstants.VersionName
68-
from(components.getByName("release"))
69-
pom {
70-
name.set("MarkyMark-Android")
71-
description.set("Library for converting Markdown to Android Jetpack Compose elements")
72-
url.set("https://git.m2mobi.com/projects/ML/repos/m2utility/browse")
73-
licenses {
74-
license {
75-
name.set("The MIT License (MIT)")
76-
url.set("https://raw.githubusercontent.com/Move-Agency/MarkyMark-Android/v3/develop/LICENSE")
77-
}
78-
}
79-
organization {
80-
name.set("Move Agency")
81-
url.set("https://www.moveagency.com/")
82-
}
83-
}
84-
}
85-
}
86-
}
87-
}
88-
8981
dependencies {
9082
implementation(platform(libs.compose.bom))
9183
implementation(libs.compose.ui)
9284
implementation(libs.compose.ui.tooling.preview)
85+
implementation(libs.androidx.core.ktx)
9386
debugImplementation(libs.compose.ui.tooling)
9487
implementation(libs.compose.material3)
9588

markymark/src/main/java/com/moveagency/markymark/MarkyMark.kt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2024 Move
2+
* Copyright © 2025 Framna
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
55
* documentation files (the “Software”), to deal in the Software without restriction, including without limitation
@@ -24,16 +24,35 @@ import com.moveagency.markymark.theme.LocalMarkyMarkTheme
2424
import com.moveagency.markymark.theme.MarkyMarkTheme
2525

2626
/**
27-
* Helper object for accessing [LocalMarkyMarkOptions] & [LocalMarkyMarkTheme].
27+
* Central access point for MarkyMark configuration and theming.
28+
*
29+
* This object provides access to the current [MarkyMarkOptions] and [MarkyMarkTheme]
30+
* through composition locals, making them available throughout the composition hierarchy.
31+
* It serves as a convenient way to access markdown rendering configuration and styling
32+
* from any composable function.
2833
*/
2934
object MarkyMark {
3035

36+
/**
37+
* The current markdown rendering options.
38+
*
39+
* This property provides access to the current [MarkyMarkOptions] from the [LocalMarkyMarkOptions]
40+
* composition local. It includes configuration for the FlexMark parser, custom composers,
41+
* and annotators used for rendering markdown content.
42+
*/
3143
@Suppress("ObjectPropertyNaming")
3244
val options: MarkyMarkOptions
3345
@Composable
3446
@ReadOnlyComposable
3547
get() = LocalMarkyMarkOptions.current
3648

49+
/**
50+
* The current markdown styling theme.
51+
*
52+
* This property provides access to the current [MarkyMarkTheme] from the [LocalMarkyMarkTheme]
53+
* composition local. It includes styling for all markdown elements, including root-level
54+
* styling, element-specific styles, and color schemes.
55+
*/
3756
@Suppress("ObjectPropertyNaming")
3857
val theme: MarkyMarkTheme
3958
@Composable

0 commit comments

Comments
 (0)