def sphinx_extension(app, exception):
 if (not (app.builder.name in ('html', 'dirhtml'))):
  return
 if (not app.config.sphinx_to_github):
  if app.config.sphinx_to_github_verbose:
   stdout('Sphinx-to-github: Disabled, doing nothing.')
  return
 if exception:
  if app.config.sphinx_to_github_verbose:
   stdout('Sphinx-to-github: Exception raised in main build, doing nothing.')
  return
 dir_helper = DirHelper(os.path.isdir, os.listdir, os.walk, shutil.rmtree)
 file_helper = FileSystemHelper((lambda f, mode: codecs.open(f, mode, app.config.sphinx_to_github_encoding)), os.path.join, shutil.move, os.path.exists)
 operations_factory = OperationsFactory()
 handler_factory = HandlerFactory()
 layout_factory = LayoutFactory(operations_factory, handler_factory, file_helper, dir_helper, app.config.sphinx_to_github_verbose, sys.stdout, force=True)
 layout = layout_factory.create_layout(app.outdir)
 layout.process()

def sphinx_extension ( app , exception ) : if ( not ( app . builder . name in ( 'html' , 'dirhtml' ) ) ) : return if ( not app . config . sphinx_to_github ) : if app . config . sphinx_to_github_verbose : stdout ( 'Sphinx-to-github: Disabled, doing nothing.' ) return if exception : if app . config . sphinx_to_github_verbose : stdout ( 'Sphinx-to-github: Exception raised in main build, doing nothing.' ) return dir_helper = DirHelper ( os . path . isdir , os . listdir , os . walk , shutil . rmtree ) file_helper = FileSystemHelper ( ( lambda f , mode : codecs . open ( f , mode , app . config . sphinx_to_github_encoding ) ) , os . path . join , shutil . move , os . path . exists ) operations_factory = OperationsFactory ( ) handler_factory = HandlerFactory ( ) layout_factory = LayoutFactory ( operations_factory , handler_factory , file_helper , dir_helper , app . config . sphinx_to_github_verbose , sys . stdout , force = True ) layout = layout_factory . create_layout ( app . outdir ) layout . process ( )
wrapped up as a sphinx extension .