Skip to content

Feat/repository card#74

Merged
sagi21805 merged 11 commits into
masterfrom
feat/repository-card
Jun 18, 2026
Merged

Feat/repository card#74
sagi21805 merged 11 commits into
masterfrom
feat/repository-card

Conversation

@sagi21805

@sagi21805 sagi21805 commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Added GitHub repository cards to documentation pages, automatically pulling repository details (description, stars, forks, issues, language, recent stats) and linking to key GitHub destinations.
    • Included themed styling for the cards and an optional Patreon callout when configured.
  • Documentation
    • Updated a chapter introduction by adding a new Paul Graham quote.
  • Chores
    • Refreshed subproject versions used for the documentation tooling and previews.

@sagi21805 sagi21805 self-assigned this Jun 18, 2026
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@sagi21805, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 15 minutes and 8 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6b981bc0-8414-4865-9472-58d1809dc773

📥 Commits

Reviewing files that changed from the base of the PR and between 23a67f7 and 21af58b.

📒 Files selected for processing (20)
  • mdbook-repository-card/Cargo.toml
  • mdbook-repository-card/src/main.rs
  • mdbook-rust-analyzer-highlight
  • src/Help.md
  • src/Introduction.md
  • src/Roadmap.md
  • src/ch01-00-getting-started.md
  • src/ch01-01-making-stand-alone-binary.md
  • src/ch01-02-booting-our-binary.md
  • src/ch01-03-debugging-methods.md
  • src/ch02-00-a-minimal-bootloader.md
  • src/ch02-01-legacy-legacy-legacy.md
  • src/ch02-02-entering-protected-mode.md
  • src/ch02-03-implementing-the-bitfields-proc-macro.md
  • src/ch02-03-what-is-memory-paging.md
  • src/ch02-04-booting-the-kernel.md
  • src/ch03-00-printing-to-screen.md
  • src/ch04-00-memory-management.md
  • src/ch05-00-interrupts-and-exceptions.md
  • src/ch05-01-utilizing-the-idt.md
📝 Walkthrough

Walkthrough

A new mdbook-repository-card Rust preprocessor crate is added that injects a GitHub repository card HTML snippet into book chapters by replacing --- markers. Supporting client-side assets (theme/github-box.css, theme/github-card.js) style and populate the card via GitHub API fetches. book.toml is updated to wire the preprocessor and assets in. Two submodule pointers are bumped and one chapter receives a new quote.

Changes

GitHub Repository Card Preprocessor

Layer / File(s) Summary
Rust preprocessor crate
mdbook-repository-card/Cargo.toml, mdbook-repository-card/rustfmt.toml, mdbook-repository-card/src/main.rs
New mdbook-repository-card crate defines GithubRepositoryCard with embedded HTML templates for the card and optional Patreon snippet, implements the Preprocessor trait to extract config from book.toml, validate required fields, and regex-inject the rendered card HTML after --- markers in each chapter. CLI entry handles supports mode and stdin/stdout JSON I/O.
CSS styling for the repository card
theme/github-box.css
Defines the complete .github-repo-box component with CSS custom properties for light and dark themes (coal, navy, ayu), box layout with accent border, flex header and title styling with hover effects, action buttons with transitions, description typography, footer stats grid with hover styling, icon and language-color swatch, and Patreon button icon.
Client-side JavaScript for GitHub API integration
theme/github-card.js
Scans .github-repo-box elements, reads data-repo, and makes two API requests per card: fetches repository metadata (name, description, stars, forks, issues, language) and populates DOM with a hardcoded language-to-color mapping; fetches commits with per_page=1 to derive commit count from Link header pagination or array length, with error handling that logs failures and sets fallback values.
Book wiring, submodule bumps, and doc update
book.toml, LearnixOS, mdbook-gh-issue-preview, src/ch02-03-implementing-the-bitfields-proc-macro.md
book.toml registers the preprocessor (after gh-issue-preview) and adds both theme assets to multiline additional-css/additional-js arrays. Both submodule pointers are bumped to new commits. One chapter gains an italicized Paul Graham quote.

