add possibility to include extra message in package header

This commit is contained in:
Maximilian Keßler 2021-10-07 18:00:41 +02:00
parent e213c706ea
commit dbdd99cc3d
3 changed files with 11 additions and 6 deletions

View file

@ -35,7 +35,7 @@ PYTEX_INFO_TEXT = [
"This package has been generated by PyTeX, available at",
" https://github.com/kesslermaximilian/PyTeX",
"and built from source file '{source_file}'.",
"It is STRONGLY DISCOURAGED to edit this source file directly, since local changes",
"will not be versioned by Git and overwritten by the next build. Always edit the",
"source file and build the package again."
"It is STRONGLY DISCOURAGED to edit this source file directly, since local",
"changes will not be versioned by Git and overwritten by the next build. Always",
"edit the source file and build the package again."
]

View file

@ -8,7 +8,8 @@ from enums import Attributes, Args
class PackageFormatter:
def __init__(self, package_name: str, author: str = DEFAULT_AUTHOR):
def __init__(self, package_name: str, author: str = DEFAULT_AUTHOR, extra_header: str = ""):
self.extra_header = extra_header
self.package_name_raw = package_name
self.author = author
author_parts = self.author.lower().replace('ß', 'ss').split(' ')

View file

@ -5,7 +5,10 @@ from config import LICENSE, PACKAGE_INFO_TEXT, PYTEX_INFO_TEXT
def make_default_commands(package_formatter: PackageFormatter):
header = '%' * 80 + '\n' \
+ '\n'.join(map(lambda line: '% ' + line, LICENSE + [''] + PACKAGE_INFO_TEXT + [''] + PYTEX_INFO_TEXT)) \
+ '\n'.join(map(lambda line: '% ' + line,
LICENSE + [''] + PACKAGE_INFO_TEXT + [''] + PYTEX_INFO_TEXT
+ [''] + package_formatter.extra_header)
) \
+ '\n' + '%' * 80 + '\n\n' \
+ '\\NeedsTeXFormat{{LaTeX2e}}\n' \
'\\ProvidesPackage{{{package_name}}}[{date} - {description}]\n\n'
@ -47,7 +50,8 @@ def make_default_commands(package_formatter: PackageFormatter):
info=Args.one)
package_formatter.add_arg_replacement(1, 'warning', r'\PackageWarning{{{name}}}{{{warning}}}',
name=Attributes.package_name, warning=Args.one)
package_formatter.add_arg_replacement(1, 'error', r'\PackageError{{{name}}}{{{error}}}}', name=Attributes.package_name, error=Args.one)
package_formatter.add_arg_replacement(1, 'error', r'\PackageError{{{name}}}{{{error}}}}',
name=Attributes.package_name, error=Args.one)
package_formatter.add_replacement('end options x',
r"\DeclareOptionX*{{\PackageWarning{{{package_name}}}"
r"{{Unknown '\CurrentOption'}}}}" + '\n' + r'\ProcessOptionsX\relax' + '\n',