code: def demo_indexing(action):
      root_dir = "demos/"
  
      for directory in glob.iglob("demos/**/", recursive=True):
          readme = os.path.join(directory, "README.md")
          if not os.path.exists(readme):
              # FIXME(#1139): some demos directories don't have a README
              continue
  
          index = os.path.join("docs", directory, "index.rst")
          if not os.path.exists(index):
              error(
                  f"expected each demo README to match a docs 'index.rst' file, found `{readme}` without corresponding `{index}`"
              )
  
          link = f"{DOC_URL_BASE}/{directory}"
          if directory != root_dir:
              # the root readme already has the detailed table in it, so don't include the full list
              # of demos there.
  
              listing = "\n".join(demo_listing_table(directory))
              suffix = "The demo titles link to the latest, nicely rendered version. The 'source' links will open the demo in the application in which this README is being viewed, such as Jupyter Lab (ready for execution)."
          else:
              listing = ""
              suffix = ""
  
          new_contents = f"""\
  <!-- {AUTOGENERATED_PROMPT} -->
  
  These demos are displayed with detailed descriptions in the documentation: {link}
  
  {listing}
  
  {suffix}"""
  
          separate_compare_overwrite(
              readme,
              DOCS_LINK_SEPARATOR,
              action=action,
              new_middle=new_contents,
              label="docs link",
          )
  
imports: import abc
  import argparse
  import contextlib
  import difflib
  import enum
  import glob
  import itertools
  import json
  import nbformat
  import os.path
  import re
  import subprocess
  import sys
  import textwrap
label_desc: Use image node_id 9 for calling a global function with example usage: demo_indexing(action) without return types