add PyTeX info text to package header
This commit is contained in:
parent
a6ba08f1ee
commit
0e90f82076
4 changed files with 18 additions and 4 deletions
|
@ -30,3 +30,12 @@ PACKAGE_INFO_TEXT = [
|
|||
"Reportings of bugs, suggestions and improvements are welcome, see the README",
|
||||
"at the Git repository for further information."
|
||||
]
|
||||
|
||||
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."
|
||||
]
|
||||
|
|
1
enums.py
1
enums.py
|
@ -10,6 +10,7 @@ class Attributes(Enum):
|
|||
file_name = 'file_name'
|
||||
date = 'date'
|
||||
year = 'year'
|
||||
source_file_name = 'source_file_name'
|
||||
|
||||
|
||||
class Args(Enum):
|
||||
|
|
|
@ -21,6 +21,7 @@ class PackageFormatter:
|
|||
self.year = int(datetime.now().strftime('%Y'))
|
||||
self.replace_dict: Dict = {}
|
||||
self.arg_replace_dict: Dict = {}
|
||||
self.source_file_name = "not specified"
|
||||
|
||||
@staticmethod
|
||||
def command_name2keyword(keyword: str):
|
||||
|
@ -88,6 +89,7 @@ class PackageFormatter:
|
|||
return contents
|
||||
|
||||
def format_package(self, input_path: Path, output_dir: Path = None):
|
||||
self.source_file_name = str(input_path.name)
|
||||
input_file = input_path.open()
|
||||
lines = input_file.readlines()
|
||||
newlines = []
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from enums import Attributes, Args
|
||||
from package_formatter import PackageFormatter
|
||||
from config import LICENSE, PACKAGE_INFO_TEXT
|
||||
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)) \
|
||||
+ '\n' + '%' * 80 + '\n' \
|
||||
header = '%' * 80 + '\n' \
|
||||
+ '\n'.join(map(lambda line: '% ' + line, LICENSE + [''] + PACKAGE_INFO_TEXT + [''] + PYTEX_INFO_TEXT)) \
|
||||
+ '\n' + '%' * 80 + '\n\n' \
|
||||
+ '\\NeedsTeXFormat{{LaTeX2e}}\n' \
|
||||
'\\ProvidesPackage{{{package_name}}}[{date} - {description}]\n\n'
|
||||
package_formatter.add_arg_replacement(
|
||||
|
@ -15,7 +16,8 @@ def make_default_commands(package_formatter: PackageFormatter):
|
|||
date=Attributes.date,
|
||||
description=Args.one,
|
||||
year=Attributes.year,
|
||||
copyright_holders=Attributes.author
|
||||
copyright_holders=Attributes.author,
|
||||
source_file=Attributes.source_file_name
|
||||
)
|
||||
package_formatter.add_replacement('package name', '{}', Attributes.package_name)
|
||||
package_formatter.add_replacement('package prefix', '{}', Attributes.package_prefix)
|
||||
|
|
Loading…
Reference in a new issue