Skip to content

Commit

Permalink
Merge pull request #10069 from tk0miya/10055_ensuredir_for_warnfile
Browse files Browse the repository at this point in the history
Close #10055: sphinx-build: Create directories when `-w` option given
  • Loading branch information
tk0miya committed Jan 11, 2022
2 parents 99c144d + ce41a5e commit 9a42e42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions sphinx/cmd/build.py
Expand Up @@ -16,6 +16,7 @@
import pdb
import sys
import traceback
from os import path
from typing import IO, Any, List

from docutils.utils import SystemMessage
Expand All @@ -28,6 +29,7 @@
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
Expand Down Expand Up @@ -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') % (
Expand Down

0 comments on commit 9a42e42

Please sign in to comment.