Merge pull request #5131 from tk0miya/5125_wrong_sphinx.main

Fix #5125: sphinx-build: Interface of ``sphinx:main()`` has changed
This commit is contained in:
Takeshi KOMIYA 2018-07-13 00:39:33 +09:00 committed by GitHub
commit b2ce178d7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -34,6 +34,9 @@ Bugs fixed
* #5070: epub: Wrong internal href fragment links
* #5104: apidoc: Interface of ``sphinx.apidoc:main()`` has changed
* #5076: napoleon raises RuntimeError with python 3.7
* #5125: sphinx-build: Interface of ``sphinx:main()`` has changed
* sphinx-build: ``sphinx.cmd.build.main()`` refers ``sys.argv`` instead of given
argument
Testing
--------

View File

@ -60,15 +60,15 @@ if __version__.endswith('+'):
pass
def main(*args, **kwargs):
def main(argv=sys.argv):
from .cmd import build
warnings.warn(
'`sphinx.main()` has moved to `sphinx.cmd.build.main()`.',
RemovedInSphinx20Warning,
stacklevel=2,
)
args = args[1:] # skip first argument to adjust arguments (refs: #4615)
return build.main(*args, **kwargs)
argv = argv[1:] # skip first argument to adjust arguments (refs: #4615)
return build.main(argv)
def build_main(argv=sys.argv):

View File

@ -32,7 +32,7 @@ def make_main(argv=sys.argv[1:]):
def main(argv=sys.argv[1:]):
# type: (List[str]) -> int
if sys.argv[1:2] == ['-M']:
if argv[:1] == ['-M']:
return make_main(argv)
else:
return build_main(argv)