rst2typst.package module

Typst package helper.

Note

In this module, “Package” means Typst package.

This module provides two features.

  • Package registry to manage packages and to render import statements.

  • Helper functions to install files as local package.

class rst2typst.package.Entrypoint(name: str, alias: str | None = None)

Bases: object

Importing target and alias of package.

alias: str | None = None
property code: str

As Typst code.

name: str
class rst2typst.package.PackageRegistry(*args, **kwargs)

Bases: dict[str, set[Entrypoint]]

Package management store.

add(name: str, entrypoint: str | tuple[str, str] | Entrypoint | None = None)

Add package path and entrypoints.

property code: str

As Typst code.

rst2typst.package.build_install_path(name: str, version: str | None = None) Path

Retrieve path object of package Typst local package.

If version is not specified, name is treated as the name of a published Python package, and the installed version is used.

Parameters:
  • name – Package name

  • version – Version of package.

rst2typst.package.install_package(source: Path, name: str, version: str | None = None, *, force: bool = False)

Copy package directory as Typst local package.

Ref

param source:

Source directory of Typst package.

param name:

The name of local package.

param version:

The version of local package.

param force:

Flag to override package.