code: def organize_docs(d):
      organized = {
          "building": {},
          "components": {},
          "helpers": {},
          "modals": {},
          "routes": {},
          "events": {},
          "py-client": {},
          "chatinterface": {},
      }
      pages = []
      for mode in d:
          for c in d[mode]:
              c["parent"] = "gradio"
              c["class"] = None
              if "returns" in c:
                  c["returns"]["annotation"] = None
              for p in c.get("parameters", []):
                  p["annotation"] = str(p["annotation"])
                  if "default" in p:
                      p["default"] = str(p["default"])
              for f in c["fns"]:
                  f["fn"] = None
                  f["parent"] = "gradio." + c["name"]
                  for p in f.get("parameters", []):
                      p["annotation"] = str(p["annotation"])
                      if "default" in p:
                          p["default"] = str(p["default"])
              if mode == "component":
                  organized["components"][c["name"].lower()] = c
                  pages.append(c["name"].lower())
              elif mode in [
                  "helpers",
                  "routes",
                  "py-client",
                  "chatinterface",
                  "modals",
              ]:
                  organized[mode][c["name"].lower()] = c
                  pages.append(c["name"].lower())
  
              else:
                  # if mode not in organized["building"]:
                  #     organized["building"][mode] = {}
                  organized["building"][c["name"].lower()] = c
                  pages.append(c["name"].lower())
  
      c_keys = list(organized["components"].keys())
      for i, cls in enumerate(organized["components"]):
          if not i:
              organized["components"][cls]["prev_obj"] = "Components"
              organized["components"][cls]["next_obj"] = organized[
                  "components"
              ][c_keys[1]]["name"]
          elif i == len(c_keys) - 1:
              organized["components"][cls]["prev_obj"] = organized[
                  "components"
              ][c_keys[len(c_keys) - 2]]["name"]
              organized["components"][cls]["next_obj"] = "load"
          else:
              organized["components"][cls]["prev_obj"] = organized[
                  "components"
              ][c_keys[i - 1]]["name"]
              organized["components"][cls]["next_obj"] = organized[
                  "components"
              ][c_keys[i + 1]]["name"]
      c_keys = list(organized["helpers"].keys())
      for i, cls in enumerate(organized["helpers"]):
          if not i:
              organized["helpers"][cls]["prev_obj"] = "Video"
              organized["helpers"][cls]["next_obj"] = organized[
                  "helpers"
              ][c_keys[1]]["name"]
          elif i == len(c_keys) - 1:
              organized["helpers"][cls]["prev_obj"] = organized[
                  "helpers"
              ][c_keys[len(c_keys) - 2]]["name"]
              organized["helpers"][cls]["next_obj"] = "Error"
          else:
              organized["helpers"][cls]["prev_obj"] = organized[
                  "helpers"
              ][c_keys[i - 1]]["name"]
              organized["helpers"][cls]["next_obj"] = organized[
                  "helpers"
              ][c_keys[i + 1]]["name"]
      c_keys = list(organized["modals"].keys())
      for i, cls in enumerate(organized["modals"]):
          if not i:
              organized["modals"][cls]["prev_obj"] = "EventData"
              organized["modals"][cls]["next_obj"] = organized[
                  "modals"
              ][c_keys[1]]["name"]
          elif i == len(c_keys) - 1:
              organized["modals"][cls]["prev_obj"] = organized[
                  "modals"
              ][c_keys[len(c_keys) - 2]]["name"]
              organized["modals"][cls]["next_obj"] = "Request"
          else:
              organized["modals"][cls]["prev_obj"] = organized[
                  "modals"
              ][c_keys[i - 1]]["name"]
              organized["modals"][cls]["next_obj"] = organized[
                  "modals"
              ][c_keys[i + 1]]["name"]
  
      c_keys = list(organized["routes"].keys())
      for i, cls in enumerate(organized["routes"]):
          if not i:
              organized["routes"][cls]["prev_obj"] = "Info"
              organized["routes"][cls]["next_obj"] = organized[
                  "routes"
              ][c_keys[1]]["name"]
          elif i == len(c_keys) - 1:
              organized["routes"][cls]["prev_obj"] = organized[
                  "routes"
              ][c_keys[len(c_keys) - 2]]["name"]
              organized["routes"][cls]["next_obj"] = "Flagging"
          else:
              organized["routes"][cls]["prev_obj"] = organized[
                  "routes"
              ][c_keys[i - 1]]["name"]
              organized["routes"][cls]["next_obj"] = organized[
                  "routes"
              ][c_keys[i + 1]]["name"]
      c_keys = list(organized["py-client"].keys())
      for i, cls in enumerate(organized["py-client"]):
          if not i:
              organized["py-client"][cls]["prev_obj"] = "Python-Client"
              organized["py-client"][cls]["next_obj"] = organized[
                  "py-client"
              ][c_keys[1]]["name"]
          elif i == len(c_keys) - 1:
              organized["py-client"][cls]["prev_obj"] = organized[
                  "py-client"
              ][c_keys[len(c_keys) - 2]]["name"]
              organized["py-client"][cls]["next_obj"] = "JS-Client"
          else:
              organized["py-client"][cls]["prev_obj"] = organized[
                  "py-client"
              ][c_keys[i - 1]]["name"]
              organized["py-client"][cls]["next_obj"] = organized[
                  "py-client"
              ][c_keys[i + 1]]["name"]
  
      for cls in organized["chatinterface"]:
          organized["chatinterface"][cls]["prev_obj"] = "Block-Layouts"
          organized["chatinterface"][cls]["next_obj"] = "Themes"
  
      layout_keys = ["row", "column", "tab", "group", "accordion"]
      for i, cls in enumerate(layout_keys):
          if not i:
              organized["building"][cls]["prev_obj"] = "Blocks"
              organized["building"][cls]["next_obj"] = layout_keys[
                  i + 1
              ].capitalize()
          elif i == len(layout_keys) - 1:
              organized["building"][cls]["prev_obj"] = layout_keys[
                  i - 1
              ].capitalize()
              organized["building"][cls]["next_obj"] = "Components"
          else:
              organized["building"][cls]["prev_obj"] = layout_keys[
                  i - 1
              ].capitalize()
              organized["building"][cls]["next_obj"] = layout_keys[
                  i + 1
              ].capitalize()
  
      organized["building"][cls]["prev_obj"]
  
      organized["events_matrix"] = component_events
      organized["events"] = events
  
      js = {}
      js_pages = []
  
      for js_component in os.listdir(JS_DIR):
          if not js_component.startswith("_") and js_component not in [
              "app",
              "highlighted-text",
              "playground",
              "preview",
              "upload-button",
              "theme",
              "tootils",
          ]:
              if os.path.exists(
                  os.path.join(JS_DIR, js_component, "package.json")
              ):
                  with open(
                      os.path.join(JS_DIR, js_component, "package.json")
                  ) as f:
                      package_json = json.load(f)
                      if package_json.get("private", False):
                          continue
              if os.path.exists(
                  os.path.join(JS_DIR, js_component, "README.md")
              ):
                  with open(
                      os.path.join(JS_DIR, js_component, "README.md")
                  ) as f:
                      readme_content = f.read()
  
                  try:
                      latest_npm = requests.get(
                          f"https://registry.npmjs.org/@gradio/{js_component}/latest"
                      ).json()["version"]
                      latest_npm = f" [v{latest_npm}](https://www.npmjs.com/package/@gradio/{js_component})"
                      readme_content = readme_content.split("\n")
                      readme_content = "\n".join(
                          [
                              readme_content[0],
                              latest_npm,
                              *readme_content[1:],
                          ]
                      )
                  except TypeError:
                      pass
  
                  js[js_component] = readme_content
                  js_pages.append(js_component)
  
      with open(JS_CLIENT_README) as f:
          readme_content = f.read()
      js_pages.append("js-client")
  
      js["js-client"] = readme_content
  
      js_pages.sort()
  
      return {
          "docs": organized,
          "pages": pages,
          "js": js,
          "js_pages": js_pages,
          "js_client": readme_content,
      }
  
file_path: gradio/js/_website/generate_jsons/src/docs/__init__.py
imports: import html
  import json
  import os
  from gradio_client.documentation import document_cls, generate_documentation
  import gradio
  from ..guides import guides
  import requests
label_desc: Use image node_id 9 for calling a global function with example usage: organize_docs(d) and returns: dict