@@ -195,9 +195,7 @@ def make_main(argv: List[str] = sys.argv[1:]) -> int:
195
195
return make_mode .run_make_mode (argv [1 :])
196
196
197
197
198
- def build_main (argv : List [str ] = sys .argv [1 :]) -> int :
199
- """Sphinx build "main" command-line entry."""
200
-
198
+ def _parse_arguments (argv : List [str ] = sys .argv [1 :]) -> argparse .Namespace :
201
199
parser = get_parser ()
202
200
args = parser .parse_args (argv )
203
201
@@ -236,6 +234,10 @@ def build_main(argv: List[str] = sys.argv[1:]) -> int:
236
234
warning = Tee (warning , warnfp ) # type: ignore
237
235
error = warning
238
236
237
+ args .status = status
238
+ args .warning = warning
239
+ args .error = error
240
+
239
241
confoverrides = {}
240
242
for val in args .define :
241
243
try :
@@ -258,26 +260,55 @@ def build_main(argv: List[str] = sys.argv[1:]) -> int:
258
260
if args .nitpicky :
259
261
confoverrides ['nitpicky' ] = True
260
262
263
+ args .confoverrides = confoverrides
264
+
265
+ return args
266
+
267
+
268
+ def build_main (argv : List [str ] = sys .argv [1 :]) -> int :
269
+ """Sphinx build "main" command-line entry."""
270
+ args = _parse_arguments (argv )
271
+
261
272
app = None
262
273
try :
263
274
confdir = args .confdir or args .sourcedir
264
275
with patch_docutils (confdir ), docutils_namespace ():
265
276
app = Sphinx (args .sourcedir , args .confdir , args .outputdir ,
266
- args .doctreedir , args .builder , confoverrides , status ,
267
- warning , args .freshenv , args .warningiserror ,
277
+ args .doctreedir , args .builder , args . confoverrides , args . status ,
278
+ args . warning , args .freshenv , args .warningiserror ,
268
279
args .tags , args .verbosity , args .jobs , args .keep_going ,
269
280
args .pdb )
270
281
app .build (args .force_all , args .filenames )
271
282
return app .statuscode
272
283
except (Exception , KeyboardInterrupt ) as exc :
273
- handle_exception (app , args , exc , error )
284
+ handle_exception (app , args , exc , args . error )
274
285
return 2
275
286
276
287
288
+ def _bug_report_info () -> int :
289
+ from platform import platform , python_implementation
290
+
291
+ import docutils
292
+ import jinja2
293
+
294
+ print ('Please paste all output below into the bug report template\n \n ' )
295
+ print ('```text' )
296
+ print (f'Platform: { sys .platform } ; ({ platform ()} )' )
297
+ print (f'Python version: { sys .version } )' )
298
+ print (f'Python implementation: { python_implementation ()} ' )
299
+ print (f'Sphinx version: { sphinx .__display_version__ } ' )
300
+ print (f'Docutils version: { docutils .__version__ } ' )
301
+ print (f'Jinja2 version: { jinja2 .__version__ } ' )
302
+ print ('```' )
303
+ return 0
304
+
305
+
277
306
def main (argv : List [str ] = sys .argv [1 :]) -> int :
278
307
sphinx .locale .setlocale (locale .LC_ALL , '' )
279
308
sphinx .locale .init_console (os .path .join (package_dir , 'locale' ), 'sphinx' )
280
309
310
+ if argv [:1 ] == ['--bug-report' ]:
311
+ return _bug_report_info ()
281
312
if argv [:1 ] == ['-M' ]:
282
313
return make_main (argv )
283
314
else :
0 commit comments