code: def main() -> None:
      parser = argparse.ArgumentParser(
          description="Build the GPflow documentation."
      )
      parser.add_argument(
          "branch",
          nargs="?",
          default=None,
          type=str,
          choices=[b.value for b in Branch],
          help="Git branch that is currently being built.",
      )
      parser.add_argument(
          "destination",
          nargs="?",
          default=None,
          type=Path,
          help="Directory to write docs to.",
      )
      parser.add_argument(
          "--limit_notebooks",
          "--limit-notebooks",
          type=str,
          nargs="*",
          help="Only process the notebooks with this base/stem name; this is typically much faster and is useful when debugging.  For example, to process notebooks/tailor/external-mean-function.pct.py, use --limit_notebooks external-mean-function\n",
      )
      parser.add_argument(
          "--fail_on_warning",
          "--fail-on-warning",
          default=False,
          action="store_true",
          help="If set, crash if there were any warnings while generating documentation.",
      )
      parser.add_argument(
          "--shard",
          default=ShardingStrategy("no"),
          type=ShardingStrategy,
          help=(
              "Sharding strategy:"
              " If set to 'no' this script performs all necessary work."
              " If set to the format <i>/<n>, where 0 <= i < n then this script only computes"
              f" notebooks for shard <i> out of <n> shards. This requires that {_TMP} has manually"
              " been created, and is empty."
              " If set to 'collect' then this script assumes all notebooks already have been"
              " computed, using the <i>/<n> commands, and finishes the work."
          ),
      )
      args = parser.parse_args()
      sharding = args.shard
  
      if sharding.setup_tmp:
          shutil.rmtree(_TMP, ignore_errors=True)
          _TMP.mkdir(parents=True)
      else:
          assert _TMP.is_dir()
  
      # Type-ignore below is because the `dirs_exist_ok` parameter was added in Python 3.8, and we
      # still support Python 3.7. However, we only build our documentation using Python3.10+, so
      # actually this is ok.
      # pylint: disable=unexpected-keyword-arg
      shutil.copytree(_SPHINX_SRC, _BUILD_TMP, dirs_exist_ok=True)  # type: ignore[call-arg]
      # pylint: enable=unexpected-keyword-arg
  
      if sharding.build_notebooks:
          _build_notebooks(args.limit_notebooks, sharding)
  
      if sharding.build_other:
          branch = Branch(args.branch)
          assert branch, "'branch' command line argument missing."
          dest = args.destination
          assert dest, "'destination' command line argument missing."
          version_dest = dest / branch.version
          shutil.rmtree(version_dest, ignore_errors=True)
  
          (_BUILD_TMP / "build_version.txt").write_text(branch.version)
          generate_module_rst(gpflow, _BUILD_TMP / "api")
  
          sphinx_commands = [
              "sphinx-build",
              "-b",
              "html",
              "-d",
              str(_DOCTREE_TMP),
              str(_BUILD_TMP),
              str(version_dest),
          ]
          if args.fail_on_warning:
              sphinx_commands.extend(
                  [
                      "-W",
                      "--keep-going",
                  ]
              )
  
          subprocess.run(sphinx_commands).check_returncode()
  
file_path: GPflow/doc/build_docs.py
imports: import argparse
  import json
  import shutil
  import subprocess
  from datetime import datetime
  from itertools import chain
  from pathlib import Path
  from time import perf_counter
  from typing import Collection, Optional, Union
  from generate_module_rst import generate_module_rst
  from tabulate import tabulate
  from versions import Branch
  import gpflow
label_desc: Use image node_id 4 for calling a global function with example usage: main() without return types