Download api/spec/packages/legacy/lib/rules/docs.js from Leon4gr45/openmeter: direct link, hf CLI and curl.
- Browser
- Download file 1.49 kB
-
https://huggingface.co/spaces/Leon4gr45/openmeter/resolve/main/api/spec/packages/legacy/lib/rules/docs.js
- Command line
-
hf download hf://spaces/Leon4gr45/openmeter/api/spec/packages/legacy/lib/rules/docs.js
-
curl -L -o docs.js https://huggingface.co/spaces/Leon4gr45/openmeter/resolve/main/api/spec/packages/legacy/lib/rules/docs.js
1.49 kB
| import { createRule, paramMessage, getDoc } from '@typespec/compiler' | |
| export const docDecoratorRule = createRule({ | |
| name: 'doc-decorator', | |
| severity: 'warning', | |
| description: 'Ensure documentation.', | |
| messages: { | |
| default: paramMessage`Missing documentation for ${'name'} ${'type'}`, | |
| }, | |
| create: (context) => ({ | |
| model: (target) => { | |
| if (target.name && !getDoc(context.program, target)) { | |
| context.reportDiagnostic({ | |
| target, | |
| format: { | |
| name: target.name, | |
| }, | |
| }) | |
| } | |
| if (target.name.endsWith('Response')) { | |
| return | |
| } | |
| for (const [name, property] of target.properties) { | |
| if ( | |
| target.name && | |
| name && | |
| !['_', 'contentType'].includes(name) && | |
| !getDoc(context.program, property) | |
| ) { | |
| context.reportDiagnostic({ | |
| target: property, | |
| format: { | |
| name: `${target.name}.${name}`, | |
| }, | |
| }) | |
| } | |
| } | |
| }, | |
| enum: (target) => { | |
| if (target.name && !getDoc(context.program, target)) { | |
| context.reportDiagnostic({ | |
| target, | |
| format: { | |
| name: target.name, | |
| }, | |
| }) | |
| } | |
| }, | |
| union: (target) => { | |
| if (target.name && !getDoc(context.program, target)) { | |
| context.reportDiagnostic({ | |
| target, | |
| format: { | |
| name: target.name, | |
| }, | |
| }) | |
| } | |
| }, | |
| }), | |
| }) | |