Skip to content

Commit c7bbfb1

Browse files
Metadata line length check ignores API docs (#930)
Follow up to #890. API docs are auto-generated so we can't easily fix if the line length is not ideal, which often happens from being too short.
1 parent eb1912f commit c7bbfb1

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

scripts/commands/checkMetadata.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,16 @@ const readMetadata = async (filePath: string): Promise<Record<string, any>> => {
5353
}
5454
};
5555

56-
const isValidMetadata = (metadata: Record<string, any>): boolean =>
56+
const isValidMetadata = (
57+
metadata: Record<string, any>,
58+
filePath: string,
59+
): boolean =>
5760
metadata.title &&
5861
metadata.description &&
59-
metadata.title != metadata.description &&
60-
metadata.description.length <= 160 &&
61-
metadata.description.length >= 50;
62+
(isApi(filePath) ||
63+
(metadata.title != metadata.description &&
64+
metadata.description.length <= 160 &&
65+
metadata.description.length >= 50));
6266

6367
const main = async (): Promise<void> => {
6468
const args = readArgs();
@@ -67,15 +71,15 @@ const main = async (): Promise<void> => {
6771
const mdErrors = [];
6872
for (const file of mdFiles) {
6973
const metadata = await readMetadata(file);
70-
if (!isValidMetadata(metadata)) {
74+
if (!isValidMetadata(metadata, file)) {
7175
mdErrors.push(file);
7276
}
7377
}
7478

7579
const notebookErrors = [];
7680
for (const file of notebookFiles) {
7781
const metadata = await readMetadata(file);
78-
if (!isValidMetadata(metadata)) {
82+
if (!isValidMetadata(metadata, file)) {
7983
notebookErrors.push(file);
8084
}
8185
}
@@ -99,6 +103,14 @@ async function determineFiles(args: Arguments): Promise<[string[], string[]]> {
99103
return [await globby(mdGlobs), await globby(notebookGlobs)];
100104
}
101105

106+
function isApi(filePath: string): boolean {
107+
return (
108+
filePath.includes("/api/qiskit/") ||
109+
filePath.includes("/api/qiskit-ibm-runtime/") ||
110+
filePath.includes("/api/qiskit-ibm-provider/")
111+
);
112+
}
113+
102114
function handleErrors(mdErrors: string[], notebookErrors: string[]): void {
103115
if (mdErrors.length > 0) {
104116
console.error(`

0 commit comments

Comments
 (0)