code: def doc2rst(algo_doc, sphinxsearch=False):
      if sphinxsearch:
          # dummy rst files used to append algorithms to the sphinx HTML search
          lines = [":orphan:", ""]
          header = (
              "Algorithm reference - "
              + algo_doc["name"]
              + " ("
              + algo_doc["mode"]
              + ")"
          )
          lines += [header, "=" * len(header), ""]
      else:
          # actual rst files used to render HTMLs
          lines = [algo_doc["name"], "=" * len(algo_doc["name"]), ""]
          lines += [
              algo_doc["mode"]
              + " | "
              + algo_doc["category"]
              + " category",
              "",
          ]
  
      if algo_doc["inputs"]:
          lines += ["Inputs", "------", ""]
  
          for inp in algo_doc["inputs"]:
              lines.append(
                  " - ``%s`` (*%s*) - %s"
                  % (inp["name"], inp["type"], TR(inp["description"]))
              )
  
          lines.append("")
  
      if algo_doc["outputs"]:
          lines += ["Outputs", "-------", ""]
  
          for out in algo_doc["outputs"]:
              lines.append(
                  " - ``%s`` (*%s*) - %s"
                  % (out["name"], out["type"], TR(out["description"]))
              )
  
          lines.append("")
  
      if algo_doc["parameters"]:
          lines += ["Parameters", "----------", ""]
  
          for param in algo_doc["parameters"]:
              range_str = param["type"]
              if param["range"] is not None:
                  range_str += " ∈ " + TR(
                      param["range"].replace(",", ", ")
                  )
              if param["default"] is not None:
                  range_str += ", default = " + TR(param["default"])
  
              lines.append(
                  " - ``%s`` (*%s*) :" % (param["name"], range_str)
              )
              lines.append("     " + TR(param["description"]))
  
          lines.append("")
  
      lines += [
          "Description",
          "-----------",
          "",
          TR_DESC(algo_doc["description"]),
      ]
  
      lines += related_algos(algo_doc)
  
      return "\n".join(lines)
  
file_path: essentia/doc/sphinxdoc/generate_reference.py
imports: import essentia.standard
  import essentia.streaming
  import os, re, subprocess
  import sys
label_desc: Use image node_id 6 for calling a global function with example usage: doc2rst(algo_doc, sphinxsearch) and returns: str