add support for latex3 files

This commit is contained in:
Maximilian Keßler 2022-01-11 18:51:03 +01:00
parent 23766e8dcd
commit c8deda5af8
5 changed files with 45 additions and 12 deletions

View file

@ -11,7 +11,7 @@ class Attributes(Enum):
date = 'date'
year = 'year'
source_file_name = 'source_file_name'
version = 'package_version'
version = 'version'
class Args(Enum):

View file

@ -67,6 +67,10 @@ def build(
files.append(file)
for file in src_dir.rglob('*.pydict'):
files.append(file)
for file in src_dir.rglob('*.pysty3'):
files.append(file)
for file in src_dir.rglob('*.pycls3'):
files.append(file)
else:
for file in src_dir.glob('*.pysty'):
files.append(file)
@ -74,6 +78,10 @@ def build(
files.append(file)
for file in src_dir.glob('*.pydict'):
files.append(file)
for file in src_dir.glob('*.pysty3'):
files.append(file)
for file in src_dir.glob('*.pycls3'):
files.append(file)
sources_to_build = []
for file in files:

View file

@ -84,17 +84,35 @@ class TexFileToFormat:
self._header = new_header
def __format(self) -> dict:
if '.pysty' in self.src_path.name:
if self.src_path.name.endswith('.pysty'):
formatter = PackageFormatter(
package_name=self.src_path.with_suffix('').name,
author=self.current_build_info.author,
extra_header=self._header)
elif '.pycls' in self.src_path.name:
extra_header=self._header,
tex_version='LaTeX2e',
version=self.current_build_info.packages_version)
elif self.src_path.name.endswith('.pycls'):
formatter = ClassFormatter(
class_name=self.src_path.with_suffix('').name,
author=self.current_build_info.author,
extra_header=self._header)
elif '.pydict' in self.src_path.name:
extra_header=self._header,
tex_version='LaTeX2e',
version=self.current_build_info.packages_version)
elif self.src_path.name.endswith('.pysty3'):
formatter = PackageFormatter(
package_name=self.src_path.with_suffix('').name,
author=self.current_build_info.author,
extra_header=self._header,
tex_version='LaTeX3',
version=self.current_build_info.packages_version)
elif self.src_path.name.endswith('.pycls3'):
formatter = ClassFormatter(
class_name=self.src_path.with_suffix('').name,
author=self.current_build_info.author,
extra_header=self._header,
tex_version='LaTeX3',
version=self.current_build_info.packages_version)
elif self.src_path.name.endswith('.pydict'):
formatter = DictionaryFormatter(
kind=self.src_path.with_suffix('').name,
author=self.current_build_info.author,

View file

@ -4,14 +4,18 @@ import PyTeX.macros
class ClassFormatter(PyTeX.formatter.TexFormatter):
def __init__(self, class_name: str, author: str, extra_header: [str] = [], tex_version: str = 'LaTeX2e'):
def __init__(self, class_name: str, author: str, extra_header: [str] = [], tex_version: str = 'LaTeX2e',
version: str = '0.0.0'):
PyTeX.formatter.TexFormatter.__init__(
self,
name=class_name,
author=author,
header=extra_header,
file_extension='.cls',
tex_version=tex_version)
tex_version=tex_version,
version=version
)
self.tex_version = tex_version
def make_default_macros(self):
PyTeX.macros.make_default_macros(self, 'class')
PyTeX.macros.make_default_macros(self, 'class', tex_version=self.tex_version)

View file

@ -4,15 +4,18 @@ import PyTeX.macros
class PackageFormatter(PyTeX.formatter.TexFormatter):
def __init__(self, package_name: str, author: str, extra_header: [str] = [], tex_version: str = 'LaTeX2e'):
def __init__(self, package_name: str, author: str, extra_header: [str] = [], tex_version: str = 'LaTeX2e',
version: str = '0.0.0'):
PyTeX.formatter.TexFormatter.__init__(
self,
name=package_name,
author=author,
header=extra_header,
file_extension='.sty',
tex_version=tex_version
tex_version=tex_version,
version=version
)
self.tex_version = tex_version
def make_default_macros(self):
PyTeX.macros.make_default_macros(self, 'package')
PyTeX.macros.make_default_macros(self, 'package', tex_version=self.tex_version)