Script Valley
Open Source Contribution: A Practical Guide
Code Quality and Testing StandardsLesson 4.3

How to update documentation when contributing code changes

inline code comments, JSDoc and docstrings, README updates, changelog entries, API docs generation, docs-as-code, when not to document

Code Without Docs Is Incomplete

Documentation is part of the change. If you add a function, document it. If you change behavior, update the docs. PRs that fix behavior but leave stale documentation create future confusion.

Inline Comments

Comment the why, not the what. The comment Increment counter explains nothing. The comment Increment before lock acquisition to avoid race condition with observer is useful.

Docstrings and JSDoc

// JavaScript -- JSDoc
/**
 * Terminates the current user session and clears the auth token.
 * Safe to call when token is null or already expired.
 * @param {Object} options
 * @param {boolean} options.redirect - Redirect to login page after logout.
 * @returns {Promise<void>}
 */
async function logout(options = {}) { ... }

# Python -- docstring
def logout(redirect: bool = False) -> None:
    """
    Terminate the current session and clear the auth token.

    Args:
        redirect: If True, redirect to login page after clearing session.
    """
    ...

When to Update CHANGELOG and README

README updates are needed when you change installation steps, configuration options, or core behavior. CHANGELOG entries follow the project format -- check existing entries as a template. Many projects auto-generate changelogs from Conventional Commits, so your commit messages are the documentation.

Up next

How to read and understand an unfamiliar codebase quickly

Sign in to track progress