3

I'm starting to approach the problem of automated typesetting of git change logs, using biblatex and biber as a helping hand, and I'm having great difficulty understanding both what I'm doing and how to build biblatex controls nicely.

Here's what I've got so far. I'm sorry the MWE isn't a bit smaller; I almost gave myself a hernia getting down to this:

mwe111.tex:

\documentclass{article} 
\usepackage[%
    datamodel=gitlog,
    bibstyle=gitlog,
    sorting=none,
    date=iso8601,
    firstinits=true,
]{biblatex}
\addbibresource{mwe111.gll}
\begin{document}
\nocite{*}
\printbibliography[title={Change Log},type=gitcommit]
\end{document}

mwe111.gll:

@gitcommit{9dce109,
 author = {Brent Longborough},
 date = {2015-11-15},
 title = {Initial commit
},
 commithash = {9dce10970bb6be976ce59f76dd28e52abeb3b103} }
@gitcommit{f558cdd,
 author = {Brent Longborough},
 date = {2015-11-15},
 title = {First code to build pseudo-bibfile
},
 commithash = {f558cddc5a95acb1c081ead6f6e81cb9941941a0} }
@gitcommit{240f4c9,
 author = {Brent Longborough},
 date = {2015-11-15},
 title = {Added data model (not working) - now we step back a bit
},
 commithash = {240f4c9dbb22631f6098fbe45c409ef58cdddb09} }
@gitcommit{b4629f6,
 author = {Brent Longborough},
 date = {2015-11-16},
 title = {First working version full of restrictions
},
 commithash = {b4629f6bb7504b2d6e4a677294a761e1d1d5c659} }
@gitcommit{d651d24,
 author = {Brent Longborough},
 date = {2015-11-17},
 title = {Gradually improving things (especially understanding)
},
 commithash = {d651d249a3a14fd270a0f40e5d8124f6c552cc5b} }
@gitcommit{4c1dd2c,
 author = {Brent Longborough},
 date = {2015-11-17},
 title = {Making an MWE for TeX.SX
},
 commithash = {4c1dd2c540ff8a2f2976d972d15071c1f54f9379} }

gitlog.dbx:

\DeclareDatamodelEntrytypes{gitcommit}
\DeclareDatamodelFields[type=field,datatype=literal]{
  title,
  commithash
}
\DeclareDatamodelFields[type=field,datatype=name]{
  author
}
\DeclareDatamodelFields[type=field, datatype=date]{
  date
}
\DeclareDatamodelEntryfields[gitcommit]{
  title,
  author,
  date,
  commithash
}

gitlog.bbx:

\ProvidesFile{gitlog.bbx}
[\abx@bbxid]

\defbibenvironment{bibliography}
  {\list
     {\printfield{entrykey}}
     {\setlength{\labelwidth}{0pt}%
      \setlength{\itemindent}{-\leftmargin}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{%
    \hspace\labelsep\ttfamily##1}}}
  {\endlist}
  {\item}

\newbibmacro*{begentry}{}
\newbibmacro*{finentry}{\finentry}

\DeclareBibliographyDriver{gitcommit}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{title}%
  \newblock%
  \usebibmacro{author}%
  \newunit
  \usebibmacro{date}%
  \newunit
  \usebibmacro{commithash}
  \usebibmacro{finentry}}

\newbibmacro*{commithash}{%
    \printtext{%
       \printfield{commithash}%
}}

\endinput

Now, so far this sort of works (the typography is awful, but that's not the important problem at this stage), except that the "commithash" field is not printed:

git changelog - typeset output

Obviously I must have missed out something important, but have no idea what it is. Can anyone help?

  • Related (but of course not specific to the problem here) How can I create entirely new data types with BibLaTeX/Biber?. – moewe Nov 17 '15 at 18:52
  • @moewe Yes, thanks, I had seen that, but had a great deal of difficulty understanding the answer (my fault, not yours! -- the example itself had complex requirements). – Brent.Longborough Nov 17 '15 at 19:00
  • I added the link more for the "linked questions"/related feature than to solve the problem here. I didn't actually know that the csv list thingy was that sensitive when I wrote the answer. Plus a great deal there is about getting date fields right as well as localisation features. If you can put your finger on a specific point where the answer could be more understandable or precise I would appreciate a pointer. – moewe Nov 17 '15 at 19:09
  • @moewe : No, thank you, I appreciate that. My real problem was (will be) getting to grips with the different layers of bibliography entry formatting. I'm sure there'll be more questions later! – Brent.Longborough Nov 17 '15 at 19:22

1 Answers1

3

It seems that biblatex/Biber are a bit sensitive to space and punctuation in \DeclareDatamodelFields. The biblatex documentation warns in the explanation to \DeclareDatamodelFields (p. 160)

As usual in TeX csv lists, make sure each element is immediately followed by a comma or the closing brace—no extraneous whitespace.

If I add a comma after the field names everything works just as expected.

You will find that there is no need to declare standard fields such as date, title and author, those are already there.

A working gitlog.dbx could be

\DeclareDatamodelEntrytypes{gitcommit}
\DeclareDatamodelFields[type=field,datatype=literal]{
  commithash,
}
\DeclareDatamodelEntryfields[gitcommit]{
  title,
  author,
  date,
  commithash,
}
moewe
  • 175,683