Liking cljdoc? Tell your friends :D

com.blockether.ruff

Clojure binding to ruff (https://github.com/astral-sh/ruff) for Python code FORMATTING ONLY, through the JDK Foreign Function & Memory API.

ruff does not publish a C-ABI library — only a CLI. So this binds a tiny first-party cdylib, ruff-c (native/ruff-c, a thin extern "C" wrapper over ruff's ruff_python_formatter crate), exactly the way clj-fff binds fff-c. Formatting runs IN-PROCESS via a downcall — no subprocess, no CLI, no config discovery. format takes Python source and returns it reformatted (long calls/collections wrapped multiline, black-compatible style).

Run the JVM with --enable-native-access=ALL-UNNAMED so the foreign linker may load the library without a restricted-method warning.

The library is resolved ONCE, lazily, the first time it's needed:

  1. RUFF_NATIVE_PATH env / com.blockether.ruff.native.path system property — an explicit path to the cdylib (used verbatim).
  2. A bundled classpath resource prebuilds/<platform>/<lib>, shipped by com.blockether/ruff-native-<platform> (extracted to the cache dir). This is the native-image path.
  3. A runtime download: the ruff-native-<platform> jar resolved through clojure.tools.deps (honouring Maven repos/mirrors/settings.xml), extracted + cached. Disable with RUFF_DISABLE_DOWNLOAD=1.

<platform> ∈ { linux-x64 linux-arm64 darwin-arm64 darwin-x64 windows-x64 }.

Clojure binding to ruff (https://github.com/astral-sh/ruff) for Python code
FORMATTING ONLY, through the JDK Foreign Function & Memory API.

ruff does not publish a C-ABI library — only a CLI. So this binds a tiny
first-party cdylib, `ruff-c` (native/ruff-c, a thin `extern "C"` wrapper over
ruff's `ruff_python_formatter` crate), exactly the way clj-fff binds `fff-c`.
Formatting runs IN-PROCESS via a downcall — no subprocess, no CLI, no config
discovery. `format` takes Python source and returns it reformatted (long
calls/collections wrapped multiline, black-compatible style).

Run the JVM with `--enable-native-access=ALL-UNNAMED` so the foreign linker
may load the library without a restricted-method warning.

The library is resolved ONCE, lazily, the first time it's needed:
  1. RUFF_NATIVE_PATH env / `com.blockether.ruff.native.path` system property
     — an explicit path to the cdylib (used verbatim).
  2. A bundled classpath resource `prebuilds/<platform>/<lib>`, shipped by
     `com.blockether/ruff-native-<platform>` (extracted to the cache dir).
     This is the native-image path.
  3. A runtime download: the `ruff-native-<platform>` jar resolved through
     `clojure.tools.deps` (honouring Maven repos/mirrors/settings.xml),
     extracted + cached. Disable with RUFF_DISABLE_DOWNLOAD=1.

`<platform>` ∈ { linux-x64 linux-arm64 darwin-arm64 darwin-x64 windows-x64 }.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close