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