Code blocks don’t work in isolation. Readers either need context to understand what they’re looking at, or they need to be trusted to read the code themselves. The right balance of explanation depends on what type of page you’re writing and who’s reading it.Documentation Index
Fetch the complete documentation index at: https://learn.mintlify.com/llms.txt
Use this file to discover all available pages before exploring further.
How does the content type affect explanation?
Reference pages are looked up, not read top-to-bottom. Someone reading an API reference page already knows what they want. They are after the parameters, the types, and a quick example. Long prose explanations slow them down.Reference page example
Inline comments versus prose
When only part of a code block needs explanation, inline comments are often more clear than a paragraph of prose after the code block. However, consider if people will be copying and pasting the code block, in which case a comment might be more confusing than helpful.- Non-obvious choices (“why 30 seconds for a timeout?”)
- Things that are commonly misconfigured (“should I use
api_keyorAPI_KEY?”) - Variables the reader will need to replace (“replace
YOUR_API_KEYwith your actual API key”)
# Step 1: Initialize the client. If the comment restates what the code says, you probably don’t need it.
Explain before, not after
For how-to guides and tutorials, one sentence before the code block identifies what’s about to happen and gives readers context for what they’re reading.Explain-then-show pattern
What counts as obvious depends on the reader
Content for beginners needs more explanation than content for experienced users. A step that’s obvious to someone who’s written API integrations before might not be obvious to someone setting up their first integration. Before deciding how much to explain, consider your audience for the specific page where the code block appears. If you’ve defined your readers as developers with API experience, trust that experience. If you’re writing for people who are new to using your product and APIs, explain the parts that experienced users take for granted.Next up: Tabs — When your content varies by environment, audience, or stack, tabs let readers see only what applies to them.