Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Check files

A check file is a JavaScript module in the journal repository that journal.yml lists under checks: by its path (how to write one). Its default export has a validate(paper, options) function. options has the fields of the check’s entry in journal.yml, except optional, id included.

Results

validate returns a result, a list of results, or a promise of either. An empty list adds no row. A result is a Curvenote CheckResult, and oak reads these of its fields:

field
statuspass, fail or error. Required.
messageThe text of the row. Required.
helpHow to fix it, added to the annotation.
fileThe page, as paper.pages[].file.
positionWhere in the page, as a node’s position. With file, the message shows on that line of the pull request’s diff.
optionaltrue makes this result a warning.

paper

Its types in oak’s source are PaperData and Paper.

field
rootThe paper’s folder, an absolute path.
projectThe project frontmatter, such as title, authors and keywords, with the journal’s settings merged in.
configThe paper’s myst.yml as the author wrote it, without the journal’s settings.
repoThe paper’s repository, as owner/name, or null when oak cannot tell. On your machine it comes from --repo, else the clone’s origin. In the pull request checks it is the paper’s repository, also for a pull request from a fork.
journalThe journal repository the check file comes from: config, its journal.yml with oak’s defaults filled in, and registry, the entries of registry/papers.yml that oak accepts, or an empty list when it has none.
projectPartsThe content of each part the project frontmatter sets, as a tree, by part name.
pagesOne entry per page, in table-of-contents order and starting with the root page, which Curvenote’s checks read as the article. See pages.
toText(node)The text of a node and everything under it.
selectAll(selector, node)The nodes under node that match a selector such as 'heading', from unist-util-select.
positionOf(node)A position for a result about node: the node’s own. A node a directive makes, such as a figure or an {image}, has none, so it gets the first line of the nearest node before it on its page that has one. undefined for a node in no page’s mdast.

Pages

Each entry of paper.pages has these fields. Its type in oak’s source is PaperPage.

field
fileThe page’s file, an absolute path.
frontmatterIts frontmatter as MyST reads it (frontmatter).
fileFrontmatterThe frontmatter block at the top of its file, as written. It is {} when the page has none, and null when the block is not a YAML mapping or the page is not a .md file. List MyST’s frontmatter-is-yaml rule to block a page whose block is not valid YAML.
mdastIts content, as a tree.
partsThe content of each part its frontmatter sets, as a tree, by part name.

The tree follows MyST’s document structure, from the MyST version in the paper’s oak.

Frontmatter

A paper’s metadata comes from myst.yml and from the block at the top of each page, and paper shows each in two forms:

Some frontmatter keys are content, not settings: abstract:, data_availability:, acknowledgments: and the other parts. MyST moves each into a part of its own, and leaves only a pointer to it in project.parts or the page’s frontmatter.parts. The part’s content is in projectParts when myst.yml sets it, and in the page’s parts when the page does. A part’s position counts lines from the start of the part’s own text, not of the file. A +++ {"part": "abstract"} block in a page’s body stays in mdast, as a block node with data.part set to abstract.

Where a check runs

A check runs inside oak validate, with the paper’s folder as its working directory. It can read the paper’s files under paper.root and use fetch. It also sees the environment oak validate runs in, which differs between your machine and the pull request checks, so read the repository from paper.repo.

A check file can import Node’s built-in modules, such as node:path, and other files in the journal repository. CI clones the journal repository without installing anything, so an import of a package fails there, even when it works on your machine.

oak waits up to two minutes for each check file. A check file still running then, such as one whose fetch waits on a server that does not answer, shows as an error row, and oak moves on to the next check.