Merge pull request #78 from benjamin-weiss/build-system-improvements
Build system improvements
This commit is contained in:
commit
bf753b4db8
|
@ -1,5 +1,6 @@
|
||||||
demo.pdf
|
demo.pdf
|
||||||
mtheme.pdf
|
mtheme.pdf
|
||||||
|
login.json
|
||||||
|
|
||||||
*.fls
|
*.fls
|
||||||
*.acn
|
*.acn
|
||||||
|
|
19
Makefile
19
Makefile
|
@ -1,14 +1,17 @@
|
||||||
INS = mtheme.ins
|
INS = mtheme.ins
|
||||||
|
CONTRIB_SRC = contributors.py
|
||||||
|
CONTRIB_TEX = contributors.tex
|
||||||
DTX = $(wildcard *.dtx)
|
DTX = $(wildcard *.dtx)
|
||||||
STY = $(patsubst %.dtx,%.sty,$(wildcard beamer*.dtx))
|
STY = $(patsubst %.dtx,%.sty,$(wildcard beamer*.dtx))
|
||||||
TEXMFHOME = $(shell kpsewhich -var-value=TEXMFHOME)
|
TEXMFHOME = $(shell kpsewhich -var-value=TEXMFHOME)
|
||||||
INSTALL_DIR = $(TEXMFHOME)/tex/latex/mtheme
|
INSTALL_DIR = $(TEXMFHOME)/tex/latex/mtheme
|
||||||
|
TEMP_DIR = .temptex
|
||||||
|
|
||||||
DEMO_SRC = demo.tex
|
DEMO_SRC = demo.tex
|
||||||
DEMO_PDF = demo.pdf
|
DEMO_PDF = demo.pdf
|
||||||
MANUAL_SRC = mtheme.dtx
|
MANUAL_SRC = mtheme.dtx
|
||||||
MANUAL_PDF = mtheme.pdf
|
MANUAL_PDF = mtheme.pdf
|
||||||
TEXC := xelatex -shell-escape
|
TEXC := latexmk -xelatex -output-directory=$(TEMP_DIR)
|
||||||
|
|
||||||
DOCKER_IMAGE = latex-image
|
DOCKER_IMAGE = latex-image
|
||||||
DOCKER_CONTAINER = latex-container
|
DOCKER_CONTAINER = latex-container
|
||||||
|
@ -17,19 +20,21 @@ DOCKER_CONTAINER = latex-container
|
||||||
.PHONY: clean install manual sty docker-run docker-rm
|
.PHONY: clean install manual sty docker-run docker-rm
|
||||||
|
|
||||||
|
|
||||||
all: demo manual
|
all: sty demo contributors manual
|
||||||
|
|
||||||
sty: $(DTX) $(INS)
|
sty: $(DTX) $(INS)
|
||||||
@latex $(INS)
|
@latex $(INS)
|
||||||
|
|
||||||
demo: $(STY) $(DEMO_SRC)
|
demo: $(STY) $(DEMO_SRC)
|
||||||
$(TEXC) $(DEMO_SRC)
|
$(TEXC) $(DEMO_SRC)
|
||||||
|
@cp $(TEMP_DIR)/$(DEMO_PDF) .
|
||||||
|
|
||||||
manual: $(MANUAL_SRC)
|
$(CONTRIB_TEX):$(CONTRIB_SRC)
|
||||||
@mkdir -p .temptex
|
@python $(CONTRIB_SRC)
|
||||||
@$(TEXC) -output-directory .temptex $<
|
|
||||||
@$(TEXC) -output-directory .temptex $<
|
manual: $(MANUAL_SRC) $(CONTRIB_TEX)
|
||||||
@cp .temptex/mtheme.pdf .
|
@$(TEXC) $(MANUAL_SRC)
|
||||||
|
@cp $(TEMP_DIR)/$(MANUAL_PDF) .
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@git clean -xfd
|
@git clean -xfd
|
||||||
|
|
|
@ -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
|
|
|
@ -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.")
|
|
@ -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}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"user": "",
|
||||||
|
"password": ""
|
||||||
|
}
|
59
mtheme.dtx
59
mtheme.dtx
|
@ -26,8 +26,6 @@
|
||||||
\setmonofont{Fira Mono}
|
\setmonofont{Fira Mono}
|
||||||
\defaultfontfeatures{Ligatures=TeX}
|
\defaultfontfeatures{Ligatures=TeX}
|
||||||
|
|
||||||
\usepackage{pythontex}
|
|
||||||
|
|
||||||
\usepackage{enumitem}
|
\usepackage{enumitem}
|
||||||
\setlist[itemize]{noitemsep}
|
\setlist[itemize]{noitemsep}
|
||||||
\setlist[enumerate]{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.
|
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}
|
\section{Contributors}
|
||||||
\begin{pycode}
|
\input{contributors}
|
||||||
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}
|
|
||||||
|
|
||||||
\section{Implementation}
|
\section{Implementation}
|
||||||
\DocInput{beamerthemem.dtx}
|
\DocInput{beamerthemem.dtx}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
\input docstrip.tex
|
\input docstrip.tex
|
||||||
\keepsilent
|
\keepsilent
|
||||||
|
\askforoverwritefalse
|
||||||
|
|
||||||
\usedir{tex/latex/mtheme}
|
\usedir{tex/latex/mtheme}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue