Merge pull request #78 from benjamin-weiss/build-system-improvements

Build system improvements
This commit is contained in:
Matthias Vogelgesang 2015-06-15 16:21:10 +02:00
commit bf753b4db8
8 changed files with 103 additions and 72 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
demo.pdf
mtheme.pdf
login.json
*.fls
*.acn

View File

@ -1,14 +1,17 @@
INS = mtheme.ins
CONTRIB_SRC = contributors.py
CONTRIB_TEX = contributors.tex
DTX = $(wildcard *.dtx)
STY = $(patsubst %.dtx,%.sty,$(wildcard beamer*.dtx))
TEXMFHOME = $(shell kpsewhich -var-value=TEXMFHOME)
INSTALL_DIR = $(TEXMFHOME)/tex/latex/mtheme
TEMP_DIR = .temptex
DEMO_SRC = demo.tex
DEMO_PDF = demo.pdf
MANUAL_SRC = mtheme.dtx
MANUAL_PDF = mtheme.pdf
TEXC := xelatex -shell-escape
TEXC := latexmk -xelatex -output-directory=$(TEMP_DIR)
DOCKER_IMAGE = latex-image
DOCKER_CONTAINER = latex-container
@ -17,19 +20,21 @@ DOCKER_CONTAINER = latex-container
.PHONY: clean install manual sty docker-run docker-rm
all: demo manual
all: sty demo contributors manual
sty: $(DTX) $(INS)
@latex $(INS)
demo: $(STY) $(DEMO_SRC)
$(TEXC) $(DEMO_SRC)
@cp $(TEMP_DIR)/$(DEMO_PDF) .
manual: $(MANUAL_SRC)
@mkdir -p .temptex
@$(TEXC) -output-directory .temptex $<
@$(TEXC) -output-directory .temptex $<
@cp .temptex/mtheme.pdf .
$(CONTRIB_TEX):$(CONTRIB_SRC)
@python $(CONTRIB_SRC)
manual: $(MANUAL_SRC) $(CONTRIB_TEX)
@$(TEXC) $(MANUAL_SRC)
@cp $(TEMP_DIR)/$(MANUAL_PDF) .
clean:
@git clean -xfd

View File

@ -1,7 +0,0 @@
#!/bin/sh
mkdir -p .temptex
xelatex -shell-escape -output-directory .temptex mtheme.dtx
pythontex .temptex/mtheme.dtx
xelatex -shell-escape -output-directory .temptex mtheme.dtx
cp .temptex/mtheme.pdf ./mtheme.pdf

67
contributors.py Executable file
View File

@ -0,0 +1,67 @@
#!/usr/bin/env python
import sys
import requests
import json
LOGIN = None
try:
with open("login.json", "r") as f:
login_data = json.load(f)
if (login_data['user'] and login_data['password']):
LOGIN = (login_data['user'],
login_data['password'])
except:
print("Couldn't open file 'login.json'.")
sys.exit()
def apiRequestLeft():
resp = requests.get("https://api.github.com/rate_limit",
auth=LOGIN)
if(resp.ok):
data = json.loads(resp.content)
return data['rate']['remaining']
else:
return 0
if not (apiRequestLeft):
print("No API requests left to load contributors list. ")
if(LOGIN is None):
print ("To get more API requests enter your login data into " +
"'login.json'")
sys.exit()
resp = requests.get("https://api.github.com/repos/matze/mtheme/contributors",
auth=LOGIN)
latex_string = "\\begin{itemize}\n"
if(resp.ok):
data = json.loads(resp.content)
extracted_data = ((c['login'], c['html_url'], c['url']) for c in data)
for user_name, html_url, url in extracted_data:
resp = requests.get(url, auth=LOGIN)
if(resp.ok):
user_data = json.loads(resp.content)
try:
name = user_data['name']
except:
name = ""
else:
if not (apiRequestLeft):
name = "Couldn't load name. API request limit exceeded."
else:
"Couldn't load name."
latex_string += str(" \\item \\href{%s}{%s} %s\n" % (html_url,
user_name,
name))
else:
latex_string += " \\item Couldn't load contributors.\n"
latex_string += "\\end{itemize}\n"
try:
with open("contributors.tex", "w") as f:
f.write(latex_string)
print("Successfully written data to file.")
print(latex_string)
except IOError:
print("Error writing to file.")

