Skip to content

fix(beta): pass --git-ref main so edit links work - #1259

Open
vedchaudhari wants to merge 1 commit into
nodejs:mainfrom
vedchaudhari:fix-edit-url
Open

vedchaudhari wants to merge 1 commit into
nodejs:mainfrom
vedchaudhari:fix-edit-url

Conversation

@vedchaudhari

@vedchaudhari vedchaudhari commented Nov 17, 2026 •

Copy link
Copy Markdown

Description

"Edit this page" links on beta.docs.nodejs.org 404, e.g. https://github.com/nodejs/node/edit/HEAD/doc/api/index.md. GitHub can only edit files on a branch, and the beta build never sets ref, so it stays on the 'HEAD' default.

This passes --git-ref main in the beta build script, so the links become .../edit/main/doc/api/<page>.md. Source links use main too, which is where HEAD pointed anyway.

Validation

  • Loaded the beta config with --git-ref main: the edit link for buffer.md is https://github.com/nodejs/node/edit/main/doc/api/buffer.md (without it, edit/HEAD/...).
  • node --run test, format:check and lint pass.

Related Issues

None found.

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run node --run test and all tests passed.
  • I have check code formatting with node --run format:check & node --run lint.
  • I've covered new added functionality with unit tests if necessary.

@vedchaudhari
vedchaudhari requested a review from a team as a code owner November 17, 2026 07:09
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
api-docs-tooling Ready Ready Preview Nov 24, 2026 3:33am UTC

Request Review

// This is the API docs base URL for editing a file on GitHub UI.
// GitHub can only edit files on a branch, so this can't use `{ref}`
// (`HEAD` or a tag would 404).
export const GITHUB_EDIT_URL = 'https://github.com/{repository}/edit/main';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To be fair, {ref} makes sense, but it should fallback to something else if ref is not indeed a valid GitHub ref for GitHub's UI.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point, updated: keeps {ref}, falls back to main when it isn't a branch.

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.31%. Comparing base (b65d7c1) to head (cc487f1).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1259   +/-   ##
=======================================
  Coverage   94.31%   94.31%           
=======================================
  Files         293      293           
  Lines       29912    29922   +10     
  Branches     3057     3058    +1     
=======================================
+ Hits        28211    28221   +10     
  Misses       1679     1679           
  Partials       22       22           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

api-links Generator

Performance estimate (single CI run)

  • Generation time: 25.4% faster (710.00 ms → 530.00 ms)
  • Peak memory: 2.8% lower (292.45 MB → 284.19 MB)

json Generator

Performance estimate (single CI run)

  • Generation time: 25.2% faster (9.11 s → 6.81 s)
  • Peak memory: 1.0% higher (910.09 MB → 919.56 MB)

legacy-html Generator

Performance estimate (single CI run)

  • Generation time: 1.8% slower (11.57 s → 11.78 s)
  • Peak memory: 1.5% higher (1.39 GB → 1.41 GB)

legacy-json Generator

Performance estimate (single CI run)

  • Generation time: 51.7% slower (5.57 s → 8.45 s)
  • Peak memory: 11.9% lower (977.55 MB → 861.59 MB)

llms-txt Generator

Performance estimate (single CI run)

  • Generation time: 35.9% faster (9.12 s → 5.85 s)
  • Peak memory: 3.9% higher (814.07 MB → 846.04 MB)

orama-db Generator

Performance estimate (single CI run)

  • Generation time: 11.7% slower (5.45 s → 6.09 s)
  • Peak memory: 7.7% lower (1.07 GB → 1007.69 MB)

web Generator

Performance estimate (single CI run)

  • Generation time: 10.5% slower (20.95 s → 23.14 s)
  • Peak memory: 5.6% higher (1.46 GB → 1.54 GB)

@vedchaudhari vedchaudhari changed the title fix(config): point edit links at the main branch fix: fall back to main in edit links when the ref isn't a branch Nov 18, 2026
Comment on lines +26 to +35
// Refs GitHub's web editor can't open, as it only edits files on a branch:
const NON_BRANCH_REFS = [
// `HEAD`, and revisions relative to it (`HEAD~1`, `HEAD^`)
/^HEAD([~^]\d*)*$/,
// Commit SHAs (SHA-1 or SHA-256, abbreviated or not)
/^[0-9a-f]{7,64}$/i,
// Tags, given in full or as a release version (`v24.0.0`, `1.2.3-rc.1`)
/^refs\/tags\//,
/^v?\d+\.\d+\.\d+([-+].*)?$/,
];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we need this? Can't we change the branch in the config from HEAD to main, or something?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, that works too and is simpler. The beta build doesn't pass --git-ref, so setting the Node preset's ref to main fixes it; the fallback only helps if someone passes HEAD or a tag. Happy to switch to just that. @ovflowd ok with you?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@avivkeller @ovflowd any preference here? Happy to switch to just setting ref: 'main' in the Node preset if that's simpler.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No real preference. I just wonder where HEAD comes from? Is this inferred by git via doc-kit or?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No real preference. I just wonder where HEAD comes from? Is this inferred by git via doc-kit or?

It's not inferred from git. ref just defaults to 'HEAD' in the core config and the Node preset. That's fine for blob/raw links, since GitHub resolves it to the default branch, but /edit/HEAD/... 404s.

export const GITHUB_EDIT_URL = 'https://github.com/{repository}/edit/{ref}';

// The branch "edit this page" links use when `ref` can't be edited
export const DEFAULT_EDIT_BRANCH = 'main';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should just use --git-ref

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think we should just use --git-ref

Sounds good, I'll drop the fallback and pass --git-ref main in the beta build script instead.

Signed-off-by: vedchaudhari <vedc2853@gmail.com>
@vedchaudhari vedchaudhari changed the title fix: fall back to main in edit links when the ref isn't a branch fix(beta): pass --git-ref main so edit links work Nov 24, 2026

This branch was successfully deployed

1 active deployment
Preview – api-docs-tooling — 3dfe54ef Deployed Nov 24, 2026 by vercel[bot]
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.

3 participants