High-quality code documentation improves maintainability and helps other developers understand your intentions. Follow these practices:

  1. Use appropriate JSDoc annotations to indicate API visibility and status:
    /** @internal */
    hostname: Hostname
       
    /**
     * @deprecated Use `createIdResolver` from `vite` instead.
     */
    
  2. Structure API documentation logically by describing functionality first, then providing implementation details or deprecation notices: ```typescript /**
  3. Add explanatory comments for non-obvious code decisions to explain the “why” behind implementation choices:
    // only limit to these extensions because:
    // - for the `@import`/`@use`s written in file loaded by `load` function,
    //   the `canonicalize` function of that `importer` is called first
    // - the `load` function of an importer is only called for the importer
    //   that returned a non-null result from its `canonicalize` function
    (resolved.endsWith('.css') || resolved.endsWith('.scss') || resolved.endsWith('.sass'))
    
  4. Keep documentation updated when implementing changes, especially for deprecated features. Explicitly indicate migration paths and alternatives when deprecating functionality.