Skip to content

chore: add Markdown format check - #2736

Closed
WenyXu wants to merge 2 commits into
mainfrom
chore/markdown-formatting-tools
Closed

chore: add Markdown format check#2736
WenyXu wants to merge 2 commits into
mainfrom
chore/markdown-formatting-tools

Conversation

@WenyXu

@WenyXu WenyXu commented Aug 12, 2026

Copy link
Copy Markdown
Member

What changed

Adds pinned local Prettier tooling and package scripts so contributors can format changed Markdown and MDX files reproducibly:

  • pnpm format:md
  • pnpm format:md:check

By default, the scripts target Markdown and MDX files changed from origin/main; callers can append explicit paths for narrower checks. The Node.js CI build job runs pnpm format:md:check with full Git history available for that comparison.

Scope

  • Documentation versions: N/A
  • Languages: N/A

Verification

  • node scripts/format-markdown.mjs --check
  • node scripts/format-markdown.mjs --check -- docs/user-guide/deployments-administration/monitoring/events i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/monitoring/events
  • npm exec --yes --package=pnpm@9.15.4 -- pnpm format:md:check
  • npm exec --yes --package=pnpm@9.15.4 -- pnpm format:md:check -- docs/user-guide/deployments-administration/monitoring/events i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/monitoring/events
  • prettier --check .github/workflows/node-build.yml scripts/format-markdown.mjs package.json
  • git diff --check

Checklist

  • I verified the content against the applicable GreptimeDB version. (N/A: tooling-only change.)
  • I updated the relevant documentation versions and languages, or explained why not. (N/A: no documentation content changed.)
  • I checked changed links and anchors. (N/A: no links or anchors changed.)
  • I updated navigation when the document structure changed. (N/A: navigation unchanged.)

Signed-off-by: WenyXu <wenymedia@gmail.com>
@WenyXu
WenyXu marked this pull request as ready for review August 12, 2026 07:45
Copilot AI lite review requested due to automatic review settings August 12, 2026 07:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds pinned, local Markdown tooling (markdownlint + Prettier) and new pnpm scripts so contributors can lint and format Markdown consistently within the docs repository.

Changes:

  • Add markdownlint-cli@0.42.0 and prettier@3.5.3 as pinned devDependencies.
  • Introduce pnpm scripts for Markdown linting and formatting (lint:md, format:md, format:md:check).
  • Add .markdownlintignore to exclude generated/output directories from Markdown linting.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
pnpm-lock.yaml Locks the newly introduced Markdown tooling dependencies and their transitive dependency graph.
package.json Adds pinned devDependencies and exposes new pnpm scripts for linting/formatting Markdown.
.markdownlintignore Excludes node_modules/ and generated build outputs from markdownlint runs.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread package.json Outdated
Comment thread package.json Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39827a8ca6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json Outdated
Comment thread package.json Outdated
Comment thread pnpm-lock.yaml Outdated
Comment thread package.json Outdated
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 12, 2026

Copy link
Copy Markdown

Deploying greptime-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: c0e875b
Status:⚡️  Build in progress...

View logs

Signed-off-by: WenyXu <wenymedia@gmail.com>
@WenyXu WenyXu changed the title chore: add local Markdown lint and format commands chore: add Markdown format check Aug 12, 2026
@WenyXu

WenyXu commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

@codex review

@WenyXu WenyXu closed this Aug 12, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0e875bd27

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

const paths = providedPaths.filter(path => path !== '--')
const base = execFileSync('git', ['merge-base', 'HEAD', 'origin/main'], { encoding: 'utf8' }).trim()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Diff against the pull request's actual base

For pull requests targeting dev, the build job in .github/workflows/node-build.yml still invokes this script, but the hard-coded origin/main merge base makes changedPaths include unrelated changes accumulated on dev since it diverged from main. If any of those pre-existing Markdown files are not Prettier-compliant, every otherwise unrelated PR into dev fails this check; derive the baseline from the pull request's base branch or SHA instead.

Useful? React with 👍 / 👎.

}

const paths = providedPaths.filter(path => path !== '--')
const base = execFileSync('git', ['merge-base', 'HEAD', 'origin/main'], { encoding: 'utf8' }).trim()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip Git baseline lookup for explicit inputs

When a contributor supplies explicit paths from a source archive, a clone whose primary remote is not named origin, or any checkout without origin/main, the command fails here before it reaches paths.length > 0. Explicit inputs do not need a merge base, so resolve the Git baseline only in the no-input branch; otherwise even node scripts/format-markdown.mjs --check AGENTS.md cannot perform the requested check.

Useful? React with 👍 / 👎.


const paths = providedPaths.filter(path => path !== '--')
const base = execFileSync('git', ['merge-base', 'HEAD', 'origin/main'], { encoding: 'utf8' }).trim()
const changedPaths = execFileSync('git', ['diff', '--name-only', '--diff-filter=ACMR', base], {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include untracked Markdown in the default input set

When a contributor creates a new documentation page and runs the bare formatting command before staging it, git diff --name-only <base> omits that untracked file, so the script either reports that there is nothing to format or silently checks only older files. The page is detected only after it is added or committed, commonly turning the subsequent CI run into the first formatting failure; combine this result with untracked, non-ignored Markdown paths.

Useful? React with 👍 / 👎.

}

const prettier = fileURLToPath(new URL('../node_modules/prettier/bin/prettier.cjs', import.meta.url))
const result = spawnSync(process.execPath, [prettier, mode, ...inputs], { stdio: 'inherit' })

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict explicit directories to Markdown inputs

When a contributor follows the usage text and runs pnpm format:md -- i18n/zh or passes the repository root, the directory is forwarded unchanged. Prettier's CLI help defines operands as file/dir/glob and lists JSON, YAML, TypeScript, and other parsers, so --write recursively rewrites those supported files alongside Markdown—including the localized navigation JSON under i18n/zh; expand or filter directory inputs to .md and .mdx before invoking Prettier.

AGENTS.md reference: AGENTS.md:L44-L45

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants