Skip to content

API Reference

This section provides complete API documentation for jettex.

Module Overview

jettex is organized into the following modules:

Module Description
jettex Main module with all public exports
jettex.install TinyTeX installation and management
jettex.compile LaTeX compilation functions
jettex.tlmgr TeX Live package manager wrapper
jettex.packages Automatic package detection and installation
jettex.console Rich console output and logging
jettex.utils Utility functions

Quick Reference

Installation Functions

import jettex

# Install TinyTeX
jettex.install_tinytex(version=1, install_dir=None, force=False)

# Uninstall TinyTeX
jettex.uninstall_tinytex()

# Check installation
jettex.is_tinytex_installed() -> bool
jettex.tinytex_root() -> Path | None
jettex.tinytex_version() -> str | None

Compilation Functions

# Compile with auto-install (recommended)
jettex.compile_tex(input_file, engine="pdflatex", max_attempts=3) -> CompileResult

# Direct compilation
jettex.pdflatex(input_file, **options) -> CompileResult
jettex.xelatex(input_file, **options) -> CompileResult
jettex.lualatex(input_file, **options) -> CompileResult
jettex.latexmk(input_file, **options) -> CompileResult

# Clean auxiliary files
jettex.clean_auxiliary(input_file) -> int

Package Management

# Install/remove packages
jettex.tlmgr_install(packages: list[str]) -> bool
jettex.tlmgr_remove(packages: list[str]) -> bool

# Update packages
jettex.tlmgr_update(packages=None, all_packages=False, self_update=False) -> bool

# Search/list packages
jettex.tlmgr_list() -> list[str]
jettex.tlmgr_search(query, file_search=False) -> list[dict]
jettex.tlmgr_info(package) -> dict | None

# Find package for file
jettex.find_package_for_file(filename) -> str | None

Utility Functions

# PATH management
jettex.ensure_tinytex_in_path() -> bool
jettex.get_bin_dir() -> Path | None
jettex.get_executable(name) -> Path | None

Data Classes

CompileResult

from jettex import CompileResult

@dataclass
class CompileResult:
    success: bool              # Whether compilation succeeded
    output_file: Path | None   # Path to output PDF
    log_file: Path | None      # Path to log file
    stdout: str                # Standard output
    stderr: str                # Standard error
    returncode: int            # Process return code

PackageInfo

from jettex import PackageInfo

@dataclass
class PackageInfo:
    filename: str              # Missing file name
    package: str | None        # Package that provides it
    error_message: str         # Original error message

Logging and Console

from jettex import Verbosity, setup_logging, get_logger

# Configure logging verbosity
setup_logging(Verbosity.VERBOSE)  # QUIET, NORMAL, or VERBOSE
setup_logging(Verbosity.NORMAL, log_file=Path("debug.log"))

# Get logger for custom logging
logger = get_logger()
logger.debug("Custom debug message")

Constants

jettex.__version__  # Package version string