Close #10055: sphinx-build: Create directories when -w option given

This commit is contained in:
Takeshi KOMIYA 2022-01-09 04:04:31 +09:00
parent 87eda92a52
commit ce41a5e3f0
2 changed files with 5 additions and 0 deletions

View File

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

View File

@ -16,6 +16,7 @@ import os
import pdb import pdb
import sys import sys
import traceback import traceback
from os import path
from typing import IO, Any, List from typing import IO, Any, List
from docutils.utils import SystemMessage 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 import Tee, format_exception_cut_frames, save_traceback
from sphinx.util.console import color_terminal, nocolor, red, terminal_safe # type: ignore 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.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 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: if warning and args.warnfile:
try: try:
warnfile = abspath(args.warnfile)
ensuredir(path.dirname(warnfile))
warnfp = open(args.warnfile, 'w') warnfp = open(args.warnfile, 'w')
except Exception as exc: except Exception as exc:
parser.error(__('cannot open warning file %r: %s') % ( parser.error(__('cannot open warning file %r: %s') % (