Skip to content

feat: prepare the staged README for the packaged toolbox - #82

Draft
ehennestad wants to merge 2 commits into
add-readme-and-package-name-optionsfrom
process-staged-readme
Draft

ehennestad wants to merge 2 commits into
add-readme-and-package-name-optionsfrom
process-staged-readme

Conversation

@ehennestad

@ehennestad ehennestad commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

On R2026b the package readme is the file named by Readme, and File Exchange shows it as the submission text. A project README copied into the package through RootFilesToPackage is written for GitHub: its badges and relative links and image paths do not resolve on File Exchange.

Changes

  • packageToolbox rewrites the staged copy of the file named by Readme after the version is known, with the new matbox.toolbox.internal.prepareReadme. A readme committed in the source folder is not changed. stageRootFilesForPackaging now returns the paths of the copies it staged, which is how packageToolbox tells the two apart.
  • Badge lines: a line made only of Markdown images, linked or not, is removed when it lies in the leading block, before the first line of prose. Blank lines, headings and lines of HTML tags do not end the leading block. Image lines further down, such as figures, and HTML <img> lines, such as logos, are kept.
  • Links: relative destinations of Markdown links and images, reference definitions and the HTML attributes href, src and srcset become absolute at the tag v<major>.<minor>.<patch> of the packaged version. A file becomes <repository>/blob/<tag>/<path>, a folder <repository>/tree/<tag>/<path>, and an image https://raw.githubusercontent.com/<owner>/<repo>/<tag>/<path> (<repository>/raw/<tag>/<path> off github.com). A leading ./ or / is dropped and a query or fragment is kept. Destinations with a scheme, starting with #, // or ../, and everything inside fenced code blocks are left as they are.
  • matbox.toolbox.internal.getRepositoryUrl takes the repository from GITHUB_SERVER_URL and GITHUB_REPOSITORY on GitHub Actions, else from the origin remote, with SSH addresses and credentials converted to https://<host>/<owner>/<repo>. Without either, links stay relative and MatBox:Package:RepositoryUrlNotFound is issued.
  • prepareReadmeFile reads and writes the readme as UTF-8.
  • PrepareReadmeTest covers the transform and the repository URL. In TasksTest, the packaged readme of the Readme test is now compared with the processed text, and a new test checks that a committed readme is packaged unchanged.
  • The README and docs/ci.md describe the processing.

Notes

On EBRAINS-MATLAB the processing removes the seven badge lines and turns the four relative links into blob and tree URLs. On openMINDS_MATLAB the logo block before the title is kept, with its /img/... paths made absolute.

🤖 Generated with Claude Code

A README copied from the project root through RootFilesToPackage is
the package readme on R2026b, and File Exchange shows it. Its badges
and relative links only work on GitHub.

packageToolbox now rewrites the staged copy named by Readme, once the
version is known, with matbox.toolbox.internal.prepareReadme:

- Lines made only of Markdown images are removed from the leading
  block, before the first line of prose. Image lines further down,
  such as figures, and HTML <img> lines are kept.
- Relative destinations of Markdown links and images, reference
  definitions and the HTML attributes href, src and srcset become
  absolute URLs at the tag v<major>.<minor>.<patch>: blob for a file,
  tree for a folder, the raw URL for an image. Fenced code blocks are
  not changed.

The repository URL comes from GITHUB_SERVER_URL and GITHUB_REPOSITORY
on GitHub Actions, else from the origin remote. Without either, the
links stay relative and MatBox:Package:RepositoryUrlNotFound is
issued. A readme committed in the source folder is not processed.

stageRootFilesForPackaging returns the paths of the staged copies, so
packageToolbox can tell a staged copy from a committed file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ehennestad
ehennestad added this pull request to stack #83 November 4, 2026 10:32
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

133 tests   132 ✅  43s ⏱️
  8 suites    1 💤
  1 files      0 ❌

Results for commit 9b49818.

♻️ This comment has been updated with latest results.

@ehennestad
ehennestad marked this pull request as draft November 4, 2026 11:08
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.

1 participant