Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .coveragerc

This file was deleted.

245 changes: 199 additions & 46 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pretext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
]


def activate():
def activate() -> None:
"""
This function was provided by the original `pretext` package
deployed to PyPI by Alex Willmer. Thanks to their generosity,
Expand Down
56 changes: 33 additions & 23 deletions pretext/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from pathlib import Path
import sys
from typing import Optional
from typing import Dict, Optional

from . import utils, core, codechat

Expand All @@ -14,11 +14,11 @@ def html(
ptxfile: Path,
pub_file: Path,
output: Path,
stringparams,
stringparams: Dict[str, str],
custom_xsl: Optional[Path],
xmlid_root,
zipped=False,
):
xmlid_root: Optional[str],
zipped: bool = False,
) -> None:
os.makedirs(output, exist_ok=True)
log.info(f"\nNow building HTML into {output}\n")
if xmlid_root is not None:
Expand All @@ -40,9 +40,9 @@ def html(
None,
output.as_posix(),
)
codechat.map_path_to_xml_id(
ptxfile, utils.project_path(ptxfile), output.as_posix()
)
pp = utils.project_path(ptxfile)
assert pp is not None, f"Invalid project path to {ptxfile}."
codechat.map_path_to_xml_id(ptxfile, pp, output.as_posix())
except Exception as e:
log.critical(e)
log.debug("Exception info:\n##################\n", exc_info=True)
Expand All @@ -54,9 +54,9 @@ def latex(
ptxfile: Path,
pub_file: Path,
output: Path,
stringparams,
stringparams: Dict[str, str],
custom_xsl: Optional[Path],
):
) -> None:
os.makedirs(output, exist_ok=True)
log.info(f"\nNow building LaTeX into {output}\n")
# ensure working directory is preserved
Expand All @@ -81,10 +81,10 @@ def pdf(
ptxfile: Path,
pub_file: Path,
output: Path,
stringparams,
stringparams: Dict[str, str],
custom_xsl: Optional[Path],
pdf_method: str,
):
) -> None:
os.makedirs(output, exist_ok=True)
log.info(f"\nNow building LaTeX into {output}\n")
# ensure working directory is preserved
Expand All @@ -110,10 +110,10 @@ def custom(
ptxfile: Path,
pub_file: Path,
output: Path,
stringparams,
stringparams: Dict[str, str],
custom_xsl: Path,
output_filename: Optional[str] = None,
):
) -> None:
os.makedirs(output, exist_ok=True)
if output_filename is not None:
output_filepath = output / output_filename
Expand Down Expand Up @@ -141,7 +141,9 @@ def custom(


# build (non Kindle) ePub:
def epub(ptxfile, pub_file: Path, output: Path, stringparams):
def epub(
ptxfile: Path, pub_file: Path, output: Path, stringparams: Dict[str, str]
) -> None:
os.makedirs(output, exist_ok=True)
try:
utils.npm_install()
Expand All @@ -151,7 +153,7 @@ def epub(ptxfile, pub_file: Path, output: Path, stringparams):
"Unable to build epub because node packages are not installed. Exiting..."
)
log.info(f"\nNow building ePub into {output}\n")
with utils.working_directory("."):
with utils.working_directory(Path()):
try:
core.epub(
ptxfile,
Expand All @@ -169,7 +171,9 @@ def epub(ptxfile, pub_file: Path, output: Path, stringparams):


# build Kindle ePub:
def kindle(ptxfile, pub_file: Path, output: Path, stringparams):
def kindle(
ptxfile: Path, pub_file: Path, output: Path, stringparams: Dict[str, str]
) -> None:
os.makedirs(output, exist_ok=True)
try:
utils.npm_install()
Expand All @@ -179,7 +183,7 @@ def kindle(ptxfile, pub_file: Path, output: Path, stringparams):
"Unable to build Kindle ePub because node packages are not installed. Exiting..."
)
log.info(f"\nNow building Kindle ePub into {output}\n")
with utils.working_directory("."):
with utils.working_directory(Path()):
try:
core.epub(
ptxfile,
Expand All @@ -197,7 +201,13 @@ def kindle(ptxfile, pub_file: Path, output: Path, stringparams):


# build Braille:
def braille(ptxfile, pub_file: Path, output: Path, stringparams, page_format="emboss"):
def braille(
ptxfile: Path,
pub_file: Path,
output: Path,
stringparams: Dict[str, str],
page_format: str = "emboss",
) -> None:
os.makedirs(output, exist_ok=True)
log.warning(
"Braille output is still experimental, and requires additional libraries from liblouis (specifically the file2brl software)."
Expand All @@ -210,7 +220,7 @@ def braille(ptxfile, pub_file: Path, output: Path, stringparams, page_format="em
"Unable to build braille because node packages could not be installed. Exiting..."
)
log.info(f"\nNow building braille into {output}\n")
with utils.working_directory("."):
with utils.working_directory(Path()):
try:
core.braille(
xml_source=ptxfile,
Expand All @@ -232,9 +242,9 @@ def webwork_sets(
ptxfile: Path,
pub_file: Path,
output: Path,
stringparams,
zipped=False,
):
stringparams: Dict[str, str],
zipped: bool = False,
) -> None:
os.makedirs(output, exist_ok=True)
log.info(f"\nNow building WeBWorK Sets into {output}\n")
# ensure working directory is preserved
Expand Down
Loading