Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
default_language_version:
python: "3.11"
python: "3.12"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-ast
- id: check-case-conflict
Expand All @@ -13,23 +13,23 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.292"
rev: "v0.8.3"
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.5.1"
rev: "v1.13.0"
hooks:
- id: mypy
additional_dependencies:
- sphinx
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.330.post0
rev: v1.1.390
hooks:
- id: pyright
additional_dependencies:
Expand Down
178 changes: 168 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,172 @@
install:
pdm install
npm install
SHELL := /bin/bash

build-assets:
npx tailwindcss -i litestar_sphinx_theme/style.css -o litestar_sphinx_theme/theme/static/litestar-sphinx-theme.css -m
# =============================================================================
# Configuration and Environment Variables
# =============================================================================

.PHONY: refresh-lockfiles
refresh-lockfiles: ## Sync lockfiles with requirements files.
pdm update --update-reuse --group :all
.DEFAULT_GOAL:=help
.ONESHELL:
.EXPORT_ALL_VARIABLES:
MAKEFLAGS += --no-print-directory

# -----------------------------------------------------------------------------
# Display Formatting and Colors
# -----------------------------------------------------------------------------
BLUE := $(shell printf "\033[1;34m")
GREEN := $(shell printf "\033[1;32m")
RED := $(shell printf "\033[1;31m")
YELLOW := $(shell printf "\033[1;33m")
NC := $(shell printf "\033[0m")
INFO := $(shell printf "$(BLUE)ℹ$(NC)")
OK := $(shell printf "$(GREEN)✓$(NC)")
WARN := $(shell printf "$(YELLOW)⚠$(NC)")
ERROR := $(shell printf "$(RED)✖$(NC)")

# =============================================================================
# Help and Documentation
# =============================================================================

.PHONY: help
help: ## Display this help text for Makefile
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

# =============================================================================
# Installation and Environment Setup
# =============================================================================

.PHONY: install-uv
install-uv: ## Install latest version of uv
@echo "${INFO} Installing uv..."
@curl -LsSf https://astral.sh/uv/install.sh | sh >/dev/null 2>&1
@uv tool install nodeenv >/dev/null 2>&1
@echo "${OK} UV installed successfully"

.PHONY: install
install: destroy clean ## Install the project, dependencies, and pre-commit
@echo "${INFO} Starting fresh installation..."
@uv python pin 3.12 >/dev/null 2>&1
@uv venv >/dev/null 2>&1
@uv sync --all-extras --dev
@if ! command -v npm >/dev/null 2>&1; then \
echo "${INFO} Installing Node environment... 📦"; \
uvx nodeenv .venv --force --quiet >/dev/null 2>&1; \
fi
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm install --no-fund >/dev/null 2>&1
@echo "${OK} Installation complete! 🎉"

.PHONY: destroy
destroy: ## Destroy the virtual environment
@echo "${INFO} Destroying virtual environment... 🗑️"
@uv run pre-commit clean >/dev/null 2>&1
@rm -rf .venv
@echo "${OK} Virtual environment destroyed 🗑️"


# =============================================================================
# Dependency Management
# =============================================================================

.PHONY: upgrade
upgrade: ## Upgrade all dependencies to latest stable versions
@echo "${INFO} Updating all dependencies... 🔄"
@uv lock --upgrade
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npm upgrade --latest
@echo "${OK} Dependencies updated 🔄"
@uv run pre-commit autoupdate
@echo "${OK} Updated Pre-commit hooks 🔄"

.PHONY: lock
lock: ## Rebuild lockfiles from scratch, updating all dependencies
pdm update --update-eager --group :all
lock: ## Rebuild lockfiles from scratch
@echo "${INFO} Rebuilding lockfiles... 🔄"
@uv lock --upgrade >/dev/null 2>&1
@echo "${OK} Lockfiles updated"

# =============================================================================
# Build and Release
# =============================================================================

.PHONY: build
build: ## Build the package
@echo "${INFO} Generating CSS... 🎨"
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" npx tailwindcss -i litestar_sphinx_theme/style.css -o litestar_sphinx_theme/theme/static/litestar-sphinx-theme.css -m
@echo "${INFO} Building package... 📦"
@uv build >/dev/null 2>&1
@echo "${OK} Package build complete"


# =============================================================================
# Cleaning and Maintenance
# =============================================================================

.PHONY: clean
clean: ## Cleanup temporary build artifacts
@echo "${INFO} Cleaning working directory... 🧹"
@rm -rf pytest_cache .ruff_cache .hypothesis build/ -rf dist/ .eggs/ .coverage coverage.xml coverage.json htmlcov/ .pytest_cache tests/.pytest_cache tests/**/.pytest_cache .mypy_cache .unasyncd_cache/ .auto_pytabs_cache node_modules >/dev/null 2>&1
@find . -name '*.egg-info' -exec rm -rf {} + >/dev/null 2>&1
@find . -type f -name '*.egg' -exec rm -f {} + >/dev/null 2>&1
@find . -name '*.pyc' -exec rm -f {} + >/dev/null 2>&1
@find . -name '*.pyo' -exec rm -f {} + >/dev/null 2>&1
@find . -name '*~' -exec rm -f {} + >/dev/null 2>&1
@find . -name '__pycache__' -exec rm -rf {} + >/dev/null 2>&1
@find . -name '.ipynb_checkpoints' -exec rm -rf {} + >/dev/null 2>&1
@echo "${OK} Working directory cleaned"