Sequence Diagram(s)

sequenceDiagram
  rect rgba(173, 216, 230, 0.5)
    Note over mdBook,stdout: Build-time preprocessing
    mdBook->>GithubRepositoryCard: spawn (cargo run)
    mdBook->>stdin: write JSON(context, book)
    GithubRepositoryCard->>GithubRepositoryCard: extract username/repository from config
    GithubRepositoryCard->>GithubRepositoryCard: render HTML and regex-replace --- markers
    GithubRepositoryCard->>stdout: write processed book JSON
  end

  rect rgba(144, 238, 144, 0.5)
    Note over Browser,GitHubAPI: Runtime card population
    Browser->>github-card.js: page load
    github-card.js->>github-card.js: querySelectorAll(.github-repo-box)
    github-card.js->>GitHubAPI: GET /repos/{data-repo}
    GitHubAPI-->>github-card.js: name, description, stars, forks, issues, language
    github-card.js->>GitHubAPI: GET /repos/{data-repo}/commits?per_page=1
    GitHubAPI-->>github-card.js: commits + Link header
    github-card.js->>Browser: populate card DOM fields and apply language color
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 A card for each repo, so neat and so bright,
With stars and with forks gleaming there in the night.
The preprocessor hops through each chapter with glee,
Replacing the dashes with HTML for thee.
Two fetches, one stylesheet, a crate newly born—
The book blossoms fresh on this fine bunny morn! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Feat/repository card' is vague and uses generic formatting conventions rather than clearly describing the main functionality being added. Use a more descriptive title that clearly explains what feature is being added, such as 'Add GitHub repository card preprocessor for mdBook'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/repository-card

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@mdbook-repository-card/src/main.rs`:
- Around line 103-121: Replace the generic regex pattern `r"---"` in the
Regex::new call with a dedicated placeholder token that is unlikely to appear in
normal markdown content, such as a unique marker like `r"<!--
REPOSITORY_CARD_PLACEHOLDER -->"` or similar. Then ensure that the HTML card
injection only happens when this specific placeholder is encountered, rather
than replacing all markdown separators. This prevents unintended card insertion
on normal `---` separators that may already exist in chapter content.

In `@theme/github-box.css`:
- Around line 40-41: In the dark-mode block of the github-box.css file,
Stylelint requires an empty line between custom property declarations and
regular CSS properties. Add a blank line between the --gh-btn-hover custom
property declaration and the box-shadow property to comply with the spacing
rules. This separation helps maintain consistent formatting between custom
properties and standard properties.

In `@theme/github-card.js`:
- Around line 6-8: The fetch call to the GitHub API endpoint does not validate
the HTTP response status before processing the response body. Add a status check
in the first .then() handler after fetching from the GitHub API to verify that
res.ok is true, and if not, throw an error or reject the promise so that error
responses (like 403 or 404) are caught before attempting to parse the JSON and
access data properties. This prevents partial or broken card states when the API
returns error responses.
- Line 44: The commits link in the querySelector for ".link-commits" hardcodes
the branch name as "main", which will fail for repositories with different
default branches. Instead of hardcoding the string "main" in the href
assignment, access the default branch from the data object (which should contain
`default_branch` property from the GitHub API) and use that value dynamically in
the URL to ensure the link works for any repository regardless of its default
branch name.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cd6616ed-6b06-4ab4-be32-fe12ca90266a

📥 Commits

Reviewing files that changed from the base of the PR and between 71e783a and 9d123f0.

📒 Files selected for processing (9)
  • LearnixOS
  • book.toml
  • mdbook-gh-issue-preview
  • mdbook-repository-card/Cargo.toml
  • mdbook-repository-card/rustfmt.toml
  • mdbook-repository-card/src/main.rs
  • src/ch02-03-implementing-the-bitfields-proc-macro.md
  • theme/github-box.css
  • theme/github-card.js

