Debian Codegraph @

texmf-dist/doc/latex/gitlog/gitlog.tex

raw
1 % gitlog.tex
2 % Copyright 2015 Brent Longborough
3 %
4 % This work may be distributed and/or modified under the
5 % conditions of the LaTeX Project Public License, either version 1.3
6 % of this license or (at your option) any later version.
7 % The latest version of this license is in
8 % http://www.latex-project.org/lppl.txt
9 % and version 1.3 or later is part of all distributions of LaTeX
10 % version 2005/12/01 or later.
11 %
12 % This work has the LPPL maintenance status `maintained'.
13 % The Current Maintainer of this work is Brent Longborough.
14 % -----------------------------------------------------
15 \documentclass[a4paper,12pt,twoside,openany]{memoir}
16 % =====================================================
17 \usepackage[british]{babel}
18 \selectlanguage{british}
19 \usepackage[style=iso]{datetime2}
20 \usepackage[local,pcount,grumpy,markifdirty]{gitinfo2}
21 \usepackage{tgpagella}
22 \usepackage{tgadventor}
23 \usepackage{fontspec}
24 \setmainfont[Numbers={Proportional,OldStyle},Ligatures=TeX]{TeX Gyre Pagella}
25 \setsansfont[Numbers={Proportional,OldStyle},Ligatures=TeX]{TeX Gyre Adventor}
26 \setmonofont{Consolas}
27 \usepackage{enumitem}
28 \setlist[description]{%
29 format=\ttfamily\bfseries,
30 style=nextline,
31 leftmargin=3em,
32 itemsep=0.5\onelineskip}
33 \setulmarginsandblock{0.11111\paperwidth}{0.22222\paperwidth}{*}
34 \setlrmarginsandblock{0.11111\paperwidth}{0.22222\paperwidth}{*}
35 \setheadfoot{1.2\baselineskip}{0.0849\paperwidth}
36 \setmarginnotes{0.125\foremargin}{0.75\foremargin}{\onelineskip}
37 \setheaderspaces{*}{*}{0.618}
38 \checkandfixthelayout[fixed]
39 % \makepagenote
40 % \continuousnotenums
41 % \notepageref
42 % \foottopagenote
43 % \renewcommand*{\printpageinnotes}[1]{%
44 % (p.\pageref{#1})\space}
45 % \renewcommand\printpageinnoteshyperref[1]{%
46 % (p.\pageref*{#1})\space}
47 % \renewcommand*{\pagenotesubhead}[3]{%
48 % \subsubsection*{#1: #3}}
49 \tightlists
50 \chapterstyle{bringhurst}
51 \pagestyle{empty}
52 \aliaspagestyle{chapter}{empty}
53 \settocdepth{subsection}
54 \setsecnumdepth{none}
55 \newcommand{\bpara}[1]{\par\vspace{\beforeparaskip}\noindent\textbf{#1}\,}
56 \newcommand{\rpara}[1]{\par\noindent\textbf{#1}\,}
57 \newcommand{\tcmd}[1]{\texttt{\textbackslash#1}}
58 \newcommand{\dark}[1]{\texttt\textbf{{#1}}}
59 \newcommand{\sfit}[1]{\textit{#1}}
60 \newcommand{\git}{\sfit{git}}
61 \newcommand*{\emailat}{@}
62 \newcommand{\tpname}{\sfit{gitlog}}
63 \newcommand{\tpfname}{\textsf{gitlog.sty}}
64 % -----------------------------------------------------
65 \usepackage[%
66 bookmarksnumbered,
67 bookmarksopen,
68 linktocpage,
69 ]{hyperref}
70 \hypersetup{
71 pdfauthor={Brent Longborough},
72 pdftitle={The gitlog package: git change logs for LaTeX},
73 pdfkeywords={git;changelog;dvcs},
74 }
75 \usepackage[%
76 write,
77 bibfile=gitlog.sample.bib,
78 github=Hightor/gitlog,
79 title={Sample Git Change Log},
80 ]{gitlog}
81 \begin{document}
82 \frontmatter
83 % -----------------------------------------------------
84 \title{%
85 ~\\[2\baselineskip]
86 \Huge \tpfname\\[2ex]%
87 \Large A proof of concept for automatic typesetting \\of change logs from the \git\ \textsc{dvcs}
88 }
89 \author{Brent Longborough}
90 \date{\DTMenglishmonthname{\DTMfetchmonth{gitdate}} \DTMfetchyear{gitdate}}
91 \maketitle
92
93 {\centering
94 Release:\gitRels\ (\gitAbbrevHash)\\
95 }
96 % -----------------------------------------------------
97 \thispagestyle{empty}
98 \aliaspagestyle{chapter}{plain}
99 \clearforchapter
100 \tableofcontents*
101 % -----------------------------------------------------
102 \mainmatter
103 \pagestyle{giruled}
104 \aliaspagestyle{chapter}{giplain}
105 \chapter{Introduction}
106 The \git{} distributed version control system
107 maintains an historical log of update activity.
108 The \tpname{} package provides a way automatically
109 to typeset such a log, optionally linking commits
110 from the typeset log
111 to one of the online \textsc{dvcs} hosting services.
112
113 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
114 \section{Limitations}
115
116 The current release (\gitRel)
117 is intended only as a \emph{proof-of-concept},
118 and should not be used for production-level work
119 unless you're happy with these limitations:
120 \begin{itemize}
121 \item Formatting maliciously-coded documents
122 \textbf{\emph{can cause arbitrary files to be overwritten.}}
123 Although this problem is easy to avoid
124 (and requires the \sfit{--shell-escape} command line option),
125 there are no built-in protections.
126 \item The \git\ change log is built and formatted using the
127 facilities of \sfit{biblatex} and \sfit{biber}.
128 The way this is currently implemented makes it unlikely that
129 documents using \tpname\ can contain `normal' bibliographies.
130 \item New lines in the \git\ change log commit messages are
131 simply converted to spaces.
132 The result is pretty ugly,
133 unless you've had the foresight
134 to punctuate your commit messages nicely.
135 \end{itemize}
136
137 \noindent
138 That said, I think \tpname\ will still be useful to a subset of \TeX\ users,
139 and I welcome suggestions and contributed code via email or Github, where the url is
140 \url{https://github.com/Hightor/gitlog/issues}.
141
142
143 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
144 \section{How \tpname\ works}
145 \begin{enumerate}
146 \item The package uses a git command internally, via the \tcmd{write18} command,
147 to write out the change log in the shape of a rather strange
148 \sfit{.bib} file
149
150 \item The change log .bib file contains a series of items of type \sfit{gitcommit},
151 defined and formatted by the \tpname\
152 data model and bibliography styles which accompany the package.
153
154 \item The rest of the work is done by persuading \sfit{biblatex} and \sfit{biber}
155 to treat this data as a bibliography.
156
157 \item Optionally, you can generate your own `change log bibliography',
158 using this command (joined up into a single line):\\[\baselineskip]
159 {\ttfamily
160 git --no-pager log --reverse --date=short\\
161 --pretty="format:@gitcommit\{\%h,\%n author = \{\%an\},\%n\\
162 date = \{\%ad\}, \%n title = \{\%B\}, \%n commithash = \{\%H\}\\
163 \}" > \textit{filename}
164 }
165
166 \end{enumerate}
167
168 % -----------------------------------------------------
169 \chapter{Using the package}
170 \label{ch:using}
171 To collect and typeset \git{} history,
172 you load the \tpname\ package in the usual way:\\[0.5\baselineskip]
173 \texttt{\textbackslash usepackage[$<options>$]\{gitlog\}}
174
175 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
176 \section{Package options}
177
178 The following options are available:
179
180 \subsection{General options}
181
182 \begin{description}
183
184 \item[\texttt{title=\textit{log title}}]
185 This option allows you to change the chapter title associated with
186 the typeset change log.
187 The default is `Change Log'.
188
189 \item[\texttt{date}, \texttt{nodate}]
190 These complementary options
191 allow you to specify whether or not you want
192 the author date and name to be added to the change log.
193 The default is \texttt{nodate}.
194
195
196 \end{description}
197
198 \subsection{Options for controlling the .bib file}
199
200 \begin{description}
201
202 \item[\texttt{write}, \texttt{nowrite}]
203 These complementary options
204 allow you to specify whether or not you want
205 \tpname\ to generate the special change log (\sfit{.bib})
206 for you.
207
208 If you specify \texttt{write}, then \tpname\ will regenerate the
209 change log every time the document is formatted.
210 Note that this option is implemented with the \tcmd{write18} command,
211 and requires that your document be processed with the \TeX option
212 \texttt{--shell-escape}.
213
214 If you specify \texttt{nowrite}, then \tpname\ will not write anything,
215 and the \texttt{--shell-escape} option is not required.
216 However, in this case,
217 you are responsible for generating the change log
218 in the correct format for \tpname\ to use,
219 as well as being able to hand-tailor it.
220
221 If neither option is specified, the default depends on whether or not
222 you use the \sfit{bibfile} option, described next.
223
224 \clearpage
225 \item[\texttt{bibfile=\textit{filename}}]
226 The \git\ change log data is kept in
227 a file in \sfit{biblatex .bib} format,
228 which \tpname\ writes (if requested) and then reads
229 to format the change log.
230
231 If this option is not specified, then a default filename
232 is used:
233 \textit{<jobname>}\texttt{.gitlog.bib}.
234 In this case, the default option \sfit{write} is used,
235 but can be suppressed by specifying \texttt{nowrite}.
236
237 This can be overridden by specifying your own choice
238 of filename using this option.
239 In this case, the default option \sfit{nowrite} is used,
240 but you can force \tpname\ to write to your file
241 by specifying \texttt{write}.
242
243 \dark{Warning:} there is \emph{no} protection against writing
244 to any file name whatsoever.
245 The default settings are reasonably `safe';
246 where you need to ship the document without its repository,
247 then
248 \begin{quote}
249 {\ttfamily
250 [write,bibfile=\jobname.local.bib]
251 }
252 \end{quote}
253 is probably a safe set of options to use.
254
255 \end{description}
256
257 \subsection{Options for linking to on-line services}
258
259 The change log typeset by \tpname\ can include links
260 connecting each commit to its corresponding page
261 in either the GitHub or the Atlassian Bitbucket
262 online repository services.
263 (Trade marks of their respective owners.)
264
265 To use this feature, you must load the \sfit{hyperref} package
266 before loading \tpname, and use one of the following,
267 mutually exclusive, options.
268
269 \begin{description}
270
271 \item[\texttt{github=\textit{repository-path}}]
272 When each commit in the changelog is typeset,
273 a link is generated to the corresponding page on GitHub,
274 with a \textsc{url} in this format:
275 \begin{quote}
276 {\ttfamily\small
277 https://github.com/{\rmfamily\itshape repository-path}/commit/{\rmfamily\itshape commit-hash}
278 }
279 \end{quote}
280
281 \item[\texttt{bitbucket=\textit{repository-path}}]
282 When each commit in the changelog is typeset,
283 a link is generated to the corresponding page on Atlassian Bitbucket,
284 with a \textsc{url} in this format:
285 \begin{quote}
286 {\ttfamily\small
287 https://bitbucket.org/{\rmfamily\itshape repository-path}/commits/{\rmfamily\itshape commit-hash}
288 }
289 \end{quote}
290
291 \end{description}
292
293 \section{Typesetting the change log}
294
295 The command \tcmd{printGitLog}
296 typesets the change log, as a new chapter containing a pseudo-bibliography,
297 at that point in the document.
298 At the moment, there are very few options to allow you to tailor the typography.
299
300 A sample change log can be seen at the end of this manual.
301
302 % -----------------------------------------------------
303 \chapter{Etc}
304 \section{Release notes}
305
306 \rpara{R0.0.beta: 2015-11-24}
307 Initial beta release
308
309 \section{Acknowledgements}
310
311 The \href{http://tex.stackexchange.com}{\TeX.SE community}
312 has been a constant source of help, inspiration, and amazement.
313
314 I'd also like to register my thanks to the owners of the packages and tools
315 on which \tpname\ depends:
316 biblatex, etoolbox, hyperref, and kvoptions,
317 and also to
318 \href{http://tex.stackexchange.com/users/35864/moewe}{moewe at \TeX.SE} for
319 invaluable help during my ongoing stumblings with \sfit{biblatex}.
320
321 We all depend heavily on the constant hard work
322 so unstintingly given to the community by the Guardians of CTAN.
323 Thank you all.
324
325 The failings, of course, I claim for myself.
326
327 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
328 \section{Copyright \& licence}
329 Copyright \copyright\ \DTMfetchyear{gitdate}, Brent Longborough,
330 who has asserted his moral right
331 to be identified as the author of this work.
332
333 This work --- \tpname\ --- may be distributed and/or modified under the
334 conditions of the LaTeX Project Public License: either version 1.3
335 of this license, or (at your option) any later version.
336
337 The latest version of this license can be found
338 at the \LaTeX\ Project website,%
339 \footnote{(\url{http://www.latex-project.org/lppl.txt})}
340 and version 1.3 or later is part of all recent distributions of
341 \LaTeX.
342
343 This work has the LPPL maintenance status `maintained';
344 the Current Maintainer of this work is Brent Longborough.
345
346 % This work consists of the files
347 % gitlog.sty, gitlog.bbx, gitlog.dbx,
348 % gitlog.tex, gitlog.sample.bib, gitHeadLocal.gin,
349 % gitlog.pdf, and README.md
350
351 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
352 \section{From the author}
353 Although my limitations as a \TeX nician
354 mean that I'm going to need a lot of expert help
355 to turn \tpname\ into a delightful author experience,
356 I hope you find the package useful and the concept interesting.
357 I'll be very happy to receive your comments by email.\\[\baselineskip]
358 Brent Longborough\\[\baselineskip]
359 \textsf{brent+ctancontrib (bei) longborough (punkt) org}\\
360 and at \href{http://tex.stackexchange.com/users/344/brent-longborough}{\TeX.SE}
361 % -----------------------------------------------------
362 \printGitLog
363 % -----------------------------------------------------
364 \end{document}