add support for latex3 files
This commit is contained in:
parent
23766e8dcd
commit
c8deda5af8
5 changed files with 45 additions and 12 deletions
|
@ -11,7 +11,7 @@ class Attributes(Enum):
|
||||||
date = 'date'
|
date = 'date'
|
||||||
year = 'year'
|
year = 'year'
|
||||||
source_file_name = 'source_file_name'
|
source_file_name = 'source_file_name'
|
||||||
version = 'package_version'
|
version = 'version'
|
||||||
|
|
||||||
|
|
||||||
class Args(Enum):
|
class Args(Enum):
|
||||||
|
|
|
@ -67,6 +67,10 @@ def build(
|
||||||
files.append(file)
|
files.append(file)
|
||||||
for file in src_dir.rglob('*.pydict'):
|
for file in src_dir.rglob('*.pydict'):
|
||||||
files.append(file)
|
files.append(file)
|
||||||
|
for file in src_dir.rglob('*.pysty3'):
|
||||||
|
files.append(file)
|
||||||
|
for file in src_dir.rglob('*.pycls3'):
|
||||||
|
files.append(file)
|
||||||
else:
|
else:
|
||||||
for file in src_dir.glob('*.pysty'):
|
for file in src_dir.glob('*.pysty'):
|
||||||
files.append(file)
|
files.append(file)
|
||||||
|
@ -74,6 +78,10 @@ def build(
|
||||||
files.append(file)
|
files.append(file)
|
||||||
for file in src_dir.glob('*.pydict'):
|
for file in src_dir.glob('*.pydict'):
|
||||||
files.append(file)
|
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 = []
|
sources_to_build = []
|
||||||
for file in files:
|
for file in files:
|
||||||
|
|
|
@ -84,17 +84,35 @@ class TexFileToFormat:
|
||||||
self._header = new_header
|
self._header = new_header
|
||||||
|
|
||||||
def __format(self) -> dict:
|
def __format(self) -> dict:
|
||||||
if '.pysty' in self.src_path.name:
|
if self.src_path.name.endswith('.pysty'):
|
||||||
formatter = PackageFormatter(
|
formatter = PackageFormatter(
|
||||||
package_name=self.src_path.with_suffix('').name,
|
package_name=self.src_path.with_suffix('').name,
|
||||||
author=self.current_build_info.author,
|
author=self.current_build_info.author,
|
||||||
extra_header=self._header)
|
extra_header=self._header,
|
||||||
elif '.pycls' in self.src_path.name:
|
tex_version='LaTeX2e',
|
||||||
|
version=self.current_build_info.packages_version)
|
||||||
|
elif self.src_path.name.endswith('.pycls'):
|
||||||
formatter = ClassFormatter(
|
formatter = ClassFormatter(
|
||||||
class_name=self.src_path.with_suffix('').name,
|
class_name=self.src_path.with_suffix('').name,
|
||||||
author=self.current_build_info.author,
|
author=self.current_build_info.author,
|
||||||
extra_header=self._header)
|
extra_header=self._header,
|
||||||
elif '.pydict' in self.src_path.name:
|
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(
|
formatter = DictionaryFormatter(
|
||||||
kind=self.src_path.with_suffix('').name,
|
kind=self.src_path.with_suffix('').name,
|
||||||
author=self.current_build_info.author,
|
author=self.current_build_info.author,
|
||||||
|
|
|
@ -4,14 +4,18 @@ import PyTeX.macros
|
||||||
|
|
||||||
|
|
||||||
class ClassFormatter(PyTeX.formatter.TexFormatter):
|
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__(
|
PyTeX.formatter.TexFormatter.__init__(
|
||||||
self,
|
self,
|
||||||
name=class_name,
|
name=class_name,
|
||||||
author=author,
|
author=author,
|
||||||
header=extra_header,
|
header=extra_header,
|
||||||
file_extension='.cls',
|
file_extension='.cls',
|
||||||
tex_version=tex_version)
|
tex_version=tex_version,
|
||||||
|
version=version
|
||||||
|
)
|
||||||
|
self.tex_version = tex_version
|
||||||
|
|
||||||
def make_default_macros(self):
|
def make_default_macros(self):
|
||||||
PyTeX.macros.make_default_macros(self, 'class')
|
PyTeX.macros.make_default_macros(self, 'class', tex_version=self.tex_version)
|
||||||
|
|
|
@ -4,15 +4,18 @@ import PyTeX.macros
|
||||||
|
|
||||||
|
|
||||||
class PackageFormatter(PyTeX.formatter.TexFormatter):
|
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__(
|
PyTeX.formatter.TexFormatter.__init__(
|
||||||
self,
|
self,
|
||||||
name=package_name,
|
name=package_name,
|
||||||
author=author,
|
author=author,
|
||||||
header=extra_header,
|
header=extra_header,
|
||||||
file_extension='.sty',
|
file_extension='.sty',
|
||||||
tex_version=tex_version
|
tex_version=tex_version,
|
||||||
|
version=version
|
||||||
)
|
)
|
||||||
|
self.tex_version = tex_version
|
||||||
|
|
||||||
def make_default_macros(self):
|
def make_default_macros(self):
|
||||||
PyTeX.macros.make_default_macros(self, 'package')
|
PyTeX.macros.make_default_macros(self, 'package', tex_version=self.tex_version)
|
||||||
|
|
Loading…
Reference in a new issue