Comment thread mdbook-repository-card/src/main.rs Outdated
Comment thread theme/github-box.css
Comment on lines +40 to +41
--gh-btn-hover: #30363d;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix the Stylelint spacing violation in the dark-mode block.

Stylelint expects an empty line before Line 41 (box-shadow) after the custom property declarations.

💡 Proposed fix
 html.coal .github-repo-box,
 html.navy .github-repo-box,
 html.ayu .github-repo-box {
@@
     --gh-btn-border: rgba(240, 246, 252, 0.1);
     --gh-btn-hover: `#30363d`;
+
     box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
--gh-btn-hover: #30363d;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
html.coal .github-repo-box,
html.navy .github-repo-box,
html.ayu .github-repo-box {
--gh-btn-border: rgba(240, 246, 252, 0.1);
--gh-btn-hover: `#30363d`;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
}
🧰 Tools
🪛 Stylelint (17.13.0)

[error] 41-41: Expected empty line before declaration (declaration-empty-line-before)

(declaration-empty-line-before)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@theme/github-box.css` around lines 40 - 41, In the dark-mode block of the
github-box.css file, Stylelint requires an empty line between custom property
declarations and regular CSS properties. Add a blank line between the
--gh-btn-hover custom property declaration and the box-shadow property to comply
with the spacing rules. This separation helps maintain consistent formatting
between custom properties and standard properties.

Source: Linters/SAST tools

Comment thread theme/github-card.js
Comment on lines +6 to +8
fetch(`https://api.github.com/repos/${repoPath}`)
.then((res) => res.json())
.then((data) => {

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Guard the repo metadata fetch with an HTTP status check.

Without checking res.ok, API error responses (e.g., 403/404) enter the success path and then fail on property access, leaving partial/broken card state.

💡 Proposed fix
-  fetch(`https://api.github.com/repos/${repoPath}`)
-    .then((res) => res.json())
+  fetch(`https://api.github.com/repos/${repoPath}`)
+    .then((res) => {
+      if (!res.ok) throw new Error(`Repository fetch failed: ${res.status}`);
+      return res.json();
+    })
     .then((data) => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fetch(`https://api.github.com/repos/${repoPath}`)
.then((res) => res.json())
.then((data) => {
fetch(`https://api.github.com/repos/${repoPath}`)
.then((res) => {
if (!res.ok) throw new Error(`Repository fetch failed: ${res.status}`);
return res.json();
})
.then((data) => {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@theme/github-card.js` around lines 6 - 8, The fetch call to the GitHub API
endpoint does not validate the HTTP response status before processing the
response body. Add a status check in the first .then() handler after fetching
from the GitHub API to verify that res.ok is true, and if not, throw an error or
reject the promise so that error responses (like 403 or 404) are caught before
attempting to parse the JSON and access data properties. This prevents partial
or broken card states when the API returns error responses.

Comment thread theme/github-card.js
box.querySelector(".link-stars").href = `${data.html_url}/stargazers`;
box.querySelector(".link-forks").href =
`${data.html_url}/network/members`;
box.querySelector(".link-commits").href = `${data.html_url}/commits/main`;

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Do not hardcode main in the commits link.

Line 44 will produce a wrong/broken link for repositories whose default branch is not main.

💡 Proposed fix
-      box.querySelector(".link-commits").href = `${data.html_url}/commits/main`;
+      box.querySelector(".link-commits").href = `${data.html_url}/commits`;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@theme/github-card.js` at line 44, The commits link in the querySelector for
".link-commits" hardcodes the branch name as "main", which will fail for
repositories with different default branches. Instead of hardcoding the string
"main" in the href assignment, access the default branch from the data object
(which should contain `default_branch` property from the GitHub API) and use
that value dynamically in the URL to ensure the link works for any repository
regardless of its default branch name.

@sagi21805 sagi21805 merged commit 188d956 into master Jun 18, 2026
1 check passed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 19, 2026
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