diff options
author | Karl Berry <karl@freefriends.org> | 2024-04-12 21:46:10 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-04-12 21:46:10 +0000 |
commit | 11d36f56f8f5115d58d3a97c78b8a8945383c5fb (patch) | |
tree | 7599d7502ff7f794234b065df54cae7150aa29cc /Master/texmf-dist/doc/lualatex | |
parent | e5759d48525423bdcb3c90b3fb73a2357740d18b (diff) |
gitinfo-lua (12apr24)
git-svn-id: svn://tug.org/texlive/trunk@70931 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/lualatex')
-rw-r--r-- | Master/texmf-dist/doc/lualatex/gitinfo-lua/README.md | 18 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua-init.lua | 7 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.pdf | bin | 116004 -> 122453 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex | 95 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/gitinfo-lua/latexmkrc | 5 |
5 files changed, 88 insertions, 37 deletions
diff --git a/Master/texmf-dist/doc/lualatex/gitinfo-lua/README.md b/Master/texmf-dist/doc/lualatex/gitinfo-lua/README.md index 463e764fa1c..702eb62fa76 100644 --- a/Master/texmf-dist/doc/lualatex/gitinfo-lua/README.md +++ b/Master/texmf-dist/doc/lualatex/gitinfo-lua/README.md @@ -5,19 +5,23 @@ A LaTeX package which provides macros integrated with LuaTeX and the commandline tool `git`. ## Installation -In order to install this package the right way, one should create the release tarball first with `make package`. -Afterward be sure to unpack the contents of the release tarball anywhere where TeX will find it, i.e. `~/texmf`. +The recommended way of installing is using `tlmgr install gitinfo-lua`. +If you can't update/install packages with `tlmgr`, you can download the latest `gitinfo-lua-<version>.tds.tar.gz` from the [releases page](https://github.com/Xerdi/gitinfo-lua/releases) and then unpack it in your `TEXMFHOME`. +To find out where your `TEXMFHOME` is, you can consult `kpsewhich --var-value TEXMFHOME` on the commandline. ## Documentation -The documentation can be built using `make` or manually using `lualatex`: +A prerequisite is that you have the [texmf-packaging](https://github.com/Xerdi/texmf-packaging) available in your `TEXMFHOME`. +The documentation can be built using `make build clean` or manually using `lualatex`: ```bash -make build clean -# Or manually +# Using the original TEXMFHOME and the project directory +CNF_LINE="TEXMFHOME={$(pwd),$(kpsewhich --var-value TEXMFHOME)}" cd doc -lualatex -shell-escape gitinfo-lua.tex +lualatex --lua=gitinfo-lua-init.lua --cnf-line $CNF_LINE gitinfo-lua makeindex -s gind.ist gitinfo-lua.idx -lualatex -shell-escape gitinfo-lua.tex +lualatex --lua=gitinfo-lua-init.lua --cnf-line $CNF_LINE gitinfo-lua ``` +To do the same as the Lua initialization script, commandline option `--shell-restricted` should be passed and `git` should be added to `shell_escape_commands` in your `texmf.cnf`. +The `texmf.cnf` file to edit can be found with `kpsewhich texmf.cnf`. See the [releases section](https://github.com/Xerdi/gitinfo-lua/releases) for getting the latest manual. diff --git a/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua-init.lua b/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua-init.lua new file mode 100644 index 00000000000..1877fbab12f --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua-init.lua @@ -0,0 +1,7 @@ +-- Global texconfig should already be available when executed with lualatex +local texconfig = texconfig or require('texconfig') + +-- Use restricted shell_escape with git as only command. +-- Add others where needed, separated with a comma (no spaces in between) +texconfig.shell_escape = 'p' +texconfig.shell_escape_commands = 'git' diff --git a/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.pdf b/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.pdf Binary files differindex 693b905da37..c3d56523153 100644 --- a/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.pdf +++ b/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.pdf diff --git a/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex b/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex index fe7bdd4e977..a865389e0cb 100644 --- a/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex +++ b/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex @@ -17,14 +17,20 @@ % gitinfo-cmd.lua and gitinfo-lua.lua \documentclass{ltxdoc} \usepackage[english]{babel} -\usepackage[titlepage,authors]{gitinfo-lua} +\usepackage[titlepage,authors,rootdir]{gitinfo-lua} \usepackage{listings} \lstset{ - basicstyle=\ttfamily, columns=fullflexible, + basicstyle=\ttfamily\lst@ifdisplaystyle\small\fi, + commentstyle={\slshape}, + showspaces=false, + showstringspaces=false, breaklines=true, - breakatwhitespace=false + breakatwhitespace=true, + breakindent=1em, + prebreak=\raisebox{0ex}[0ex][0ex] + { \ensuremath{_{\kern-2.2pt\hookleftarrow}}} } \usepackage{calc} \usepackage{multicol} @@ -59,7 +65,7 @@ \begin{abstract} This project aims to display git project information in PDF documents. - It's mostly written in Lua for executing the \texttt{git} commands, therefore making this package only applicable for \texttt{lualatex} with \texttt{shell escape} enabled. + It's mostly written in Lua for executing the \texttt{git} commands, therefore making this package only applicable for \texttt{lualatex}. If \texttt{lualatex} isn't working for you, you could try \href{https://ctan.org/pkg/gitinfo2}{gitinfo2} instead. For \LaTeX{} it provides a set of standard macros for displaying basic information or setting the project directory, and a set of advanced macros for formatting commits and tags. \end{abstract} @@ -100,8 +106,24 @@ lualatex -shell-escape main # Generate and keep watching with LaTeXMK latexmk -pvc -lualatex -shell-escape main \end{lstlisting} - Note that in both cases option \texttt{-shell-escape} is required. + Note that in both cases option \texttt{--shell-escape} is required. This is required for issuing \texttt{git} via the commandline. + If using \texttt{--shell-restricted} mode, which is the default, make sure to add \texttt{git} to the CSV variable \texttt{shell\_escape\_commands} in either your \texttt{texmf.cnf} or using a Lua initialization script, like: + \lstinputlisting[language={[5.3]Lua},caption={Lua initialization script},frame=single]{gitinfo-lua-init.lua} + + \noindent + The Lua initialization script can be used as follows: + \begin{lstlisting}[language=bash,frame=single,caption={With Lua initialization script},morekeywords=lualatex] +lualatex --lua=gitinfo-lua-init.lua main + \end{lstlisting} + For using the script with \texttt{latexmk}, this can be achieved with the \texttt{-lualatex="COMMAND"} option or specifying the \texttt{\$lualatex} command using a \texttt{latexmkrc} configuration file: + \begin{lstlisting}[language=bash,frame=single,caption={Overriding Lua\LaTeX\ on commandline},morekeywords=latexmk] +latexmk --lualatex --lualatex="lualatex --lua=gitinfo-lua-init.lua %O %S" main + \end{lstlisting} + \begin{lstlisting}[language=perl,frame=single,caption={Overriding Lua\LaTeX\ in \texttt{latexmkrc}}] +$lualatex = "lualatex --lua=gitinfo-lua-init.lua %O %S"; + \end{lstlisting} + Keep in mind that both the Lua initialization script and \texttt{latexmkrc} need to be placed within the same directory as the main file.\\ When utilizing the continuous compilation option \texttt{-pvc} with \texttt{latexmk}, it's important to note that only committed changes will be detected, while tag changes, unfortunately, won't be recognized. @@ -114,18 +136,22 @@ latexmk -pvc -lualatex -shell-escape main \texttt{\textbraceleft gitinfo-lua\textbraceright}\index[pkgopts]{gitinfo-lua(.sty)} This package provides some options for default formatting purposes. The author sorting is one of them. - If the options contain \meta{contrib} the authors will be sorted based on their contributions, otherwise the authors will be sorted alphabetically, which is the default option \meta{alpha}. - Another option is the \meta{titlepage} option, which sets the \cmd{\author} and \cmd{\date} macros accordingly. - By default, it sets the local git author, equivalent to option \meta{author}. - Pass option \meta{authors} to set all git authors of the project instead. + If the options contain \texttt{contrib} the authors will be sorted based on their contributions; otherwise, the authors will be sorted alphabetically, which is the default option \texttt{alpha}. + Another option is the \texttt{titlepage} option, which sets the \cmd{\author} and \cmd{\date} macros accordingly. + By default, it sets the local git author, equivalent to option \texttt{author}. + Pass the option \texttt{authors} to set all git authors of the project based on commit history instead. + + Another option, more concerning directory management, \texttt{rootdir}, sets the current working directory to the root directory of the current project for all \texttt{git} commands that are executed, similar to what \cmd{\gitdirectory} does. + If you're using recording of files, this option comes in handy when the main file is in a subdirectory of the project. + Otherwise, if the root directory isn't set appropriately, you'll receive the warning `\texttt{Warning: couldn't read HEAD from git project directory}'. \subsection{Basic macros}\label{sub:tex-basic} - By default the main file's directory is used as git project directory. + By default, the main file's directory is used as git project directory. This directory can be manipulated with \DescribeMacro{\gitdirectory}\cmd{\gitdirectory}\marg{path}. - This is only tested with relative paths on Linux. - \DescribeMacro{\gitunsetdirectory} To undo this operation and switch back to the main file's directory use \cmd{\gitunsetdirectory}.\\ + The foremost difference between using the \texttt{rootdir} option and the \cmd{gitdirectory} macro, is that the macro can specify a git directory which is part of another project. + The main reason for this macro to exist is its usage in the project example in section~\ref{sec:project}. + \DescribeMacro{\gitunsetdirectory} To undo an operation done with \cmd{\gitdirectory} and switch back to the main file's directory, use \cmd{\gitunsetdirectory}.\\ - \noindent \DescribeMacro{\gitversion} The current version can be display by using \cmd{\gitversion} and is equivalent to \texttt{git describe --tags --always}, working for both lightweight and annotated tags. For this project \cmd{\gitversion} results in \gitversion. When the version is dirty it will be post fixed with \texttt{-<commit count>-<short ref>}. @@ -140,10 +166,10 @@ latexmk -pvc -lualatex -shell-escape main These values are based on \texttt{git config user.name} and \texttt{git config user.email}. \subsection{Multiple Authors} - When projects having multiple authors this package can help with the \DescribeMacro{\dogitauthors}\break\cmd{\dogitauthors}\oarg{conj} and \DescribeMacro{\forgitauthors}\cmd{\forgitauthors}\oarg{conj}\marg{csname} macro. - Where \cmd{\dogitauthors} executes a default formatting implementation of \break\cmd{\git@format@author} and \cmd{\forgitauthors} executes the given \meta{csname} for every author available. + When projects having multiple authors, this package can help with the \DescribeMacro{\dogitauthors}\cmd{\dogitauthors}\oarg{conj} and \DescribeMacro{\forgitauthors}\cmd{\forgitauthors}\oarg{conj}\marg{csname} macro. + Where \cmd{\dogitauthors} executes a default formatting implementation of \cmd{\git@format@author} and \cmd{\forgitauthors} executes the given \meta{csname} for every author available. The optional \meta{conj} conjunction makes it possible to even integrate it further. - For example, when setting the authors in pdfx, the conjunction would be \texttt{[\textbackslash\textbackslash sep\textasciitilde]}, so that the authors are properly separated in the document properties\footnote{See package documentation of \texttt{pdfx}: \url{https://ctan.org/pkg/pdfx}}. + For example, when setting the authors in pdfx, the conjunction would be \texttt{[\textbackslash\textbackslash sep ]}, so that the authors are properly separated in the document properties\footnote{See package documentation of \texttt{pdfx}: \url{https://ctan.org/pkg/pdfx}}. \gitdirectory{../../git-test-project}% \setlength\xample{4.6cm-5pt}% @@ -175,12 +201,13 @@ latexmk -pvc -lualatex -shell-escape main For this section the git project of this document is used due to the fact that there are references to revisions. The test project's revisions change for every user, since they get recreated every time \texttt{test-scenario.sh} is executed (see section~\ref{sec:project}).\\ + \clearpage \noindent \DescribeMacro{\gitcommit}\oarg{format}\marg{csname}\marg{revision}\\ For displaying commit data \cmd{\gitcommit} can be used. The optional \texttt{format} takes variables separated by a comma. The default \texttt{format} is \texttt{h,an,ae,as,s,b}. - The \texttt{csname} is a user defined command accepting every variable as argument. + The \texttt{csname} is a user defined command accepting every variable as argument.\\ \setlength\xample{3.5cm}% \setlength\xamplesep{0pt}% \noindent% @@ -207,9 +234,13 @@ latexmk -pvc -lualatex -shell-escape main Consult \texttt{man git-log} for possible format variables and omit the \% for every variable.\\ \noindent - \DescribeMacro{\forgitcommit}\oarg{format}\marg{csname}\marg{rev\_spec}\\ + \DescribeMacro{\forgitcommit}\oarg{format}\marg{csname}\marg{rev\_spec, files=\{...\}, flags=\{...\}, cwd=...}\\ For displaying multiple commits the~\cmd{\forgitcommit} is used, which has the same arguments as \cmd{\gitcommit}, but only this time the \texttt{csname} is executed for every commit. - The last argument \texttt{rev\_spec} this time, however, can have no argument or a sequence. + The last argument, which originally only took a \texttt{rev\_spec}, now also supports some additional `named' arguments. + The argument \meta{files} takes a list of file names relative from the root of the git project. + When \meta{files} is given, all commits will be filtered out accordingly. + Currently, for \meta{flags}, only \texttt{merges} and \texttt{no-merges} are supported, which includes or excludes merge commits. + The \meta{cwd} option is like \cmd{\gitdirectory}, but only for this call. \noindent\setlength\xample{4.5cm}\setlength\xamplesep{0pt} \begin{minipage}[t]{\linewidth-\xample-\xamplesep} @@ -241,7 +272,7 @@ latexmk -pvc -lualatex -shell-escape main \end{minipage}\\ \gitdirectory{../../git-test-project} - \clearpage +% \clearpage \subsection{Tags} In this section the \texttt{git-test-project} is used. @@ -276,7 +307,7 @@ latexmk -pvc -lualatex -shell-escape main {formattags} \end{itemize} }} - \end{minipage}\\ + \end{minipage}\\[1em] This example shows that the versions used are mixed. This is, of course, a horrible way to manage a project's version, though, we'll continue on with this hard objective. For example, if we wish to display the author of the lightweight and annotated tag, we can do so by specifying a format using the if-then-else feature of the format specification. @@ -284,24 +315,27 @@ latexmk -pvc -lualatex -shell-escape main Here the \texttt{taggername} will show up, or if not present, the \texttt{authorname} will be shown instead. The default format specification is like the \cmd{\forgitcommit} format, but then again, some bit more complex:\\ - \texttt{refname:short,(taggername)(taggername,taggeremail,taggerdate:short)\\(authorname,authoremail,authordate:short),subject,body}. - This is a robust example of getting all information, being it a lightweight- or annotated tag.\\ + + \hfill\parbox{\linewidth-\parindent}{\texttt{refname:short,(taggername)(taggername,taggeremail,taggerdate:short)\\(authorname,authoremail,authordate:short),subject,body}}\\ + + \noindent + This is a robust example of getting all information, being it either a lightweight- or annotated tag.\\ For displaying commits in between tags, there's a \DescribeMacro{\forgittagseq}\cmd{\forgittagseq}\marg{csname}. The \meta{csname} takes exactly three arguments, namely, the \meta{current}, \meta{next tag} and \meta{rev spec}. - The last iteration gives an empty value for \meta{next tag} and the \meta{rev spec} is identical to \meta{current}. + The last iteration gives an empty value for \meta{next tag} and the \meta{rev spec} is identical to \meta{current}.\\ Afterward tag info can be fetched using the \DescribeMacro{\gittag} \cmd{\gittag}\oarg{format}\marg{csname}\marg{tag}. This macro takes the same formatting specification as \cmd{\fotgittag}. Beware of using \cmd{\gittag} for the \meta{next tag} parameter in \cmd{\forgittagseq}. All these macros put together are demonstrated in listing~\ref{lst:changelog} (see next page). - \clearpage +% \clearpage \subsection{Changelog} This example demonstrates the generation of a changelog. For simplicity’s sake, every tag is displayed in a \texttt{description} environment's item and within an \texttt{enumerate} environment displaying commits in between. \begin{lstlisting}[language={[LaTeX]TeX},numbers=left,captionpos=t,caption={Formatting a changelog},label={lst:changelog},morekeywords={commitline,formatversion,gittag,forgitcommit,forgittagseq,printdate}] -\section*{Changelog} +\section*{Change History} \newcommand{\commitline}[1]{\item #1} \newcommand{\formatversion}[3]{% \item[#1] @@ -330,23 +364,24 @@ latexmk -pvc -lualatex -shell-escape main \noindent \fbox{ \parbox{\linewidth-8pt-2\fboxsep}{ - {\bfseries\Large Changelog} + {\bfseries\Large Change History} \begin{description} \forgittagseq{formatversion}% \end{description} } - }\\ + }\\[1em] + \noindent For displaying the tagline (see line 5) we use the existing \cmd{\printdate} macro of package \texttt{isodate}, which also takes exactly one argument For every version sequence the commits in between are displayed (see line 7), where the last sequence having the initial commit as second argument plays well with the \cmd{\forgitcommit} macro and makes it possible to show the whole sequence of history. - \clearpage \section{Project Example}\label{sec:project} This documentation uses an example \texttt{project} which gets created by the \texttt{git-scenario.sh} script (see listing~\ref{lst:scenario}). It creates some commits having dates in the past and different authors set. Lastly it creates a `lightweight-' and `annotated' tag. - To set up this scenario either do \texttt{make scenario} or \texttt{bash scenario.sh}. + To set up this scenario either do \texttt{make scenario} or execute \texttt{bash git-scenario.sh} in an initialized \texttt{git} repository. + Keep in mind that when executing with Bash directly, you may need to specify the path to the Bash file. \lstinputlisting[language=bash,numbers=left,frame=single,label={lst:scenario},caption={git-scenario.sh},captionpos=t,morekeywords={git,alice,bob,charlie,mkdir,rm,curl,set\_author}]{git-scenario.sh} \end{document} diff --git a/Master/texmf-dist/doc/lualatex/gitinfo-lua/latexmkrc b/Master/texmf-dist/doc/lualatex/gitinfo-lua/latexmkrc new file mode 100644 index 00000000000..5683a8b2b13 --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/gitinfo-lua/latexmkrc @@ -0,0 +1,5 @@ +# Adds the gind.ist style, which is required +$makeindex = "makeindex %O -o %D -s gind.ist %S"; + +# Cleanup extra auxiliary files +push @generated_exts, "glo"; |