Skip to content

Commit 9a42e42

Browse files
authored
Merge pull request #10069 from tk0miya/10055_ensuredir_for_warnfile
Close #10055: sphinx-build: Create directories when `-w` option given
2 parents 99c144d + ce41a5e commit 9a42e42

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Features added
3737
checking in matched documents.
3838
* #9793: sphinx-build: Allow to use the parallel build feature in macOS on macOS
3939
and Python3.8+
40+
* #10055: sphinx-build: Create directories when ``-w`` option given
4041
* #9993: std domain: Allow to refer an inline target (ex. ``_`target name```)
4142
via :rst:role:`ref` role
4243
* #9391: texinfo: improve variable in ``samp`` role

sphinx/cmd/build.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import pdb
1717
import sys
1818
import traceback
19+
from os import path
1920
from typing import IO, Any, List
2021

2122
from docutils.utils import SystemMessage
@@ -28,6 +29,7 @@
2829
from sphinx.util import Tee, format_exception_cut_frames, save_traceback
2930
from sphinx.util.console import color_terminal, nocolor, red, terminal_safe # type: ignore
3031
from sphinx.util.docutils import docutils_namespace, patch_docutils
32+
from sphinx.util.osutil import abspath, ensuredir
3133

3234

3335
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:
240242

241243
if warning and args.warnfile:
242244
try:
245+
warnfile = abspath(args.warnfile)
246+
ensuredir(path.dirname(warnfile))
243247
warnfp = open(args.warnfile, 'w')
244248
except Exception as exc:
245249
parser.error(__('cannot open warning file %r: %s') % (

0 commit comments

Comments
 (0)