* Asserts that a class document has: * - A `@typeParam` tag for each type parameter. * - At least one code https://jsdoc.app/tags-example | @example tag with * a code snippet that executes successfully. * - Documentation on all properties, methods, and constructors.
(document: DocNodeWithJsDoc<DocNodeClass>)
| 267 | * - Documentation on all properties, methods, and constructors. |
| 268 | */ |
| 269 | function assertClassDocs(document: DocNodeWithJsDoc<DocNodeClass>) { |
| 270 | for (const typeParam of document.classDef.typeParams) { |
| 271 | assertHasTypeParamTags(document, typeParam.name); |
| 272 | } |
| 273 | if (!document.jsDoc.tags?.some((tag) => tag.kind === "example")) { |
| 274 | assertHasExampleTag(document); |
| 275 | } |
| 276 | |
| 277 | for (const property of document.classDef.properties) { |
| 278 | if (property.jsDoc === undefined) continue; // this is caught by `deno doc --lint` |
| 279 | assert( |
| 280 | property.accessibility === undefined, |
| 281 | "Do not use `public`, `protected`, or `private` fields in classes", |
| 282 | property, |
| 283 | ); |
| 284 | assertClassPropertyDocs( |
| 285 | property as DocNodeWithJsDoc<ClassPropertyDef>, |
| 286 | ); |
| 287 | } |
| 288 | for (const method of document.classDef.methods) { |
| 289 | if (method.jsDoc === undefined) continue; // this is caught by `deno doc --lint` |
| 290 | assert( |
| 291 | method.accessibility === undefined, |
| 292 | "Do not use `public`, `protected`, or `private` methods in classes", |
| 293 | document, |
| 294 | ); |
| 295 | assertFunctionDocs(method as DocNodeWithJsDoc<ClassMethodDef>); |
| 296 | } |
| 297 | for (const constructor of document.classDef.constructors) { |
| 298 | if (constructor.jsDoc === undefined) continue; // this is caught by `deno doc --lint` |
| 299 | assert( |
| 300 | constructor.accessibility === undefined, |
| 301 | "Do not use `public`, `protected`, or `private` constructors in classes", |
| 302 | constructor, |
| 303 | ); |
| 304 | assertConstructorDocs( |
| 305 | constructor as DocNodeWithJsDoc<ClassConstructorDef>, |
| 306 | ); |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | /** |
| 311 | * Asserts that a class property document has: |
no test coverage detected