Prompt
High-quality code documentation improves maintainability and helps other developers understand your intentions. Follow these practices:
- Use appropriate JSDoc annotations to indicate API visibility and status:
/** @internal */ hostname: Hostname /** * @deprecated Use `createIdResolver` from `vite` instead. */ - Structure API documentation logically by describing functionality first, then providing implementation details or deprecation notices:
```typescript
/**
- Create an internal resolver to be used in special scenarios, e.g.
- optimizer & handling css
@imports. * - This API is deprecated. It only works for the client and ssr
- environments. The
aliasOnlyoption is also not being used anymore. - Plugins should move to
createIdResolver(environment.config)instead. */ ```
- 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')) - Keep documentation updated when implementing changes, especially for deprecated features. Explicitly indicate migration paths and alternatives when deprecating functionality.