add class formatting support. add script class
This commit is contained in:
parent
8bf21475c5
commit
d694677d73
3 changed files with 39 additions and 38 deletions
2
PyTeX
2
PyTeX
|
@ -1 +1 @@
|
||||||
Subproject commit dbdd99cc3d6e02b0cfadb1d337f6b85c5f52a9b5
|
Subproject commit 6c0dee2511b1e28a8af3ceefa2219fc5135c8221
|
19
build.py
19
build.py
|
@ -6,7 +6,7 @@ from datetime import *
|
||||||
sys.path.insert(0, 'PyTeX/')
|
sys.path.insert(0, 'PyTeX/')
|
||||||
|
|
||||||
from package_formatter import PackageFormatter
|
from package_formatter import PackageFormatter
|
||||||
from replacements import make_default_commands
|
from class_formatter import ClassFormatter
|
||||||
from git_version import git_describe, get_latest_commit
|
from git_version import git_describe, get_latest_commit
|
||||||
|
|
||||||
BUILD_DETAILS = [
|
BUILD_DETAILS = [
|
||||||
|
@ -41,14 +41,21 @@ def build(build_dir: str):
|
||||||
if git.Repo().is_dirty():
|
if git.Repo().is_dirty():
|
||||||
extra_header += ['WARNING: Local changes to git repository detected.',
|
extra_header += ['WARNING: Local changes to git repository detected.',
|
||||||
' The build will not be reproducible (!)']
|
' The build will not be reproducible (!)']
|
||||||
num_files = 0
|
num_packages = 0
|
||||||
|
num_classes = 0
|
||||||
for file in input_root.rglob('*.pysty'):
|
for file in input_root.rglob('*.pysty'):
|
||||||
num_files += 1
|
num_packages += 1
|
||||||
formatter = PackageFormatter(package_name=file.with_suffix('').name, extra_header=extra_header)
|
formatter = PackageFormatter(package_name=file.with_suffix('').name, extra_header=extra_header)
|
||||||
print('[PyTeX] Writing file {}'.format(formatter.file_name))
|
print('[PyTeX] Writing file {}'.format(formatter.file_name))
|
||||||
make_default_commands(formatter)
|
formatter.make_default_macros()
|
||||||
formatter.format_package(file, Path('./').resolve() / build_dir / str(file.parent.relative_to(input_root)))
|
formatter.format_file(file, Path('./').resolve() / build_dir / str(file.parent.relative_to(input_root)))
|
||||||
print(f'[PyTeX] Successfully built {num_files} packages in {build_dir}/')
|
for file in input_root.rglob('*.pycls'):
|
||||||
|
num_classes += 1
|
||||||
|
formatter = ClassFormatter(class_name=file.with_suffix('').name, extra_header=extra_header)
|
||||||
|
print('[PyTeX] Writing class file {}'.format(formatter.file_name))
|
||||||
|
formatter.make_default_macros()
|
||||||
|
formatter.format_file(file, Path('./').resolve() / build_dir / str(file.parent.relative_to(input_root)))
|
||||||
|
print(f'[PyTeX] Successfully built {num_packages} packages and {num_classes} classes in {build_dir}/')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -1,55 +1,49 @@
|
||||||
\NeedsTeXFormat{LaTeX2e}
|
__HEADER__(Write up lecture notes as script)
|
||||||
\ProvidesClass{mkessler-script}[2021/03/31 Write up lecture notes as script]
|
|
||||||
|
|
||||||
%%%%Options of the package
|
__LANGUAGE_OPTIONS__
|
||||||
\newif\ifenglish\englishtrue
|
|
||||||
\DeclareOption{english}{\englishtrue}
|
|
||||||
\DeclareOption{german}{\englishfalse}
|
|
||||||
|
|
||||||
\newif\ifshowversion\showversiontrue
|
__NEW_IF__(showversion,true)
|
||||||
\DeclareOption{show version}{\showversiontrue}
|
\DeclareOption{show version}{__SET_IF__(showversion,true)}
|
||||||
\DeclareOption{hideversion}{\showversionfalse}
|
\DeclareOption{hideversion}{__SET_IF__(showversion,false)}
|
||||||
|
|
||||||
\newif\iffancyfoot\fancyfootfalse
|
__NEW_IF__(fancyfoot,false)
|
||||||
\DeclareOption{fancyfoot}{\fancyfoottrue}
|
\DeclareOption{fancyfoot}{__SET_IF__(fancyfoot,true)}
|
||||||
|
|
||||||
\newif\ifgitversion\gitversionfalse
|
|
||||||
\DeclareOption{git}{\gitversiontrue}
|
|
||||||
|
|
||||||
\ProcessOptions\relax
|
|
||||||
|
|
||||||
|
|
||||||
|
__NEW_IF__(gitversion,false)
|
||||||
|
\DeclareOption{git}{__SET_IF__(gitversion,true)}
|
||||||
|
|
||||||
|
__END_OPTIONS__
|
||||||
|
|
||||||
\RequirePackage{xifthen}
|
\RequirePackage{xifthen}
|
||||||
|
|
||||||
%%%%Define command to set metainformation of document
|
%%%%Define command to set metainformation of document
|
||||||
%Set the course
|
%Set the course
|
||||||
\def\@course{\ClassError{mkessler-script}{No \noexpand\course given}{See documentation for details}}%
|
\def\@course{__ERROR__(No \noexpand\course given){See documentation for details}}%
|
||||||
\DeclareRobustCommand*{\course}[1]{\gdef\@course{#1}}
|
\DeclareRobustCommand*{\course}[1]{\gdef\@course{#1}}
|
||||||
|
|
||||||
\def\@lecturer{\ClassError{mkessler-script}{No \noexpand\lecturer given}{See documentation for details}}%
|
\def\@lecturer{__ERROR__(No \noexpand\lecturer given){See documentation for details}}%
|
||||||
\def\@lecturertitle{}
|
\def\@lecturertitle{}
|
||||||
\DeclareRobustCommand*{\lecturer}[2][]{
|
\DeclareRobustCommand*{\lecturer}[2][]{
|
||||||
\gdef\@lecturer{#2}
|
\gdef\@lecturer{#2}
|
||||||
\gdef\@lecturertitle{\ifenglish Lecturer\else\ifthenelse{\isempty{#1}}{Dozent}{Dozentin}\fi}{}
|
\gdef\@lecturertitle{__IF__(english) Lecturer\else\ifthenelse{\isempty{#1}}{Dozent}{Dozentin}\fi}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
%Set the assistant
|
%Set the assistant
|
||||||
\newif\ifprintassistant\printassistantfalse
|
__NEW_IF__(printassistant,false)
|
||||||
\def\@assistant{}%
|
\def\@assistant{}%
|
||||||
\def\@assistantitle{}
|
\def\@assistantitle{}
|
||||||
\DeclareRobustCommand*{\assistant}[2][]{
|
\DeclareRobustCommand*{\assistant}[2][]{
|
||||||
\printassistanttrue
|
__SET_IF__(printassistant,true)
|
||||||
\gdef\@assistant{#2}
|
\gdef\@assistant{#2}
|
||||||
\gdef\@assistanttitle{\ifenglish Assistant\else\ifthenelse{\isempty{#1}}{Assistent}{Assistentin}\fi}
|
\gdef\@assistanttitle{__IF__(english) Assistant\else\ifthenelse{\isempty{#1}}{Assistent}{Assistentin}\fi}
|
||||||
}
|
}
|
||||||
|
|
||||||
%%%%Load base class article
|
%%%%Load base class article
|
||||||
\LoadClass{article}
|
\LoadClass{article}
|
||||||
|
|
||||||
|
__IF__(showversion)
|
||||||
\ifshowversion
|
__IF__(gitversion)
|
||||||
\ifgitversion
|
|
||||||
\RequirePackage[dirty={ (local changes have been made!)}]{gitinfo2}
|
\RequirePackage[dirty={ (local changes have been made!)}]{gitinfo2}
|
||||||
\fi
|
\fi
|
||||||
\fi
|
\fi
|
||||||
|
@ -73,7 +67,7 @@
|
||||||
\@lecturertitle \\
|
\@lecturertitle \\
|
||||||
{\sc \@lecturer} \\
|
{\sc \@lecturer} \\
|
||||||
\end{tabular}\par
|
\end{tabular}\par
|
||||||
\ifprintassistant
|
__IF__(printassistant)
|
||||||
\vskip 1em%
|
\vskip 1em%
|
||||||
\begin{tabular}[t]{c}%
|
\begin{tabular}[t]{c}%
|
||||||
\@assistanttitle \\
|
\@assistanttitle \\
|
||||||
|
@ -82,17 +76,17 @@
|
||||||
\fi
|
\fi
|
||||||
\vskip 1em%
|
\vskip 1em%
|
||||||
\begin{tabular}[t]{c}%
|
\begin{tabular}[t]{c}%
|
||||||
\ifenglish Notes\else Mitschrift\fi \\
|
__IF__(english) Notes\else Mitschrift\fi \\
|
||||||
{\sc \@author} \\
|
{\sc \@author} \\
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
\par}%
|
\par}%
|
||||||
\ifshowversion
|
__IF__(showversion)
|
||||||
\vskip 3em%
|
\vskip 3em%
|
||||||
\begin{tabular}[t]{c}%
|
\begin{tabular}[t]{c}%
|
||||||
{\small Version} \\
|
{\small Version} \\
|
||||||
\ifgitversion
|
__IF__(gitversion)
|
||||||
git: \gitFirstTagDescribe\\
|
git: \gitFirstTagDescribe\\
|
||||||
\ifenglish compiled\else kompiliert\fi:
|
__IF__(english) compiled\else kompiliert\fi:
|
||||||
\fi\today\,\currenttime \\
|
\fi\today\,\currenttime \\
|
||||||
\end{tabular}\par
|
\end{tabular}\par
|
||||||
\fi
|
\fi
|
||||||
|
@ -131,7 +125,7 @@
|
||||||
|
|
||||||
%%%% These are the fancy headers
|
%%%% These are the fancy headers
|
||||||
|
|
||||||
\iffancyfoot
|
__IF__(fancyfoot)
|
||||||
\RequirePackage{fancyhdr}
|
\RequirePackage{fancyhdr}
|
||||||
\pagestyle{fancy}
|
\pagestyle{fancy}
|
||||||
|
|
Loading…
Reference in a new issue