2021-10-06 17:08:53 +02:00
|
|
|
from enums import Attributes, Args
|
|
|
|
from package_formatter import PackageFormatter
|
2021-10-07 08:58:43 +02:00
|
|
|
from config import LICENSE, PACKAGE_INFO_TEXT, PYTEX_INFO_TEXT
|
2021-10-06 17:08:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
def make_default_commands(package_formatter: PackageFormatter):
|
2021-10-07 08:58:43 +02:00
|
|
|
header = '%' * 80 + '\n' \
|
|
|
|
+ '\n'.join(map(lambda line: '% ' + line, LICENSE + [''] + PACKAGE_INFO_TEXT + [''] + PYTEX_INFO_TEXT)) \
|
|
|
|
+ '\n' + '%' * 80 + '\n\n' \
|
2021-10-06 22:59:00 +02:00
|
|
|
+ '\\NeedsTeXFormat{{LaTeX2e}}\n' \
|
|
|
|
'\\ProvidesPackage{{{package_name}}}[{date} - {description}]\n\n'
|
2021-10-06 18:23:41 +02:00
|
|
|
package_formatter.add_arg_replacement(
|
|
|
|
1, 'header',
|
|
|
|
header,
|
|
|
|
package_name=Attributes.package_name,
|
|
|
|
date=Attributes.date,
|
|
|
|
description=Args.one,
|
|
|
|
year=Attributes.year,
|
2021-10-07 08:58:43 +02:00
|
|
|
copyright_holders=Attributes.author,
|
|
|
|
source_file=Attributes.source_file_name
|
2021-10-06 18:23:41 +02:00
|
|
|
)
|
2021-10-06 17:08:53 +02:00
|
|
|
package_formatter.add_replacement('package name', '{}', Attributes.package_name)
|
|
|
|
package_formatter.add_replacement('package prefix', '{}', Attributes.package_prefix)
|
2021-10-06 22:59:00 +02:00
|
|
|
package_formatter.add_arg_replacement(1, 'package macro', r'\{}{}', Attributes.package_prefix, Args.one)
|
2021-10-06 17:08:53 +02:00
|
|
|
package_formatter.add_replacement('file name', '{name}', name=Attributes.file_name)
|
|
|
|
package_formatter.add_replacement('date', '{}', Attributes.date)
|
|
|
|
package_formatter.add_replacement('author', '{}', Attributes.author)
|
2021-10-06 18:39:13 +02:00
|
|
|
package_formatter.add_arg_replacement(2, 'new if', r'\newif\if{prefix}{condition}\{prefix}{condition}{value}',
|
|
|
|
prefix=Attributes.package_prefix, condition=Args.one, value=Args.two)
|
|
|
|
package_formatter.add_arg_replacement(2, 'set if', r'\{prefix}{condition}{value}',
|
2021-10-06 17:08:53 +02:00
|
|
|
prefix=Attributes.package_prefix, condition=Args.one, value=Args.two)
|
|
|
|
package_formatter.add_arg_replacement(1, 'if', r'\if{prefix}{condition}', prefix=Attributes.package_prefix,
|
|
|
|
condition=Args.one)
|
2021-10-07 13:52:20 +02:00
|
|
|
package_formatter.add_replacement('language options x',
|
2021-10-06 22:59:00 +02:00
|
|
|
r'\newif\if{prefix}english\{prefix}englishtrue' + '\n' +
|
|
|
|
r'\DeclareOptionX{{german}}{{\{prefix}englishfalse}}' + '\n' +
|
|
|
|
r'\DeclareOptionX{{ngerman}}{{\{prefix}englishfalse}}' + '\n' +
|
|
|
|
r'\DeclareOptionX{{english}}{{\{prefix}englishtrue}}',
|
|
|
|
prefix=Attributes.package_prefix)
|
2021-10-07 13:52:20 +02:00
|
|
|
package_formatter.add_replacement('language options',
|
|
|
|
r'\newif\if{prefix}english\{prefix}englishtrue' + '\n' +
|
|
|
|
r'\DeclareOption{{german}}{{\{prefix}englishfalse}}' + '\n' +
|
|
|
|
r'\DeclareOption{{ngerman}}{{\{prefix}englishfalse}}' + '\n' +
|
|
|
|
r'\DeclareOption{{english}}{{\{prefix}englishtrue}}',
|
|
|
|
prefix=Attributes.package_prefix)
|
2021-10-06 17:08:53 +02:00
|
|
|
package_formatter.add_arg_replacement(1, 'info', r'\PackageInfo{{{name}}}{{{info}}}', name=Attributes.package_name,
|
|
|
|
info=Args.one)
|
2021-10-06 18:23:41 +02:00
|
|
|
package_formatter.add_arg_replacement(1, 'warning', r'\PackageWarning{{{name}}}{{{warning}}}',
|
|
|
|
name=Attributes.package_name, warning=Args.one)
|
2021-10-06 22:59:00 +02:00
|
|
|
package_formatter.add_replacement('end options x',
|
|
|
|
r"\DeclareOptionX*{{\PackageWarning{{{package_name}}}"
|
|
|
|
r"{{Unknown '\CurrentOption'}}}}" + '\n' + r'\ProcessOptionsX\relax' + '\n',
|
|
|
|
package_name=Attributes.package_name)
|
|
|
|
package_formatter.add_replacement('end options',
|
|
|
|
r"\DeclareOption*{{\PackageWarning{{{package_name}}}"
|
|
|
|
r"{{Unknown '\CurrentOption'}}}}" + '\n' + r'\ProcessOptions\relax' + '\n',
|
|
|
|
package_name=Attributes.package_name)
|