code: def build_all(exported_root, destination, versions):
      
      log = logging.getLogger(__name__)
  
      while True:
          # Build root.
          remote = versions[Config.from_context().root_ref]
          log.info('Building root: %s', remote['name'])
          source = os.path.dirname(os.path.join(exported_root, remote['sha'], remote['conf_rel_path']))
          build(source, destination, versions, remote['name'], True)
  
          # Build all refs.
          for remote in list(versions.remotes):
              log.info('Building ref: %s', remote['name'])
              source = os.path.dirname(os.path.join(exported_root, remote['sha'], remote['conf_rel_path']))
              target = os.path.join(destination, remote['root_dir'])
              try:
                  build(source, target, versions, remote['name'], False)
              except HandledError:
                  log.warning('Skipping. Will not be building %s. Rebuilding everything.', remote['name'])
                  versions.remotes.pop(versions.remotes.index(remote))
                  break  # Break out of for loop.
          else:
              break
docs: Build all versions.
  
      :param str exported_root: Tempdir path with exported commits as subdirectories.
      :param str destination: Destination directory to copy/overwrite built docs to. Does not delete old files.
      :param sphinxcontrib.versioning.versions.Versions versions: Versions class instance.