Document a module

    Parameters
    ----------
    module_name : str
    module : module
    output_dir : str
    source_location : str
    leaf : bool
342019
def doc_module(module_name, module, output_dir, source_location, leaf):
    
    path = pathlib.Path(output_dir).joinpath(*module.__name__.split("."))
    available_classes = get_available_classes(module)
    deffed_classes = get_classes(module)
    deffed_funcs = get_funcs(module)
    deffed_enums = get_enums(module)
    alias_funcs = available_classes - deffed_classes
    if leaf:
        doc_path = path.with_suffix(".md")
    else:
        doc_path = path / "index.md"
    doc_path.parent.mkdir(parents=True, exist_ok=True)
    module_path = "/".join(module.__name__.split("."))
    doc = [f"title: {module_name.split('.')[-1]}" + "\n"]
    module_doc = module.__doc__

    # Module overview documentation
    if module_doc is not None:
        doc += to_doc(module.__name__, module, 1, source_location)
    else:
        doc.append(f"# {module.__name__}\n\n")
    doc.append("\n\n")
    for cls_name, cls in sorted(deffed_enums) + sorted(deffed_classes):
        doc += to_doc(cls_name, cls, 2, source_location)

        class_methods = [
            x
            for x in inspect.getmembers(cls, inspect.isfunction)
            if (not x[0].startswith("_")) and deffed_here(x[1], cls)
        ]
        class_methods += inspect.getmembers(cls, lambda o: isinstance(o, property))
        if len(class_methods) > 0:
            doc.append("### Methods \n\n")
            for method_name, method in class_methods:
                doc += to_doc(method_name, method, 4, source_location)
    for fname, func in sorted(deffed_funcs):
        doc += to_doc(fname, func, 2, source_location)
    return doc_path.absolute(), "".join(doc)
248031
def qualname(self) -> str:
        
        if self.module:
            return self.module + '.' + self.name
        return self.name
1216544
def visit_module(self, node):
        """"""
        docs = '"""%s"""\n\n' % node.doc if node.doc else ""
        return docs + "\n".join(n.accept(self) for n in node.body) + "\n\n"
556339
def find_module(self, modname, folder=None):
        
        for src in self.get_source_folders():
            module = _find_module_in_folder(src, modname)
            if module is not None:
                return module
        for src in self.get_python_path_folders():
            module = _find_module_in_folder(src, modname)
            if module is not None:
                return module
        if folder is not None:
            module = _find_module_in_folder(folder, modname)
            if module is not None:
                return module
        return None
830770
def get_module_path(module_name):
    
    path = sys.path
    for name in module_name.split('.'):
        file_pointer, path, desc = imp.find_module(name, path)
        path = [path, ]
        if file_pointer is not None:
            file_pointer.close()

    return path[0]
667590
def aboutModule( module, parent = None, logo = '' ):
        
        
        dlg = XAboutDialog( parent )
        dlg.setLogo( logo )
        dlg.setInfo( XAboutDialog.moduleInfo(module) )
        
        dlg.exec_()
1034499
def append_summary_to_module_docstring(module):
  
  pairs = [(name, getattr(module, name)) for name in module.__all__]
  kws = dict(key_header="Name", summary_type="module contents")
  module.__doc__ = docstring_with_summary(module.__doc__, pairs, **kws)
521174
function loadAndDescribeModuleInCwd() {
// Hack: Trick node into changing process.mainScript to moduleToDebug
  moduleToDebug = Module._load(location, module, true);

  var sample = getSampleCommand();
  sampleLine = util.format('You can access your module as `m`%s.', sample);

  prompt = getModuleName() + '> ';
}
1096672
def show_doc_from_name(mod_name, ft_name:str, doc_string:bool=True, arg_comments:dict={}, alt_doc_string:str=''):
    ""
    mod = import_mod(mod_name)
    splits = str.split(ft_name, '.')
    assert hasattr(mod, splits[0]), print(f"Module {mod_name} doesn't have a function named {splits[0]}.")
    elt = getattr(mod, splits[0])
    for i,split in enumerate(splits[1:]):
        assert hasattr(elt, split), print(f"Class {'.'.join(splits[:i+1])} doesn't have a function named {split}.")
        elt = getattr(elt, split)
    show_doc(elt, doc_string, ft_name, arg_comments, alt_doc_string)
415286
function outputModuleDefinitions (module, headWasOutput)
  {
    for (var i = 0, m = module.bodies.length; i < m; ++i) {
      var bodyPath = module.bodyPaths[i];
      if (!bodyPath)
        console.log (module.name, i, module.bodies.length, module.bodyPaths);
      // Skip bodies who's corresponding file was already output.
      if (context.outputtedFiles[bodyPath])
        continue;
      context.outputtedFiles[bodyPath] = true;

      var body = module.optimize ?
        optimize (module.bodies[i], bodyPath, module)
        : {status: STAT.INDENTED, data: module.bodies[i]};

      if (i || !headWasOutput)
        traceOutput.push (LINE, '// File: ' + bodyPath, LINE, '');
      traceOutput.push (conditionalIndent (body));
    }
  }
1126340
function processFile(argv, inputPath, opt_outputPath) {
  // Setup output path.
  var outputPath = opt_outputPath;
  if (!opt_outputPath) {
    var ext = path.extname(inputPath);
    if (ext.length) {
      outputPath = inputPath.substr(0, inputPath.length - ext.length) +
          '.instrumented' + ext;
    } else {
      outputPath = inputPath + '.instrumented.js';
    }
  }

  var sourceCode = fs.readFileSync(inputPath).toString();

  // TODO(benvanik): support setting the module ID?
  var targetCode = transformCode(0, inputPath, sourceCode, argv);

  console.log('Writing ' + outputPath + '...');
  fs.writeFileSync(outputPath, targetCode);
  fs.chmodSync(outputPath, fs.statSync(inputPath).mode);
}
409229
def get_mod_paths(mod_name, out_dir):
    """"""
    paths = []
    try:
        mod = get_loader(mod_name)
        source = Path(mod.path)
        if source.name.endswith(".py"):
            source_rel = Path(*mod_name.split("."))
            if source.name == "__init__.py":
                source_rel = source_rel.joinpath("__init__.py")
            destination = Path(out_dir, source_rel.with_suffix(".pyi"))
            paths.append((source, destination))
    except Exception as e:
        _logger.debug(e)
        _logger.warning("cannot handle module, skipping: %s", mod_name)
    return paths
872996
def __RenderOurModuleFlags(self, module, output_lines, prefix=''):
    """"""
    flags = self._GetFlagsDefinedByModule(module)
    if flags:
      self.__RenderModuleFlags(module, flags, output_lines, prefix)
457669
def visit_Module(self, node, **kwargs):
        
        containingNodes=kwargs.get('containingNodes', [])
        if self.options.debug:
            stderr.write("# Module {0}{1}".format(self.options.fullPathNamespace,
                                                  linesep))
        if get_docstring(node):
            if self.options.topLevelNamespace:
                fullPathNamespace = self._getFullPathName(containingNodes)
                contextTag = '.'.join(pathTuple[0] for pathTuple in fullPathNamespace)
                tail = '@namespace {0}'.format(contextTag)
            else:
                tail = ''
            self._processDocstring(node, tail)
        # Visit any contained nodes (in this case pretty much everything).
        self.generic_visit(node, containingNodes=containingNodes)
541589
def map_from_module(self, module):
        
        maps = {}
        for name in dir(module):
            obj = getattr(module, name)
            try:
                if issubclass(obj, exceptions.HTTPException):
                    maps[name] = obj
            except TypeError as ter:
                pass
        self.mapping.update(maps)
176288
def module_working_directory(self, module_name):
        

        workdir = self.module_working_path(module_name)
        if not self._deleted:
            try:
                os.makedirs(workdir, exist_ok=True)
            except OSError as e:
                raise aiohttp.web.HTTPInternalServerError(text="Could not create module working directory: {}".format(e))
        return workdir
1331246
def _write_docs(module_list, output_dir):
    ''''''
    for module_meta in module_list:
        directory = module_meta['directory']
        # Ensure target directory
        if directory and not path.isdir(directory):
            makedirs(directory)

        # Write the file
        file = open(module_meta['output'], 'w')
        file.write(module_meta['content'])
        file.close()