# -----------------------------------------------------------------------------
# Type Checking
# -----------------------------------------------------------------------------

.PHONY: mypy
mypy: ## Run mypy
@echo "${INFO} Running mypy... 🔍"
@uv run dmypy run
@echo "${OK} Mypy checks passed ✨"

.PHONY: mypy-nocache
mypy-nocache: ## Run Mypy without cache
@echo "${INFO} Running mypy without cache... 🔍"
@uv run mypy
@echo "${OK} Mypy checks passed ✨"

.PHONY: pyright
pyright: ## Run pyright
@echo "${INFO} Running pyright... 🔍"
@uv run pyright
@echo "${OK} Pyright checks passed ✨"

.PHONY: basedpyright
basedpyright: ## Run basedpyright
@echo "${INFO} Running basedpyright... 🔍"
@uv run basedpyright
@echo "${OK} Basedpyright checks passed ✨"

.PHONY: type-check
type-check: mypy pyright ## Run all type checking

# -----------------------------------------------------------------------------
# Linting and Formatting
# -----------------------------------------------------------------------------

.PHONY: pre-commit
pre-commit: ## Run pre-commit hooks
@echo "${INFO} Running pre-commit checks... 🔎"
@NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" uv run pre-commit run --color=always --all-files
@echo "${OK} Pre-commit checks passed ✨"

.PHONY: slotscheck
slotscheck: ## Run slotscheck
@echo "${INFO} Running slots check... 🔍"
@uv run slotscheck -m litestar_sphinx_theme
@echo "${OK} Slots check passed ✨"

.PHONY: fix
fix: ## Run code formatters
@echo "${INFO} Running code formatters... 🔧"
@uv run ruff check --fix --unsafe-fixes
@echo "${OK} Code formatting complete ✨"

.PHONY: lint
lint: pre-commit type-check slotscheck ## Run all linting checks

.PHONY: check-all
check-all: lint test coverage ## Run all checks (lint, test, coverage)
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Litestar sphinx theme

A Sphinx theme for the [Litestar organization](https://github.com/litestar-org), based on the
[PyData Sphinx Theme](https://github.com/pydata/pydata-sphinx-theme).
[Shibuya Theme](https://shibuya.lepture.com).

It doesn't do much, mostly adjusting some colours a bit of layout and add a few default links and menus.
It doesn't do much, mostly adjusting some colors a bit of layout and adding a few default links and menus.

Refer to the [PyData Sphinx Theme documentation](https://pydata-sphinx-theme.readthedocs.io/en/latest/) for documentation.
Refer to the [Shibuya Theme documentation](https://shibuya.lepture.com) for documentation.

**This theme is not intended for general use**
31 changes: 7 additions & 24 deletions litestar_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@ def update_html_context(

context["extra_navbar_items"] = theme_options.get("extra_navbar_items")
context["use_page_nav"] = theme_options.get("use_page_nav", True)
context["github_repo_link"] = f"https://github.com/litestar-org/{theme_options['github_repo_name']}"
context["discord_link"] = theme_options.get(
context["github_url"] = f"https://github.com/litestar-org/{theme_options['github_repo_name']}"
context["discord_url"] = theme_options.get(
"discord_link",
"https://discord.gg/litestar",
)
context["twitter_link"] = theme_options.get(
context["twitter_url"] = theme_options.get(
"twitter_link",
"https://twitter.com/LitestarAPI",
)
context["reddit_link"] = theme_options.get(
context["reddit_url"] = theme_options.get(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shibuya theme supports Reddit natively now.

@JacobCoffee JacobCoffee Apr 10, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes! thats why I uncommented and added.
This is so that we dont need to define it in each of our projects conf.py 😄. Actually set in theme.conf this seems sortve redundant but i was keeping with the prior work in letting people set it differently if for some reason

"reddit_link",
"https://www.reddit.com/r/litestarapi",
"https://www.reddit.com/r/LitestarAPI",
)


def update_global_config(app: Sphinx) -> None:
if not app.config["html_logo"]:
app.config["html_logo"] = "_static/logo.svg"
app.config["html_logo"] = "_static/logo-light.png"

if not app.config["html_favicon"]:
app.config["html_favicon"] = "_static/favicon.png"
app.config["html_favicon"] = "_static/favicon.svg"

theme_options = _get_theme_options(app)
if not theme_options:
Expand All @@ -60,23 +60,6 @@ def update_global_config(app: Sphinx) -> None:
if not github_repo_name:
msg = "GitHub URL not provided. Set 'github_repo_name=...' in html_theme_options"
raise ValueError(msg)
icon_links = theme_options.setdefault("icon_links", [])
icon_links.extend(
[
{
"name": "GitHub",
"url": f"https://github.com/litestar-org/{github_repo_name}",
"icon": "fa-brands fa-github",
"type": "fontawesome",
},
{
"name": "Discord",
"url": "https://discord.gg/litestar",
"icon": "fa-brands fa-discord",
"type": "fontawesome",
},
],
)


def setup(app: Sphinx) -> dict[str, bool]:
Expand Down
Loading