code: def __init__(self, library):
      self.library = library
  
      path_index = {}
      rename_index = {}
  
      # Either modules are defined in the module's __init__.py...
      modules = dict(
          inspect.getmembers(
              importlib.import_module(library), inspect.ismodule
          )
      )
      # ... either they're defined in an api.py file
      modules.update(
          dict(
              inspect.getmembers(
                  importlib.import_module(f"{library}.api"),
                  inspect.ismodule,
              )
          )
      )
  
      def index_module(mod_name, mod, path):
          path = os.path.join(path, mod_name)
          dotted_path = path.replace("/", ".")
  
          for func_name, func in inspect.getmembers(
              mod, inspect.isfunction
          ):
              for e in (
                  f"{mod_name}.{func_name}",
                  f"{dotted_path}.{func_name}",
                  f"{func.__module__}.{func_name}",
              ):
                  path_index[e] = os.path.join(
                      path, snake_to_kebab(func_name)
                  )
                  rename_index[e] = f"{dotted_path}.{func_name}"
  
          for klass_name, klass in inspect.getmembers(
              mod, inspect.isclass
          ):
              for e in (
                  f"{mod_name}.{klass_name}",
                  f"{dotted_path}.{klass_name}",
                  f"{klass.__module__}.{klass_name}",
              ):
                  path_index[e] = os.path.join(path, klass_name)
                  rename_index[e] = f"{dotted_path}.{klass_name}"
  
          for submod_name, submod in inspect.getmembers(
              mod, inspect.ismodule
          ):
              if (
                  submod_name not in mod.__all__
                  or submod_name == "typing"
              ):
                  continue
              for e in (
                  f"{mod_name}.{submod_name}",
                  f"{dotted_path}.{submod_name}",
              ):
                  path_index[e] = os.path.join(
                      path, snake_to_kebab(submod_name)
                  )
  
              # Recurse
              index_module(submod_name, submod, path=path)
  
      for mod_name, mod in modules.items():
          index_module(mod_name, mod, path="")
  
      # Prepend the name of the library to each index entry
      for k in list(path_index.keys()):
          path_index[f"{self.library}.{k}"] = path_index[k]
      for k in list(rename_index.keys()):
          rename_index[f"{self.library}.{k}"] = rename_index[k]
  
      # HACK: replace underscores with dashes in links
      for k, v in path_index.items():
          path_index[k] = v.replace("_", "-")
  
      self.path_index = path_index
      self.rename_index = rename_index
  
imports: import argparse
  import collections
  import doctest
  import functools
  import importlib
  import inspect
  import os
  import pathlib
  import re
  import shutil
  from numpydoc.docscrape import ClassDoc, FunctionDoc
label_desc: Use image node_id 1 to create a new Linkifier object  with example: obj = Linkifier(library)