mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Use `_StrPath
in
sphinx.cmd.build
`
This commit is contained in:
parent
de24fd0b76
commit
f0f127f116
@ -7,11 +7,10 @@ import bdb
|
|||||||
import contextlib
|
import contextlib
|
||||||
import locale
|
import locale
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import os
|
|
||||||
import pdb # NoQA: T100
|
import pdb # NoQA: T100
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
from os import path
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING, Any, TextIO
|
from typing import TYPE_CHECKING, Any, TextIO
|
||||||
|
|
||||||
from docutils.utils import SystemMessage
|
from docutils.utils import SystemMessage
|
||||||
@ -22,6 +21,7 @@ from sphinx.application import Sphinx
|
|||||||
from sphinx.errors import SphinxError, SphinxParallelError
|
from sphinx.errors import SphinxError, SphinxParallelError
|
||||||
from sphinx.locale import __
|
from sphinx.locale import __
|
||||||
from sphinx.util._io import TeeStripANSI
|
from sphinx.util._io import TeeStripANSI
|
||||||
|
from sphinx.util._pathlib import _StrPath
|
||||||
from sphinx.util.console import color_terminal, nocolor, red, terminal_safe
|
from sphinx.util.console import color_terminal, nocolor, red, terminal_safe
|
||||||
from sphinx.util.docutils import docutils_namespace, patch_docutils
|
from sphinx.util.docutils import docutils_namespace, patch_docutils
|
||||||
from sphinx.util.exceptions import format_exception_cut_frames, save_traceback
|
from sphinx.util.exceptions import format_exception_cut_frames, save_traceback
|
||||||
@ -392,10 +392,10 @@ def _parse_confdir(noconfig: bool, confdir: str, sourcedir: str) -> str | None:
|
|||||||
return confdir
|
return confdir
|
||||||
|
|
||||||
|
|
||||||
def _parse_doctreedir(doctreedir: str, outputdir: str) -> str:
|
def _parse_doctreedir(doctreedir: str, outputdir: str) -> _StrPath:
|
||||||
if doctreedir:
|
if doctreedir:
|
||||||
return doctreedir
|
return _StrPath(doctreedir)
|
||||||
return os.path.join(outputdir, '.doctrees')
|
return _StrPath(outputdir, '.doctrees')
|
||||||
|
|
||||||
|
|
||||||
def _validate_filenames(
|
def _validate_filenames(
|
||||||
@ -431,12 +431,12 @@ def _parse_logging(
|
|||||||
warnfp = None
|
warnfp = None
|
||||||
if warning and warnfile:
|
if warning and warnfile:
|
||||||
try:
|
try:
|
||||||
warnfile = path.abspath(warnfile)
|
warn_file = Path(warnfile).resolve()
|
||||||
ensuredir(path.dirname(warnfile))
|
ensuredir(warn_file.parent)
|
||||||
# the caller is responsible for closing this file descriptor
|
# the caller is responsible for closing this file descriptor
|
||||||
warnfp = open(warnfile, 'w', encoding='utf-8') # NoQA: SIM115
|
warnfp = open(warn_file, 'w', encoding='utf-8') # NoQA: SIM115
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
parser.error(__('cannot open warning file %r: %s') % (warnfile, exc))
|
parser.error(__("cannot open warning file '%s': %s") % (warn_file, exc))
|
||||||
warning = TeeStripANSI(warning, warnfp) # type: ignore[assignment]
|
warning = TeeStripANSI(warning, warnfp) # type: ignore[assignment]
|
||||||
error = warning
|
error = warning
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user