Code

Code blocks are sunken wells with a copy button that appears on hover. The Pygments palette follows the runescapecn code sample colours: keywords green, attributes and numbers cyan, strings yellow, comments grey.

Python

from dataclasses import dataclass


@dataclass
class Player:
    """A logged-in account."""

    name: str
    combat_level: int = 3

    def greet(self) -> str:
        # Welcome message shown on login.
        return f"Welcome to 2009scape, {self.name}!"

With line numbers and an emphasised line:

1def smelt(ore, coal=0):
2    if ore == "iron" and coal == 0:
3        raise ValueError("iron needs coal")
4    return f"{ore} bar"

With a caption:

static/js/login.js
const login = async (username, password) => {
  const response = await fetch("/api/login", {
    method: "POST",
    body: JSON.stringify({ username, password }),
  });
  return response.json();
};

Other languages

$ sphinx-build -b html docs docs/_build/html
theme:
  name: 2009scape
  options:
    logo_text: My Project
    scanlines: true
  html_theme = "alabaster"
- html_theme = "alabaster"
+ html_theme = "2009scape"
<div class="rs-panel">
  <p class="rs-badge">Members</p>
</div>

Literal blocks

A plain literal block, introduced with a double colon:

Woodcutting  99
Fishing      99
Firemaking   99

Doctest

>>> from sphinx_2009scape_theme import __version__
>>> __version__
'1.0.0'

Parsed literals

$ pip install sphinx-2009scape-theme==1.0.2