17
contributors.tex Normal file
View File

@ -0,0 +1,17 @@
\begin{itemize}
\item \href{https://github.com/matze}{matze} Matthias Vogelgesang
\item \href{https://github.com/rchurchley}{rchurchley} Ross Churchley
\item \href{https://github.com/benjamin-weiss}{benjamin-weiss} Benjamin Weiss
\item \href{https://github.com/eddelbuettel}{eddelbuettel} Dirk Eddelbuettel
\item \href{https://github.com/ronnychevalier}{ronnychevalier} Ronny Chevalier
\item \href{https://github.com/jdahm}{jdahm} Johann Dahm
\item \href{https://github.com/Schwefelsaeure}{Schwefelsaeure}
\item \href{https://github.com/awalterschulze}{awalterschulze} Walter Schulze
\item \href{https://github.com/ehahn}{ehahn} Erik Hahn
\item \href{https://github.com/ChipmunkMath}{ChipmunkMath}
\item \href{https://github.com/timbers}{timbers} Finbarr Timbers
\item \href{https://github.com/kdungs}{kdungs} Kevin Dungs
\item \href{https://github.com/Leonidas-from-XIV}{Leonidas-from-XIV} Marek Kubica
\item \href{https://github.com/0ip}{0ip} Robin Buse
\item \href{https://github.com/cuzcomd}{cuzcomd}
\end{itemize}

4
login.json Normal file
View File

@ -0,0 +1,4 @@
{
"user": "",
"password": ""
}

View File

@ -26,8 +26,6 @@
\setmonofont{Fira Mono}
\defaultfontfeatures{Ligatures=TeX}
\usepackage{pythontex}
\usepackage{enumitem}
\setlist[itemize]{noitemsep}
\setlist[enumerate]{noitemsep}
@ -122,62 +120,7 @@ To get started with the theme is very simple. The following code shows a minimal
The theme itself is licensed under a \href{http://creativecommons.org/licenses/by-sa/4.0/}{Creative Commons Attribution-ShareAlike 4.0 International License}. This means that if you change the theme and re-distribute it, you must retain the copyright notice header and license it under the same CC-BY-SA license. This does not affect the presentation that you create with the theme.
\section{Contributors}
\begin{pycode}
import sys
import requests
import json
LOGIN = None
try:
with open('../login.json', 'r') as f:
login_data = json.load(f)
if (login_data['user'] and login_data['password']):
LOGIN = (login_data['user'],
login_data['password'])
except:
print("Couldn't load login data.")
sys.exit()
def apiRequestLeft():
resp = requests.get('https://api.github.com/rate_limit',
auth=LOGIN)
if(resp.ok):
data = json.loads(resp.content)
return data['rate']['remaining']
else:
return 0
if not (apiRequestLeft):
print("No API requests left to load contributors list. Do you have " +
"saved your login information in 'login.json'?")
sys.exit()
resp = requests.get('https://api.github.com/repos/matze/mtheme/contributors',
auth=LOGIN)
print("\\begin{itemize}")
if(resp.ok):
data = json.loads(resp.content)
extracted_data = ((c['login'], c['html_url'], c['url']) for c in data)
for user_name, html_url, url in extracted_data:
resp = requests.get(url, auth=LOGIN)
if(resp.ok):
user_data = json.loads(resp.content)
try:
name = user_data['name']
except:
name = ""
else:
if not (apiRequestLeft):
name = "Couldn't load name. API request limit exceeded."
else:
"Couldn't load name."
print(" \\item \\href{%s}{%s} %s" % (html_url, user_name, name))
else:
print(" \\item Couldn't load contributors.")
print("\\end{itemize}")
\end{pycode}
\input{contributors}
\section{Implementation}
\DocInput{beamerthemem.dtx}

View File

@ -10,6 +10,7 @@
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\usedir{tex/latex/mtheme}