Skip to content

Add code annotations with Akemi as the marker - #347

Open
bharvey88 wants to merge 2 commits into
wled:mainfrom
bharvey88:feat/akemi-annotations
Open

Add code annotations with Akemi as the marker#347
bharvey88 wants to merge 2 commits into
wled:mainfrom
bharvey88:feat/akemi-annotations

Conversation

@bharvey88

@bharvey88 bharvey88 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

This enables Material's code annotations, numbered notes that open in a tooltip from a small marker in a code block or paragraph, and restyles the marker: instead of the theme's default (+) sign, the marker is the cheerful Akemi already used as the site logo, anchored to the bottom of the line so she peeks over the text. She grows slightly (1.15x) on hover and while a tooltip is open, replacing the theme's tint-and-rotate effect.

Config side: the content.code.annotate theme feature plus the md_in_html extension annotations rely on. The marker styling is pure CSS in extra.css using the existing logo asset; no new files or images.

This PR deliberately adds only the capability and styling. No pages are annotated yet; a follow-up PR will start using annotations in the docs. Preview of what it looks like on an annotated page:

wled-docs-akemi-annotation

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Enabled interactive code annotations in the documentation.
    • Added custom image-based markers for code annotation indices.
    • Improved annotation marker behavior, keeping the image untinted and scaling on hover/active.
  • Documentation
    • Added support for rendering Markdown inside HTML blocks.

Enables Material's content.code.annotate feature (plus md_in_html,
which annotation tooltips need for block-level content). Instead of
the theme's default (+) marker, the annotation button is Akemi: the
theme's single-color mask is dropped and the cheerful Akemi already
shipped as the site logo is drawn directly, anchored to the bottom
of the line so she peeks over the text. She grows slightly on hover
and while the tooltip is open, replacing the theme's tint-and-rotate
effect.

No pages are annotated yet; docs changes that use annotations come
in a follow-up PR.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b3db4db6-9156-4623-bd31-ae9bc9e15ea4

📥 Commits

Reviewing files that changed from the base of the PR and between 24db96f and 4488ddb.

📒 Files selected for processing (1)
  • mkdocs.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • mkdocs.yml

Walkthrough

Changes

Code annotation presentation

Layer / File(s) Summary
Enable and style code annotations
mkdocs.yml, docs/assets/stylesheets/extra.css
Enables Material code annotations and md_in_html, then replaces the default annotation marker with an Akemi image and custom hover, active, and code-block sizing behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Poem

A rabbit hops where code marks gleam,
Akemi blooms inside the theme.
Tiny signs grow bold on cue,
Hovered stars turn bright and new.
Markdown pathways softly flow.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: enabling code annotations and using Akemi as the annotation marker.
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.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code

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.

@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: 1

🤖 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 `@docs/assets/stylesheets/extra.css`:
- Line 57: Update the background asset URL in the stylesheet to use the relative
path ../images/ui/akemi/001_cheerful.png instead of the root-relative /assets
path, preserving the existing background positioning and sizing.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ec0b5362-ed78-4b9e-98db-365e98000e61

📥 Commits

Reviewing files that changed from the base of the PR and between 1583203 and 24db96f.

📒 Files selected for processing (2)
  • docs/assets/stylesheets/extra.css
  • mkdocs.yml

