code: def setup_generated_mlir_docs():
      dst_path = Path("dialects")
      os.makedirs(dst_path, exist_ok=True)
  
      cmake_dir = get_cmake_dir()
      src_dir = cmake_dir / "docs" / "dialects"
      assert os.path.isdir(src_dir)
  
      shutil.copytree(src_dir, dst_path, dirs_exist_ok=True)
  
      files = os.listdir(dst_path)
  
      dialects = "\n   ".join(
          ["./" + f for f in files if "Dialect" in f]
      )
      ops = [f for f in files if "Ops" in f]
  
      # Add titles
      for op in ops:
          with open(dst_path / op, "r+") as f:
              lines = f.readlines()
              lines.insert(0, "# " + op.split(".md")[0])
              f.seek(0)
              f.writelines(lines)
      ops = "\n   ".join(["./" + op for op in ops])
  
      rst_string = f"""
  Triton MLIR Dialects and Ops
  =====================
  
  .. toctree::
     :maxdepth: 1
     :caption: Dialects
  
     {dialects}
  
  .. toctree::
     :maxdepth: 1
     :caption: Dialect Ops
  
     {ops}
  """
      with open(dst_path / "dialects.rst", "w+") as f:
          f.write(rst_string)
  
file_path: triton/docs/conf.py
imports: import os
  import shutil
  import sys
  import sysconfig
  from pathlib import Path
  import sphinx_rtd_theme
  from sphinx_gallery.sorting import FileNameSortKey
label_desc: Use image node_id 3 for calling a global function with example usage: setup_generated_mlir_docs() without return types