add _get_provides_text method

This commit is contained in:
Maximilian Keßler 2022-02-17 20:05:18 +01:00
parent f7575ccd0c
commit ed004aaf33
2 changed files with 24 additions and 22 deletions

View file

@ -37,25 +37,4 @@ class SimpleTeXFormatter(TexFormatter):
return line.rstrip() return line.rstrip()
def format_post_header(self) -> None: def format_post_header(self) -> None:
if self.config.has_description: self._shipout_line(self._get_provides_text())
if self.config.tex_flavour == TeXFlavour.LaTeX2e:
self._shipout_line(
r'\Provides%s{%s}[%s - %s]'
% (
self.config.tex_type.value.capitalize(),
self.name,
self.attribute_dict[FormatterProperty.date.value],
self.attribute_dict[FormatterProperty.description.value]
)
)
else:
self._shipout_line(
'\\ProvidesExpl%s { %s } { %s } { %s }\n { %s }'
% (
self.config.tex_type.value.capitalize(),
self.name,
self.attribute_dict[FormatterProperty.date.value],
self.config.version,
self.config.description
)
)

View file

@ -143,6 +143,29 @@ class TexFormatter(PyTeXFormatter, ABC):
def mode(self, mode: FormatterMode) -> None: def mode(self, mode: FormatterMode) -> None:
self._mode = mode self._mode = mode
def _get_provides_text(self) -> str:
if self.config.has_description:
if self.config.tex_flavour == TeXFlavour.LaTeX2e:
return \
r'\Provides%s{%s}[%s - %s]' \
% (
self.config.tex_type.value.capitalize(),
self.name,
self.attribute_dict[FormatterProperty.date.value],
self.attribute_dict[FormatterProperty.description.value]
)
else:
return \
'\\ProvidesExpl%s { %s } { %s } { %s }\n { %s }' \
% (
self.config.tex_type.value.capitalize(),
self.name,
self.attribute_dict[FormatterProperty.date.value],
self.config.version,
self.config.description
)
def format_header(self): def format_header(self):
if self._output_file is None: if self._output_file is None:
raise NotImplementedError raise NotImplementedError