Skip to content

Commit

Permalink
Merge ecb9341 into 5001efe
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia committed Apr 30, 2023
2 parents 5001efe + ecb9341 commit 19c1fa7
Showing 1 changed file with 70 additions and 72 deletions.
142 changes: 70 additions & 72 deletions documentation/c05-packages.sil
@@ -1,33 +1,81 @@
\begin{document}
\chapter{SILE Packages}

SILE comes with a number of packages which provide additional functionality.
In fact, the actual “core” of SILE’s functionality is small and
extensible, with most of the interesting features being provided by add-on
packages. SILE packages are written in the Lua programming language, and can
define new commands, change the way that the SILE system operates, or indeed
do anything that is possible to do in Lua.

As mentioned above, loading a package is done through the \code{\\script} command,
which runs Lua code. By convention packages live in the \code{packages/} subdirectory
of either your input file’s location, your current working directory, or SILE’s
installation directory. For instance, we’ll soon be talking about the
\code{grid} package, which normally can be found as
\code{/usr/local/lib/sile/packages/grid/init.lua}. To load this, we’d say:
SILE comes with a number of standard packages which provide additional functionality.
In fact, the actual “core” of SILE’s functionality is small and extensible, with most of the interesting features being provided by add-on packages.
SILE packages are written in the Lua programming language, and can define new commands, change the way that the SILE system operates, or indeed do anything that is possible to do in Lua.

\section{Loading a package}

Loading a package is done through the \code{\\use} command.
By convention packages live in a \code{packages/}
For instance, we’ll soon be talking about the \autodoc:package{grid} package, which normally can be found as \code{/usr/local/lib/sile/packages/grid/init.lua}.
To load this, we’d say:

\begin[type=autodoc:codeblock]{raw}
\use[module=packages.grid]
\end{raw}

\autodoc:note{SILE searches for paths in a variety of
directories: first, in the directory in which your input file is located,
then the current working directory; next, if the environment variable
\code{SILE_PATH} is set, it will look in that directory; then it will look in
the standard installation directories \code{/usr/lib/sile} and
\code{/usr/local/lib/sile}. Unlike TeX, it does not descend into subdirectories
when looking for a file; if you have arranged your personal macro, class
or package files into subdirectories, you will need to provide a full relative
path to them.}
\autodoc:note{
By default SILE will look for packages in a variety of directories:

\begin{enumerate}
\item{The directory where your input source file is located.}
\item{The current working directory.}
\item{The environment variable \code{SILE_PATH}, if defined.}
\item{The default Lua search path.}
\item{The directories where SILE is installed on the system, \code{/usr/lib/sile} and
\code{/usr/local/lib/sile}.}
\end{enumerate}

SILE does not descend into subdirectories when looking for a file.
If you have arranged your personal class or package files into subdirectories,
you will need to provide a full relative path to them.}

\section{The SILE ecosystem}

The SILE installation includes a core collection of modules we hope are generally useful.
But there’s more out there!
As mentioned earlier in this manual, a number of third-party contributed collections of modules can be installed via the LuaRocks package manager.

\autodoc:note{
A non-authoritative list of third-party modules may be consulted at \url{https://luarocks.org/m/sile}. To publish your own modules to LuaRocks, see the \code{package-template.sile} repository.
}

A SILE compatible LuaRock simply installs the relevant class, package, language, internationalization resources, or similar files in a \code{sile} directory.
This directory could be in your system Lua directory, in your user directory, or any other location you specify.

By default, LuaRocks will install these modules to the Lua search path.

\begin[type=autodoc:codeblock]{raw}
$ luarocks install markdown.sile
$ sile ...
\end{raw}

Depending on your system, this probably requires root permissions.
If you either don’t have root permissions or don’t want to pollute your system’s root file system, you can also install as a user.
To use packages installed as a user you will need to have LuaRocks add its user tree to your Lua search path before running SILE.

\begin[type=autodoc:codeblock]{raw}
$ luarocks --local install markdown.sile
$ eval $(luarocks --local path)
$ sile ...
\end{raw}

Of course, you can add that eval statement to your shell profile to always include your user directory in your Lua path.
You can also add your own entries to the top of the search path list by setting the \code{SILE_PATH} variable. For example:

\begin[type=autodoc:codeblock]{raw}
$ export SILE_PATH="/path/to/my/library/"
$ sile ...
\end{raw}

Note that modules are not limited to just packages.
They can include classes, languages, internationalization resources, or anything else provided by SILE.\footnote{%
Also because external locations are searched before SILE itself, they can even override any core part of SILE itself.
As such you should probably make sure you review what a package does before installing it!}

\section{Standard packages}

\section{image}
\package-documentation{image}
Expand Down Expand Up @@ -200,54 +248,4 @@ basic functionality to other packages and classes. Classes such as the
\subsection{svg}
\package-documentation{svg}

\section{The package manager}

The SILE installation includes a core collection of packages we hope are generally useful.
But there’s more out there!
SILE can use packages installed via the LuaRocks package manager.
It can also be configured to read packages from any directory of your choosing.

A SILE compatible LuaRock simply installs the relevant class, package, language, internationalization resources, or similar files in a \code{sile} directory.
This directory could be in your system Lua directory, in your user directory, or any other location you specify.

By default SILE will look for packages in:

\begin{enumerate}
\item{The directory where the SILE source file is located.}
\item{The current working directory.}
\item{The default Lua search path.}
\item{The directory where SILE is installed on the system.}
\end{enumerate}

By default, LuaRocks will install packages to the Lua search path.

\begin[type=autodoc:codeblock]{raw}
$ luarocks install lilypond.sile
$ sile ...
\end{raw}

Depending on your system, this probably requires root permissions.
If you either don’t have root permissions or don’t want to pollute your system’s root file system, you can also install as a user.
To use packages installed as a user you will need to have LuaRocks add its user tree to your Lua search path before running SILE.

\begin[type=autodoc:codeblock]{raw}
$ luarocks --local install lilypond.sile
$ eval $(luarocks --local path)
$ sile ...
\end{raw}

Of course, you can add that eval statement to your shell profile to always include your user directory in your Lua path.
You can also add your own entries to the top of the search path list by setting the \code{SILE_PATH} variable. For example:

\begin[type=autodoc:codeblock]{raw}
$ export SILE_PATH="/path/to/my/library/"
$ sile ...
\end{raw}

To write a package and publish to LuaRocks, see the \code{package-template.sile} repository.

Packages are not limited to just the package interface.
They can include classes, languages, internationalization resources, or anything else provided by SILE.
Also because external locations are searched before SILE itself, they can even override any core part of SILE itself.
As such you should probably make sure you review what a package does before installing it!
\end{document}

0 comments on commit 19c1fa7

Please sign in to comment.