Document the API for Both Teams
Write KDoc so Android and iOS devs agree on usage.
Document the API for Both Teams is a free Kotlin Multiplatform Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Kotlin Multiplatform Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Docs Are Part of the API
Both Android and iOS devs call your shared code, so clear documentation is as important as the functions themselves. 📝
Meet KDoc
KDoc is Kotlin's documentation comment. You write it right above a declaration, and tools turn it into readable reference pages.
/** Returns a friendly greeting for [name]. */
fun greet(name: String) = "Hi, " + nameExplain the Why
Code shows what happens; good docs explain the why and the intended use. State what a caller should expect, not how it works inside.
Document Parameters
Use the @param tag to describe each input. Callers from both apps then know exactly what to pass without reading the source.
/**
* @param rate tax rate as a fraction, like 0.2
*/Document Return Values
The @return tag describes what comes back. A clear return note prevents wrong assumptions about units, ranges, or null.
/** @return total price including tax, never negative */Link With Brackets
Wrap names in square brackets to create links, like [Quote]. Readers jump straight to related types in the generated docs.
/** Builds a [Quote] from a base price. */Show a Usage Sample
A tiny example beats paragraphs of prose. One snippet showing a real call answers most questions before they are asked.
Document Only the Public API
Spend your effort on the public surface. Internal helpers can stay lightly commented since no outside team will call them.
Mind the iOS Reader
Swift developers read your KDoc too, so describe behavior in plain terms. Avoid JVM jargon that means nothing on the iOS side.
Generate Docs With Dokka
Dokka reads your KDoc and produces a browsable site. Both teams get one shared reference instead of guessing from the code.
Keep Docs in Sync
Outdated docs mislead more than no docs. Update the KDoc in the same change as the code so the two never drift apart.
Quick Check
Let's check your documentation know-how.
Recap
Write KDoc on your public API, explain the why, tag params and returns, add a sample, and let Dokka share it with both teams. 🎉
Frequently asked questions
Is the “Document the API for Both Teams” lesson free?
Yes — the full text of “Document the API for Both Teams” is free to read here on the web, and the Kotlin Multiplatform Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Kotlin Multiplatform Academy course, upgrade to CoddyKit PRO.
What will I learn in “Document the API for Both Teams”?
Write KDoc so Android and iOS devs agree on usage. You practise Kotlin Multiplatform Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Kotlin Multiplatform Academy?
No prior experience is required. Kotlin Multiplatform Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Document the API for Both Teams” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Kotlin Multiplatform Academy lesson?
Yes. Every Kotlin Multiplatform Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Design a Small Public API
- internal vs public Visibility
- Organize Packages Inside the Module
- Document the API for Both Teams