integrate git version info into formatters
This commit is contained in:
parent
c3b4a87b51
commit
7b689255bc
4 changed files with 11 additions and 4 deletions
|
@ -162,7 +162,8 @@ class PyTeXBuilder:
|
||||||
self.source_root,
|
self.source_root,
|
||||||
file
|
file
|
||||||
),
|
),
|
||||||
default_config=self.pytex_config.default_formatting_config
|
default_config=self.pytex_config.default_formatting_config,
|
||||||
|
git_version_info=self._git_version_info
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ from PyTeX.build.build.enums import PyTeXFileType
|
||||||
from .hashing import md5
|
from .hashing import md5
|
||||||
from ...format.formatting_config import FormattingConfig
|
from ...format.formatting_config import FormattingConfig
|
||||||
from ...format.auto_format import formatter_from_file_extension
|
from ...format.auto_format import formatter_from_file_extension
|
||||||
|
from ...format.git_version_info import GitVersionInfo
|
||||||
|
|
||||||
|
|
||||||
class PyTeXSourceFile:
|
class PyTeXSourceFile:
|
||||||
|
@ -15,6 +16,7 @@ class PyTeXSourceFile:
|
||||||
relative_path: RelativePath,
|
relative_path: RelativePath,
|
||||||
formatter: Optional[FormatterIF] = None,
|
formatter: Optional[FormatterIF] = None,
|
||||||
default_config: Optional[FormattingConfig] = None,
|
default_config: Optional[FormattingConfig] = None,
|
||||||
|
git_version_info: Optional[GitVersionInfo] = None,
|
||||||
pytex_file_type: Optional[PyTeXFileType] = None
|
pytex_file_type: Optional[PyTeXFileType] = None
|
||||||
):
|
):
|
||||||
self._relative_path: RelativePath = relative_path
|
self._relative_path: RelativePath = relative_path
|
||||||
|
@ -24,6 +26,7 @@ class PyTeXSourceFile:
|
||||||
self._formatter = formatter_from_file_extension(
|
self._formatter = formatter_from_file_extension(
|
||||||
relative_path.path,
|
relative_path.path,
|
||||||
config=default_config,
|
config=default_config,
|
||||||
|
git_version_info=git_version_info,
|
||||||
locate_file_config=True,
|
locate_file_config=True,
|
||||||
allow_infile_config=True
|
allow_infile_config=True
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,11 +7,13 @@ from .dict_formatter import DictFormatter
|
||||||
from .simple_tex_formatter import SimpleTeXFormatter
|
from .simple_tex_formatter import SimpleTeXFormatter
|
||||||
from .dtx_formatter import DTXFormatter
|
from .dtx_formatter import DTXFormatter
|
||||||
from .pytex_formatter import PyTeXFormatter
|
from .pytex_formatter import PyTeXFormatter
|
||||||
|
from .git_version_info import GitVersionInfo
|
||||||
|
|
||||||
|
|
||||||
def formatter_from_file_extension(
|
def formatter_from_file_extension(
|
||||||
input_file: Path,
|
input_file: Path,
|
||||||
config: Optional[FormattingConfig] = None,
|
config: Optional[FormattingConfig] = None,
|
||||||
|
git_version_info: Optional[GitVersionInfo] = None,
|
||||||
locate_file_config: bool = True,
|
locate_file_config: bool = True,
|
||||||
allow_infile_config: bool = True
|
allow_infile_config: bool = True
|
||||||
) -> PyTeXFormatter:
|
) -> PyTeXFormatter:
|
||||||
|
@ -30,6 +32,7 @@ def formatter_from_file_extension(
|
||||||
return switcher[extension](
|
return switcher[extension](
|
||||||
input_file=input_file,
|
input_file=input_file,
|
||||||
config=config,
|
config=config,
|
||||||
|
git_version_info=git_version_info,
|
||||||
locate_file_config=locate_file_config,
|
locate_file_config=locate_file_config,
|
||||||
allow_infile_config=allow_infile_config
|
allow_infile_config=allow_infile_config
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,7 +5,7 @@ from typing import Optional, Dict
|
||||||
from .constants import *
|
from .constants import *
|
||||||
from .formatterif import FormatterIF
|
from .formatterif import FormatterIF
|
||||||
from .formatting_config import FormattingConfig
|
from .formatting_config import FormattingConfig
|
||||||
from .git_version_info import RepoStatusInfo
|
from .git_version_info import GitVersionInfo
|
||||||
from .generic_text import GenericText
|
from .generic_text import GenericText
|
||||||
from ..logger import logger
|
from ..logger import logger
|
||||||
from abc import ABC
|
from abc import ABC
|
||||||
|
@ -16,7 +16,7 @@ class PyTeXFormatter(FormatterIF, ABC):
|
||||||
self,
|
self,
|
||||||
input_file: Optional[Path] = None,
|
input_file: Optional[Path] = None,
|
||||||
config: Optional[FormattingConfig] = None,
|
config: Optional[FormattingConfig] = None,
|
||||||
git_version_info: Optional[RepoStatusInfo] = None,
|
git_version_info: Optional[GitVersionInfo] = None,
|
||||||
locate_file_config: bool = True,
|
locate_file_config: bool = True,
|
||||||
allow_infile_config: bool = True
|
allow_infile_config: bool = True
|
||||||
):
|
):
|
||||||
|
@ -25,7 +25,7 @@ class PyTeXFormatter(FormatterIF, ABC):
|
||||||
config=config
|
config=config
|
||||||
)
|
)
|
||||||
self._config: Optional[FormattingConfig] = self._config # for type-hinting
|
self._config: Optional[FormattingConfig] = self._config # for type-hinting
|
||||||
self._git_version_info: Optional[RepoStatusInfo] = git_version_info
|
self._git_version_info: Optional[GitVersionInfo] = git_version_info
|
||||||
self._allow_infile_config: bool = allow_infile_config
|
self._allow_infile_config: bool = allow_infile_config
|
||||||
self._header: Optional[GenericText] = None
|
self._header: Optional[GenericText] = None
|
||||||
if locate_file_config:
|
if locate_file_config:
|
||||||
|
|
Loading…
Reference in a new issue