Back to Blog
Dokly

Dokly

Pro API documentation without the $300/mo price tag.

Check it out on Product Hunt →
Open Source
Documentation
README
Community
GitHub

Open Source Documentation: Best Practices That Drive Adoption

Learn how to write documentation that turns your open source project from overlooked to widely adopted. Practical strategies for READMEs, guides, and community contributions.

Dokly Team
7 min read

Great open source projects succeed or fail based on their documentation. You could have the most elegant, performant code in the world—but if developers can't figure out how to use it, they'll move on. Here's how to write documentation that drives adoption.

The First 30 Seconds Matter#

A developer lands on your GitHub repo. You have 30 seconds to answer:

  1. What is this?
  2. Why should I care?
  3. How do I get started?

If your README doesn't answer these instantly, you've lost them.

The Perfect README Structure#

Here's the structure that works:

Project Name - One-line description that explains what this does.

Why Use This?

  • Benefit 1 (not feature—benefit)
  • Benefit 2
  • Benefit 3

Quick Start - Show installation and basic usage immediately.

Documentation - Links to deeper guides.

Contributing - How to help.

License - MIT, Apache, etc.

What Most READMEs Get Wrong#

Too much history:

Don't start with: "MyLib was started in 2019 when I was frustrated with existing solutions. After years of development and many iterations..."

Nobody cares. Get to the point.

Feature lists instead of benefits:

Bad approach - listing technical features:

  • Written in TypeScript
  • Uses Rust bindings
  • Supports ESM and CJS

Better approach - showing what problems you solve:

  • 10x faster than alternatives (with benchmarks)
  • Zero dependencies, small bundle size
  • Works in Node.js, browsers, and edge runtimes

Missing quick start:

Don't just say "See our comprehensive installation guide at..."

Just show the commands:

Bash
npm install mylib
JavaScript
import { myLib } from 'mylib';
myLib.go(); // That's it!

Documentation Layers#

Good open source documentation has layers, each serving different needs:

Layer 1: README (30 seconds)#

  • What it is
  • Why it matters
  • Quickest possible start

Layer 2: Getting Started Guide (5 minutes)#

Walk through a complete example that helps users understand core concepts.

Prerequisites: List what they need (Node.js 18+, npm, etc.)

Step 1: Create a new project

Bash
mkdir my-app && cd my-app
npm init -y
npm install mylib

Step 2: Write your first script

JavaScript
import { createApp } from 'mylib';
 
const app = createApp({
  name: 'My First App'
});
 
app.on('ready', () => {
  console.log('App is running!');
});
 
app.start();

Step 3: Run it

Bash
node index.js
# Output: App is running!

Next Steps: Link to core concepts, API reference, and examples.

Layer 3: Concept Guides (15 minutes each)#

Explain the "why" behind design decisions.

For example, a guide on middleware might explain:

  • What middleware is and why it matters
  • How the middleware pipeline works
  • How to write custom middleware
  • Why order matters
JavaScript
const loggingMiddleware = (ctx, next) => {
  console.log(`${ctx.method} ${ctx.path}`);
  const start = Date.now();
 
  await next(); // Continue to next middleware/handler
 
  const ms = Date.now() - start;
  console.log(`Completed in ${ms}ms`);
};

Layer 4: API Reference (as needed)#

Comprehensive, searchable reference documentation for each function and class.

For each API:

  • Parameters: Name, type, required/optional, description
  • Returns: What it returns
  • Example: Working code sample
  • Related: Links to similar functions
JavaScript
const app = createApp({
  name: 'My App',
  debug: true
});

Layer 5: Examples Repository#

Real-world examples developers can clone and run:

Text
examples/
├── basic/
├── with-typescript/
├── with-react/
└── full-application/

Each example should have its own README explaining what it demonstrates and how to run it.

Writing for Different Audiences#

Beginners#

  • Assume nothing
  • Explain every step
  • Provide complete, runnable examples
  • Link to prerequisite knowledge

Example: Include a section on installing Node.js before diving into your library.