.md-annotation__index::after {
-webkit-mask-image: none;
mask-image: none;
background: url("/assets/images/ui/akemi/001_cheerful.png") center bottom / contain no-repeat;

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

rg -n '^(site_url|use_directory_urls|extra_css):|001_cheerful\.png' \
  mkdocs.yml docs/assets/stylesheets/extra.css || true

fd -a -t f '001_cheerful\.png$' docs/assets

Repository: wled/WLED-Docs

Length of output: 437


🏁 Script executed:

#!/bin/bash
set -eu

printf 'mkdocs.yml relevant lines:\n'
sed -n '1,90p' mkdocs.yml | cat -n

printf '\nextra.css relevant lines:\n'
sed -n '1,90p' docs/assets/stylesheets/extra.css | cat -n

printf '\nMkDocs configuration files:\n'
fd -a -t f '^(mkdocs|docs|site-)?\.ya?ml$' .

Repository: wled/WLED-Docs

Length of output: 6982


🌐 Web query:

MkDocs site_url custom_css_url extra_css directory_urls site_url extra_css base path

💡 Result:

In MkDocs, the site_url and use_directory_urls settings dictate how your site handles URLs and navigation, while extra_css is used to inject custom styles into your documentation [1][2][3]. site_url The site_url setting defines the canonical URL of your site [1][4]. It is critical for generating correct canonical links in the HTML header and is often required by plugins [1][5]. If your site is hosted in a subdirectory (e.g., https://example.com/foo/), you must include that path in the site_url (e.g., https://example.com/foo/) [1][2]. This setting also influences how mkdocs serve mounts your site locally [1][2]. If you are building documentation for local file system viewing (e.g., using the file:// scheme), you should set site_url to an empty string ("") [6]. use_directory_urls The use_directory_urls setting determines the file structure and linking style of your generated HTML files [3][7]. - When true (default), Markdown files are mapped to an index.html file inside a directory (e.g., about.md becomes about/index.html), resulting in clean URLs like /about/ [3][8][7]. - When false, Markdown files are mapped to a single HTML file of the same name (e.g., about.md becomes about.html) [3][8][7]. This style is useful when browsing documentation directly from a local file system where directory-based index files may not resolve correctly [6][7]. extra_css The extra_css setting is a list used to include custom CSS files in your generated documentation [9][10][3]. To use it: 1. Place your CSS file (e.g., style.css) inside your docs_dir (the folder containing your Markdown files) [9][10]. 2. Add the file path to your mkdocs.yml configuration: extra_css: - style.css These files are added to the generated HTML document after the page content, allowing you to override or add to the theme's existing styles [9][10].

Citations:


🌐 Web query:

"MkDocs" "Use relative URLs for CSS assets" "site_url" "static_url"

💡 Result:

MkDocs is designed to use relative URLs for all internal links and static assets, ensuring that the generated site remains functional regardless of where it is hosted (e.g., in a subdirectory or at the root) [1][2][3]. For CSS assets, you generally do not need to manually configure them as absolute URLs. Instead, you manage them as follows: 1. Standard Extra CSS: Place your CSS files (e.g., in a stylesheets/ directory) within your docs/ folder [4][5]. Then, reference them in your mkdocs.yml using the extra_css configuration [1][4][5]: extra_css: - stylesheets/extra.css MkDocs will automatically handle the necessary relative paths to these files in the generated HTML [1][6]. 2. Theme Customizations: If you are overriding a theme or including assets directly in a custom template, you can use the base_url variable (or the url Jinja2 filter) to ensure links remain relative to the root of the site [7][8]: or 3. Handling Subdirectories: If your site is hosted in a subdirectory (e.g., https://example.com/project/), you should set the site_url in mkdocs.yml to reflect this, such as site_url: https://example.com/project/ [1]. MkDocs uses this configuration to correctly calculate relative paths, ensuring that links point to the correct location relative to the server root or the deployment path [1][7]. If you find that MkDocs is not automatically rewriting a specific URL (for example, inside raw HTML blocks), note that MkDocs' automatic link-fixing features primarily apply to standard Markdown links and theme templates; they do not always process hard-coded links within raw HTML [9]. In such cases, using relative paths that account for the directory structure of the built site is the standard approach [9].

Citations:


🌐 Web query:

"Material for MkDocs" "custom_css_url" "url" extra_css

💡 Result:

To include custom CSS in Material for MkDocs, you should use the standard MkDocs configuration option extra_css in your mkdocs.yml file [1][2]. There is no specific custom_css_url setting; extra_css is the authorized method for loading additional stylesheets [2][3]. Steps to add custom CSS: 1. Create a CSS file in your project, typically within the docs directory (e.g., docs/stylesheets/extra.css) [1][4]. 2. Reference this file in your mkdocs.yml using the extra_css key [1][2]: yaml extra_css: - stylesheets/extra.css Paths provided in extra_css are relative to the docs_dir [2]. You can also provide absolute URLs or external paths if you are loading CSS from a CDN [5]. For more extensive theme modifications, such as overriding templates or partials, Material for MkDocs also supports a custom_dir configuration in mkdocs.yml, which allows you to override specific theme files by placing them in a designated folder [1][6]. However, for simple style tweaks, using extra_css is the recommended and most straightforward approach [1][3].

Citations:


Use a base-path-safe asset URL.

The stylesheet is loaded from docs/assets/stylesheets/extra.css, but this background URL is root-relative and currently points to /assets/images/ui/akemi/001_cheerful.png. Since the asset is tracked at docs/assets/images/ui/akemi/001_cheerful.png, use ../images/ui/akemi/001_cheerful.png so the generated path remains correct for non-root deployments.

Proposed fix
-  background: url("/assets/images/ui/akemi/001_cheerful.png") center bottom / contain no-repeat;
+  background: url("../images/ui/akemi/001_cheerful.png") center bottom / contain no-repeat;
📝 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
background: url("/assets/images/ui/akemi/001_cheerful.png") center bottom / contain no-repeat;
background: url("../images/ui/akemi/001_cheerful.png") center bottom / contain no-repeat;
🤖 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 `@docs/assets/stylesheets/extra.css` at line 57, Update the background asset
URL in the stylesheet to use the relative path
../images/ui/akemi/001_cheerful.png instead of the root-relative /assets path,
preserving the existing background positioning and sizing.

@netmindz netmindz left a comment

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.

thank you for your contribution

@bharvey88

Copy link
Copy Markdown
Contributor Author

@softhack007 what do you think of this one? I really like it. I do something similar with Apollo docs.

@softhack007

Copy link
Copy Markdown
Member

@bharvey88 looks nice, I'm just wondering will it also work on mobile devices? Like a pad with touch but without a mouse pointer?

@bharvey88

Copy link
Copy Markdown
Contributor Author

@bharvey88 looks nice, I'm just wondering will it also work on mobile devices? Like a pad with touch but without a mouse pointer?

Yes it works on mobile- you can see it live on our wiki here: https://wiki.apolloautomation.com/products/ESPHome-Starter-Kit/setup/first-steps/

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