From 34c067e34cfb9860eb6df926735b5c6b4043839b Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Tue, 21 Sep 2021 21:34:55 +0200 Subject: [PATCH] Add generating declarations for contributions --- {{cookiecutter.paper_repo_name}}/.gitignore | 4 + {{cookiecutter.paper_repo_name}}/Makefile | 16 +++- .../bibliography.bib | 10 +++ .../contributions.yaml | 7 +- .../helpers/contribution-declaration.tex.tmpl | 88 +++++++++++++++++++ .../generate-contribution-declaration.py | 35 ++++++++ 6 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 {{cookiecutter.paper_repo_name}}/helpers/contribution-declaration.tex.tmpl create mode 100755 {{cookiecutter.paper_repo_name}}/helpers/generate-contribution-declaration.py diff --git a/{{cookiecutter.paper_repo_name}}/.gitignore b/{{cookiecutter.paper_repo_name}}/.gitignore index be825dc..00e9b2a 100644 --- a/{{cookiecutter.paper_repo_name}}/.gitignore +++ b/{{cookiecutter.paper_repo_name}}/.gitignore @@ -147,6 +147,8 @@ vcs.xml *.ft *.tdo *.bcf +*.vrb +*.snm *.lol *.run.xml /auto @@ -160,3 +162,5 @@ the-appendix.pdf sentences.txt arxiv-{{cookiecutter.paper_id}}.pdf arxiv-{{cookiecutter.paper_id}}.tar.gz +helpers/*-contribution-declaration.tex +helpers/*-contribution-declaration.pdf diff --git a/{{cookiecutter.paper_repo_name}}/Makefile b/{{cookiecutter.paper_repo_name}}/Makefile index d25c22e..70d3809 100644 --- a/{{cookiecutter.paper_repo_name}}/Makefile +++ b/{{cookiecutter.paper_repo_name}}/Makefile @@ -35,12 +35,12 @@ endif CONTENT_TEX_SOURCES_WITH_DIR := $(addprefix $(CURRENT_DIR)/, $(CONTENT_TEX_SOURCES)) SCOREFILES=$(shell perl extract-score-files.pl $(CONTENT_TEX_SOURCES)) -clean_latex_stuff=rm -rf *.aux *.nav *.toc *.log *.out *.blg *.bbl autozoil-log.txt autozoil.xml the-appendix.pdf supplement.zip $(PAPER_ID).pdf $(PAPER_ID).zip arxiv-$(PAPER_ID).pdf arxiv-$(PAPER_ID).tar.gz abstract.txt sentences.txt stats.txt $(EXTRA_PDFS) +clean_latex_stuff=rm -rf *.aux *.nav *.toc *.log *.out *.blg *.bbl autozoil-log.txt autozoil.xml the-appendix.pdf supplement.zip $(PAPER_ID).pdf $(PAPER_ID).zip arxiv-$(PAPER_ID).pdf arxiv-$(PAPER_ID).tar.gz abstract.txt sentences.txt stats.txt $(EXTRA_PDFS) helpers/$(PAPER_ID)-contribution-declaration.tex helpers/$(PAPER_ID)-contribution-declaration.pdf helpers/*.aux helpers/*.bbl helpers/*.bcf helpers/*.blg helpers/*.log helpers/*.run.xml ifeq ($(HAS_SUPPLEMENT),yes) -all: $(PAPER_ID).pdf abstract.txt supplement.zip stats.txt sentences.txt +all: $(PAPER_ID).pdf abstract.txt supplement.zip stats.txt sentences.txt helpers/$(PAPER_ID)-contribution-declaration.pdf else -all: $(PAPER_ID).pdf abstract.txt stats.txt sentences.txt +all: $(PAPER_ID).pdf abstract.txt stats.txt sentences.txt helpers/$(PAPER_ID)-contribution-declaration.pdf endif source-pack: $(PAPER_ID).zip @@ -104,5 +104,15 @@ titlepage.pdf: titlepage.tex xelatex $< endif + +helpers/$(PAPER_ID)-contribution-declaration.pdf: helpers/$(PAPER_ID)-contribution-declaration.tex + (cd helpers && pdflatex $(PAPER_ID)-contribution-declaration.tex) + (cd helpers && biber $(PAPER_ID)-contribution-declaration) + (cd helpers && pdflatex $(PAPER_ID)-contribution-declaration.tex) + +helpers/$(PAPER_ID)-contribution-declaration.tex: contributions.yaml helpers/contribution-declaration.tex.tmpl helpers/generate-contribution-declaration.py + (cd helpers && ./generate-contribution-declaration.py) < $< > $@ + + clean: $(clean_latex_stuff) diff --git a/{{cookiecutter.paper_repo_name}}/bibliography.bib b/{{cookiecutter.paper_repo_name}}/bibliography.bib index 02168c4..d61c26b 100644 --- a/{{cookiecutter.paper_repo_name}}/bibliography.bib +++ b/{{cookiecutter.paper_repo_name}}/bibliography.bib @@ -1,3 +1,13 @@ + +% here the bibliographic entry for the paper itself should be given, +% used for generating declarations + +@InProceedings{this-paper, +author="{{cookiecutter.paper_title}}", +title="{{cookiecutter.main_contributor_name}}", +year=2021 +} + {% raw %} @inproceedings{gralinski-etal-2019-geval, diff --git a/{{cookiecutter.paper_repo_name}}/contributions.yaml b/{{cookiecutter.paper_repo_name}}/contributions.yaml index a9ca59c..8876c45 100644 --- a/{{cookiecutter.paper_repo_name}}/contributions.yaml +++ b/{{cookiecutter.paper_repo_name}}/contributions.yaml @@ -3,10 +3,15 @@ title: {{cookiecutter.paper_title}} authors: - - author: Jan Iksinski + - author: {{cookiecutter.main_contributor_name}} + level: 1 contributions: - did this - did that - author: Józef Igrekowski + level: 1 + contributions: + - did something else + - author: Adam Abacki contributions: - did something else diff --git a/{{cookiecutter.paper_repo_name}}/helpers/contribution-declaration.tex.tmpl b/{{cookiecutter.paper_repo_name}}/helpers/contribution-declaration.tex.tmpl new file mode 100644 index 0000000..e475086 --- /dev/null +++ b/{{cookiecutter.paper_repo_name}}/helpers/contribution-declaration.tex.tmpl @@ -0,0 +1,88 @@ +{% raw %} +\documentclass[a4paper]{article} +\usepackage{booktabs} +\usepackage{bibentry} +%\usepackage[style=verbose]{biblatex} +\usepackage[total={170mm,277mm}, left=20mm, top=10mm]{geometry} +\thispagestyle{empty} +\renewcommand{\labelitemi}{--} +\usepackage{tabularx} +\usepackage{longtable} + +\usepackage[backend=biber,maxnames=12]{biblatex} +\bibliography{../bibliography.bib} + + +\begin{document} + +\begin{flushright} + {{tday}} +\end{flushright} + +\medskip + +\begin{center} + {\bf Declaration} +\end{center} + +\bigskip + +I hereby declare that the contribution to the following paper: + +\smallskip + +\fullcite{this-paper} + +\smallskip + +\noindent is correctly characterized in the table below{% if nb_of_levels == 0 %}.{% elif nb_of_levels == 1 %} ({{ level_symbols[0] }} denotes equal contributions).{% else %} ({% for lix in range(nb_of_levels) %}{% if lix == nb_of_levels - 1 %}{} and {{ level_symbols[lix] }}{} denote groups of equal contributions).{% elif lix == 0 %}{{ level_symbols[lix] }}{% else %}, {{ level_symbols[lix] }}{% endif %}{% endfor %}{% endif %} +\medskip + + + +\begin{center} +\begin{longtable}{lc} +\toprule +\addlinespace[0.05cm] +Contributor & Description of main tasks \\ +\addlinespace[0.05cm] +\midrule +\addlinespace[0.1cm] +{% for author in data['authors'] %} +{{ author['author'] }}{% if 'level' in author %}{{level_symbols[author['level']-1]}}{% endif %} +& +\begin{minipage} [t] {0.6\textwidth} +\begin{itemize} +\itemsep=0em +{% for citem in author['contributions'] %} +\item {{citem}} +{% endfor %} +\end{itemize} +\end{minipage} \\ +{% if loop.index == loop.length %} +\addlinespace[0.25cm] +{% else %} +\addlinespace[0.5cm] +{% endif %} +{% endfor %} +\bottomrule +\end{longtable} +\end{center} + +\vskip 0.8cm + +\begin{tabularx}{\textwidth}{XXXX} +{% for author in data['authors'] %} +{{ author['author'] }} +{% if loop.index == loop.length %} +\\ +{% elif loop.index % 4 == 0 %} +\\ \addlinespace[0.5cm] +{% else %} +& +{% endif %} +{% endfor %} +\end{tabularx} + +\end{document} +{% endraw %} diff --git a/{{cookiecutter.paper_repo_name}}/helpers/generate-contribution-declaration.py b/{{cookiecutter.paper_repo_name}}/helpers/generate-contribution-declaration.py new file mode 100755 index 0000000..33a9457 --- /dev/null +++ b/{{cookiecutter.paper_repo_name}}/helpers/generate-contribution-declaration.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import yaml +import sys +import os +import datetime + + +from jinja2 import FileSystemLoader, Environment, PackageLoader, select_autoescape +env = Environment( + loader=FileSystemLoader(os.path.abspath('.')), + autoescape=select_autoescape() +) + + +contributions = yaml.safe_load(sys.stdin) + + +tday = datetime.date.today() +ftday = tday.strftime('%B %d, %Y') + +level_symbols = [ + '*', + '\\dag', + '\\ddag', + '\\S', + '\\P', + '\\#'] + +nb_of_levels = len(set((c['level'] for c in contributions['authors'] if 'level' in c))) + + +template = env.get_template("contribution-declaration.tex.tmpl") + +print(template.render(tday=ftday, data=contributions, level_symbols=level_symbols, nb_of_levels=nb_of_levels))