create output directory on formatting package, add more replacement macros
This commit is contained in:
parent
a9af7d4459
commit
a6ba08f1ee
2 changed files with 20 additions and 4 deletions
|
@ -95,4 +95,5 @@ class PackageFormatter:
|
|||
newlines += self.format_with_arg(self.format(line))
|
||||
if output_dir is None:
|
||||
output_dir = input_path.parent
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
(output_dir / self.file_name).write_text(''.join(newlines))
|
||||
|
|
|
@ -4,8 +4,8 @@ from config import LICENSE, PACKAGE_INFO_TEXT
|
|||
|
||||
|
||||
def make_default_commands(package_formatter: PackageFormatter):
|
||||
header = '%'*80 + '\n' + '\n'.join(map(lambda line: '% ' + line, LICENSE + [''] + PACKAGE_INFO_TEXT))\
|
||||
+ '\n' + '%'*80 + '\n' \
|
||||
header = '%' * 80 + '\n' + '\n'.join(map(lambda line: '% ' + line, LICENSE + [''] + PACKAGE_INFO_TEXT)) \
|
||||
+ '\n' + '%' * 80 + '\n' \
|
||||
+ '\\NeedsTeXFormat{{LaTeX2e}}\n' \
|
||||
'\\ProvidesPackage{{{package_name}}}[{date} - {description}]\n\n'
|
||||
package_formatter.add_arg_replacement(
|
||||
|
@ -19,6 +19,7 @@ def make_default_commands(package_formatter: PackageFormatter):
|
|||
)
|
||||
package_formatter.add_replacement('package name', '{}', Attributes.package_name)
|
||||
package_formatter.add_replacement('package prefix', '{}', Attributes.package_prefix)
|
||||
package_formatter.add_arg_replacement(1, 'package macro', r'\{}{}', Attributes.package_prefix, Args.one)
|
||||
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)
|
||||
|
@ -28,7 +29,21 @@ def make_default_commands(package_formatter: PackageFormatter):
|
|||
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)
|
||||
package_formatter.add_replacement('language options',
|
||||
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)
|
||||
package_formatter.add_arg_replacement(1, 'info', r'\PackageInfo{{{name}}}{{{info}}}', name=Attributes.package_name,
|
||||
info=Args.one)
|
||||
package_formatter.add_arg_replacement(1, 'warning', r'\PackageWarning{{{name}}}{{{warning}}}',
|
||||
name=Attributes.package_name, warning=Args.one)
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue