Skip to content

Style semantic markup roles#924

Open
him2him2 wants to merge 3 commits into
pradyunsg:mainfrom
him2him2:style-semantic-roles
Open

Style semantic markup roles#924
him2him2 wants to merge 3 commits into
pradyunsg:mainfrom
him2him2:style-semantic-roles

Conversation

@him2him2

Copy link
Copy Markdown

Summary

Adds visual styling for Sphinx semantic roles that are currently indistinguishable from plain bold, italic, or inline code. Addresses #890.

Roles are grouped into four visual categories, each with a subtle tinted background that works in both light and dark mode:

Group Roles Visual treatment
CLI/Commands (green tint) :command:, :program:, :makevar: Monospace + pill background
Paths/Patterns (amber tint) :file:, :samp:, :regexp: Tinted code background
Environment/Options (purple tint) :envvar:, :option: Tinted code background
Metadata (grey tint) :manpage:, :mimetype:, :mailheader:, :newsgroup: Pill background

Files changed

  • src/furo/assets/styles/variables/_colors.scss -- CSS custom properties (light + dark)
  • src/furo/assets/styles/content/_semantic-roles.sass -- new stylesheet
  • src/furo/assets/styles/content/_index.sass -- register the new module
  • docs/kitchen-sink/generic.rst -- demo section with examples of all roles

Note

This is a first pass at the styling. I'm very open to feedback on the colour choices, groupings, or overall approach -- if anything should be tweaked or done differently, please let me know and I'll update accordingly.

Test plan

  • Build docs and verify all roles in the kitchen-sink "Semantic roles" section render with distinct styling
  • Toggle dark mode and confirm colours work in both themes
  • Verify existing :guilabel:, :kbd:, :menuselection: styles are unaffected
Add visual styling for Sphinx semantic roles that are currently
indistinguishable from plain bold, italic, or inline code:

- CLI/Commands (green tint): :command:, :program:, :makevar:
- Paths/Patterns (amber tint): :file:, :samp:, :regexp:
- Environment/Options (purple tint): :envvar:, :option:
- Metadata (grey tint): :manpage:, :mimetype:, :mailheader:, :newsgroup:

Includes light and dark mode support and kitchen-sink examples.
For example, ``menuselection`` should break when it is too long to fit on a
single line.

Semantic roles

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

uses replaceable parts. Regular expressions: :regexp:`^foo.*bar$`.

**Environment variables and options:**
Set :envvar:`PATH` or :envvar:`HOME` in your shell. Pass :option:`--verbose` or

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I wonder if the env vars should have a $ prepended as a visual cue. Let's wait what Pradyun has to say once he comes back home..

Comment thread docs/kitchen-sink/generic.rst Outdated
:makevar:`CFLAGS` are also styled distinctly.

**File paths, samples, and patterns:**
Edit :file:`/etc/hosts` or :file:`conf.py`. A sample like :samp:`print({name})`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We probably need an example with python3.{x} in a path, not just in a sample.

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.

Added :file:/usr/bin/python3.{x}`` in f2be025.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tip

@him2him2 I noticed that you posted a bit of RST in a GH comment which renders Markdown. It's a bit unobvious but is actually possible to embed RST in MD by wrapping it with double backticks and a whitespace between the outer double backticks and the inner RST content with backticks that should remain rendered as is:

:file:`/usr/bin/python3.{x}`


2026-02-26-143347_hyprshot
Comment thread docs/kitchen-sink/generic.rst Outdated
italic, or inline code. Each group below has a distinct visual style.

**CLI commands and build variables:**
Use :command:`curl` or :program:`python3` to run commands. Build variables like

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's add a CLI arg to the curl example to show that a command can contain multiple whitespace-delimited components while a program generally wouldn't, IIUC what the Sphinx docs imply.

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.

Done — changed to :command:curl -sSL`` in f2be025.

@webknjaz

Copy link
Copy Markdown

@him2him2 I noticed that the background colors are better visible in dark mode but when the light color scheme is active, it's barely noticeable. Have you looked into the contrast difference?

- Increase light mode alpha from 50% to 75% for better contrast
- Add CLI args to curl example to show multi-word commands
- Add file path example with replaceable part
@him2him2

Copy link
Copy Markdown
Author

@webknjaz Good catch — I've bumped the light mode alpha from 50% (80) to 75% (c0) for all role backgrounds and borders. Should be noticeably more visible without being too heavy. Preview will rebuild shortly.

@webknjaz

Copy link
Copy Markdown

Nice! I like it better now :)

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

Labels

None yet

2 participants