Merge pull request #10069 from tk0miya/10055_ensuredir_for_warnfile

Close #10055: sphinx-build: Create directories when `-w` option given
This commit is contained in:
Takeshi KOMIYA 2022-01-12 02:35:15 +09:00 committed by GitHub
commit 9a42e42a40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -37,6 +37,7 @@ Features added
checking in matched documents.
* #9793: sphinx-build: Allow to use the parallel build feature in macOS on macOS
and Python3.8+
* #10055: sphinx-build: Create directories when ``-w`` option given
* #9993: std domain: Allow to refer an inline target (ex. ``_`target name```)
via :rst:role:`ref` role
* #9391: texinfo: improve variable in ``samp`` role

View File

@ -16,6 +16,7 @@ import os
import pdb
import sys
import traceback
from os import path
from typing import IO, Any, List
from docutils.utils import SystemMessage
@ -28,6 +29,7 @@ from sphinx.locale import __
from sphinx.util import Tee, format_exception_cut_frames, save_traceback
from sphinx.util.console import color_terminal, nocolor, red, terminal_safe # type: ignore
from sphinx.util.docutils import docutils_namespace, patch_docutils
from sphinx.util.osutil import abspath, ensuredir
def handle_exception(app: Sphinx, args: Any, exception: BaseException, stderr: IO = sys.stderr) -> None: # NOQA
@ -240,6 +242,8 @@ def build_main(argv: List[str] = sys.argv[1:]) -> int:
if warning and args.warnfile:
try:
warnfile = abspath(args.warnfile)
ensuredir(path.dirname(warnfile))
warnfp = open(args.warnfile, 'w')
except Exception as exc:
parser.error(__('cannot open warning file %r: %s') % (