euporie.core.format

Contain functions to automatically format code cell input.

Functions

abstractmethod(funcobj)

A decorator indicating abstract methods.

command_exists(*cmds)

Verify a list of external commands exist on the system.

range_to_slice(start_line, start_char, ...)

Convert a line/character ranger to a slice.

Classes

ABCMeta(name, bases, namespace, /, **kwargs)

Metaclass for defining Abstract Base Classes (ABCs).

CliFormatter(command[, languages])

Format using an external command.

Formatter([languages])

Text formatter class which reformats text.

LspFormatter(lsp, path[, languages])

Format a document using a LSP server.

class euporie.core.format.CliFormatter(command: list[str], languages: set[str] | None = None)

Bases: Formatter

Format using an external command.

format(text: str) str

Pass the text to the command over stdin and return the output.

class euporie.core.format.Formatter(languages: set[str] | None = None)

Bases: object

Text formatter class which reformats text.

abstract format(text: str) str

Format the string.

class euporie.core.format.LspFormatter(lsp: LspClient, path: Path, languages: set[str] | None = None)

Bases: Formatter

Format a document using a LSP server.

format(text: str) str

Format the url with the LSP.

The LSP already knows the contents of the file, which is why we do not pass the text to the formatting function.