Bash
node --version
# Should print v18.x.x or higher

Intermediate Users#

  • Focus on patterns and best practices
  • Show multiple approaches with trade-offs
  • Explain "why" not just "how"

Example: Compare different database adapters and when to use each.

JavaScript
import { createApp } from 'mylib';
import { PostgresAdapter } from 'mylib/postgres';
 
const app = createApp({
  database: new PostgresAdapter({
    connectionString: process.env.DATABASE_URL
  })
});

Advanced Users#

  • Deep dives into internals
  • Performance optimization
  • Extension and customization

Example: Show how to implement custom transports or adapters.

TypeScript
interface Transport {
  connect(): Promise<void>;
  send(message: Message): Promise<void>;
  receive(): AsyncGenerator<Message>;
  close(): Promise<void>;
}

Making Documentation Discoverable#

In-Code Documentation#

Use JSDoc comments with examples:

TypeScript
/**
 * Creates a new user in the database.
 *
 * @param data - User creation data
 * @param data.email - User's email address (must be unique)
 * @param data.name - User's display name
 * @returns The created user with generated ID
 *
 * @example
 * const user = await createUser({
 *   email: 'jane@example.com',
 *   name: 'Jane Doe'
 * });
 *
 * @throws {ValidationError} If email is invalid
 * @throws {DuplicateError} If email already exists
 */
export async function createUser(data: CreateUserInput): Promise<User> {
  // implementation
}

Error Messages That Help#

Bad error message:

JavaScript
throw new Error('Invalid configuration');

Good error message with context and documentation link:

JavaScript
throw new Error(
  `Invalid configuration: "port" must be a number between 1 and 65535.\n` +
  `Received: ${typeof config.port} (${config.port})\n` +
  `See: https://mylib.dev/docs/configuration#port`
);

CLI Help Text#

Make your CLI self-documenting with clear help text and examples:

Bash
$ mylib init my-app      # Create new project
$ mylib dev              # Start dev server
$ mylib build --minify   # Production build

Encouraging Community Contributions#

CONTRIBUTING.md#

Make it easy for people to contribute:

Quick Start - Show how to clone, install, and test

Bash
git clone https://github.com/you/mylib
cd mylib
npm install
npm test

Documentation Contributions - Emphasize that documentation PRs are always welcome, no coding required.

Code Contributions:

  • Link to architecture guide
  • Explain PR process
  • Show code style requirements
Bash
npm run lint
npm run format

Good First Issues#

Label issues that are perfect for newcomers with clear instructions on:

  • Current behavior
  • Expected behavior
  • Files to modify
  • How to test

Documentation Maintenance#

Keep Docs in Sync with Code#

Set up automated checks to remind contributors to update docs when they change code.

Version Your Docs#

Maintain docs for multiple versions:

Text
docs/
├── v1/
├── v2/
└── latest -> v2/

Deprecation Notices#

Clearly mark deprecated features:

Deprecated: oldFunction() is deprecated and will be removed in v3.0. Use newFunction() instead.

Migration guide: Upgrading to v2.5

Measuring Documentation Success#

Track these metrics:

  • Time to first success: How long until a new user gets something working?
  • Documentation bounce rate: Do people leave immediately?
  • Search queries with no results: What are people looking for?
  • GitHub issues about docs: What's confusing?
  • Community contributions: Are people improving docs?

Conclusion#

Great open source documentation:

  1. Respects the reader's time - Quick start in 30 seconds
  2. Serves multiple skill levels - From beginner to expert
  3. Stays current - Updated with every release
  4. Invites contribution - Easy for anyone to improve
  5. Is discoverable - Found when and where it's needed

Your documentation is often the first impression of your project. Make it count.


Building an open source project? Dokly provides beautiful, searchable documentation with built-in versioning, GitHub integration, and instant deploys. Give your project the documentation it deserves.

Dokly

Dokly

Pro API documentation without the $300/mo price tag.

Check it out on Product Hunt →

Ready to build better docs?

Start creating beautiful documentation with Dokly today.

Get Started Free