Skip to content

Merge metadata check into new markdown check #3750

@Eric-Arellano

Description

@Eric-Arellano

This builds on top of #3669, which combines our image check and new title check into a single script. We do that for performance reasons because reading and parsing the same files multiple times is expensive.

In this issue, we should remove checkMetadata.ts and instead have checkMarkdown.ts do everything.

Step 1: new lib file

Move the logic from checkMarkdown.ts into lib/markdownChecker.ts. Have a checkMarkdown function that takes as an argument the metadata: Record<string, string> and returns a Set<string> with the errors for that file.

You're going to use the logic from isValidMetadata, but should improve it to return a Set of error messages rather than a single boolean:

  • If title is missing, return "Missing title in the metadata"
  • If description is missing, return "Missing description in the metadata"
  • If the description is too short or too long, return "The description in the metadata must be between 50 and 160 characters, but was ${the actual length}"

Add unit tests for checkMarkdown().

Step 2: hook up to checkMarkdown.ts

Have your new file checkMarkdown.ts call your new function and ensure we error on issues. Update the error message to say "Metadata issues: https://github.com/Qiskit/documentation/blob/main/mdx-guide.md#page-metadata"

Step 3: set up the allowlist

In our original file checkMetadata.ts, you'll notice that we have a lot of files we skip. We need to keep skipping those.

However, our config for what to skip is now getting pretty long. We should centralize all of our allowlists into a central file in config/ called allowLists.ts. Move the existing allowlists from checkMarkdown.ts into that file, and also move the allowlist from checkMetadata.ts there. You may need to rename variables to make sure things are not ambiguous between our different checks.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions