code: def write_module_docs(pkgname, modpath, tmpltpath, outpath):
      
  
      dw = DocWriter(outpath, tmpltpath)
  
      modlst = get_module_names(modpath, pkgname)
      print('Making api docs:', end='')
      for modname in modlst:
  
          # Don't generate docs for cupy or cuda subpackages
          if 'cupy' in modname or 'cuda' in modname:
              continue
  
          try:
              mod = importlib.import_module(modname)
          except ModuleNotFoundError:
              print('Error importing module %s' % modname)
              continue
  
          # Skip any virtual modules created by the copy-and-patch
          # approach in sporco.cupy. These should already have been
          # skipped due to the test for cupy above.
          if mod.__file__ == 'patched':
              continue
  
          # Construct api docs for the current module if the docs file
          # does not exist, or if its source file has been updated more
          # recently than an existing docs file
          if hasattr(mod, '__path__'):
              srcpath = mod.__path__[0]
          else:
              srcpath = mod.__file__
          dstpath = os.path.join(outpath, modname + '.rst')
  
          if is_newer_than(srcpath, dstpath):
              print(' %s' % modname, end='')
              dw.write(mod)
  
      print('')
docs: Write the autosummary style docs for the specified package.
  
      Parameters
      ----------
      pkgname : string
        Name of package to document
      modpath : string
        Path to package source root directory
      tmpltpath : string
        Directory path for autosummary template files
      outpath : string
        Directory path for RST output files