fix bugs in docstrip formatter
This commit is contained in:
parent
df423f586f
commit
9f732688d9
2 changed files with 33 additions and 11 deletions
|
@ -63,9 +63,26 @@ class PyTeXBuilder:
|
||||||
)
|
)
|
||||||
return version
|
return version
|
||||||
|
|
||||||
@classmethod
|
def _ignored_subfolders_in_build_dir(self) -> List[Path]:
|
||||||
def is_ignored_in_build_dir(cls, path: RelativePath):
|
if self._build_target_type == PyTeXRootDirType.BUILD:
|
||||||
return path.relative_path.name == VERSION_INFO_FILE
|
dirs = [
|
||||||
|
self.pytex_config.build_dir_specification.tex_source_root,
|
||||||
|
self.pytex_config.build_dir_specification.doc_root
|
||||||
|
]
|
||||||
|
return [
|
||||||
|
path.absolute().resolve() for path in dirs
|
||||||
|
]
|
||||||
|
return []
|
||||||
|
|
||||||
|
def is_ignored_in_build_dir(self, path: RelativePath) -> bool:
|
||||||
|
real_path: Path = path.absolute().resolve()
|
||||||
|
ignored_dirs = self._ignored_subfolders_in_build_dir()
|
||||||
|
for ignored_dir in ignored_dirs:
|
||||||
|
if ignored_dir in real_path.parents:
|
||||||
|
return True
|
||||||
|
return path.relative_path.name in [
|
||||||
|
VERSION_INFO_FILE, '.pytexrc'
|
||||||
|
]
|
||||||
|
|
||||||
def build_tex_sources(self) -> bool:
|
def build_tex_sources(self) -> bool:
|
||||||
self._build_target_type = PyTeXRootDirType.TEX_SOURCE
|
self._build_target_type = PyTeXRootDirType.TEX_SOURCE
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import os
|
||||||
from .enums import TeXType
|
from .enums import TeXType
|
||||||
from .formatting_config import FormattingConfig
|
from .formatting_config import FormattingConfig
|
||||||
from .pytex_formatter import PyTeXFormatter
|
from .pytex_formatter import PyTeXFormatter
|
||||||
|
@ -15,9 +15,9 @@ class DocStripFormatter(PyTeXFormatter):
|
||||||
@property
|
@property
|
||||||
def output_files(self) -> List[str]:
|
def output_files(self) -> List[str]:
|
||||||
if self.config.tex_out_type == TeXType.TeXClass:
|
if self.config.tex_out_type == TeXType.TeXClass:
|
||||||
return self.name + '.cls'
|
return [self.raw_name + '.cls']
|
||||||
elif self.config.tex_out_type == TeXType.TeXClass:
|
elif self.config.tex_out_type == TeXType.TeXPackage:
|
||||||
return self.name + '.sty'
|
return [self.raw_name + '.sty']
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@ -28,13 +28,18 @@ class DocStripFormatter(PyTeXFormatter):
|
||||||
tmp_dir
|
tmp_dir
|
||||||
)
|
)
|
||||||
if self.input_file.with_suffix('.ins').exists():
|
if self.input_file.with_suffix('.ins').exists():
|
||||||
|
shutil.copy(
|
||||||
|
self.input_file.with_suffix('.ins'),
|
||||||
|
tmp_dir
|
||||||
|
)
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
['tex', self.input_file.with_suffix('.ins').name],
|
["tex", self.input_file.with_suffix('.ins').name],
|
||||||
cwd=tmp_dir,
|
cwd=tmp_dir,
|
||||||
stderr=subprocess.STDOUT
|
stderr=subprocess.DEVNULL, # TODO
|
||||||
|
stdout=subprocess.DEVNULL # TODO
|
||||||
)
|
)
|
||||||
if not result.returncode == 0:
|
if not result.returncode == 0:
|
||||||
raise NotImplementedError
|
raise NotImplementedError('no correct returncode')
|
||||||
else:
|
else:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
['pdflatex', self.input_file.name],
|
['pdflatex', self.input_file.name],
|
||||||
|
@ -46,7 +51,7 @@ class DocStripFormatter(PyTeXFormatter):
|
||||||
for file in self.output_files:
|
for file in self.output_files:
|
||||||
outfile = tmp_dir / file
|
outfile = tmp_dir / file
|
||||||
if not outfile.exists():
|
if not outfile.exists():
|
||||||
raise NotImplementedError
|
raise NotImplementedError(f'output file {outfile} does not exist')
|
||||||
shutil.copy(outfile, build_dir)
|
shutil.copy(outfile, build_dir)
|
||||||
shutil.rmtree(tmp_dir)
|
shutil.rmtree(tmp_dir)
|
||||||
return [] # No future config
|
return [] # No future config
|
||||||
|
|
Loading…
Reference in a new issue