Beispiel #1
0
def main(module_list):
    options = {'target':None, 'modules':list(module_list), 'verbosity':1,
               'prj_name':'', 'action':'html', 'tests':{'basic':1},
               'show_imports':0, 'frames':1, 'private':None,
               'list_classes_separately': 0, 'debug':0,
               'docformat':None, 'top':None, 'inheritance': None,
               'ignore_param_mismatch': 0, 'alphabetical': 1}


    modules=_import(options['modules'],1)

    # Record the order of the modules in options.
    from epydoc.uid import make_uid
    muids = []
    for m in modules:
        try:
            muids.append(make_uid(m))
        except:
            raise
            if sys.stderr.softspace: print >>sys.stderr
            print >>sys.stderr, 'Failed to create a UID for %s' % m

    # Build their documentation
    docmap = _make_docmap(modules, options)
    f=Formatter(docmap)
    print f.format(module_list)
Beispiel #2
0
def cli():
    """
    Command line interface for epydoc.
    
    @rtype: C{None}
    """
    # Parse the command line arguments.
    options = _parse_args()

    # Import all the specified modules.
    modules = _import(options['modules'], options['verbosity'])

    # Record the order of the modules in options.
    from epydoc.uid import make_uid
    options['modules'] = muids = []
    for m in modules:
        try:
            muids.append(make_uid(m))
        except:
            if sys.stderr.softspace: print >>sys.stderr
            print >>sys.stderr, 'Failed to create a UID for %s' % m

    # Build their documentation
    docmap = _make_docmap(modules, options)

    # Perform the requested action.
    if options['action'] == 'html': _html(docmap, options)
    elif options['action'] == 'check': _check(docmap, options)
    elif options['action'] == 'latex': _latex(docmap, options, 'latex')
    elif options['action'] == 'dvi': _latex(docmap, options, 'dvi')
    elif options['action'] == 'ps': _latex(docmap, options, 'ps')
    elif options['action'] == 'pdf': _latex(docmap, options, 'pdf')
    else: raise ValueError('Unknown action %r' % options['action'])

    # Report any internal errors.
    if _encountered_internal_error:
        estr = ("!! An internal error occured.  To see the exception "+
                "that caused the !!\n!! error, use the '--debug' "+
                "option.                                 !!")
        print >>sys.stderr, '\n'+'!'*70
        print >>sys.stderr, estr
        print >>sys.stderr, '!'*70+'\n'
Beispiel #3
0
def main(module_list):
    options = {
        'target': None,
        'modules': list(module_list),
        'verbosity': 1,
        'prj_name': '',
        'action': 'html',
        'tests': {
            'basic': 1
        },
        'show_imports': 0,
        'frames': 1,
        'private': None,
        'list_classes_separately': 0,
        'debug': 0,
        'docformat': None,
        'top': None,
        'inheritance': None,
        'ignore_param_mismatch': 0,
        'alphabetical': 1
    }

    modules = _import(options['modules'], 1)

    # Record the order of the modules in options.
    from epydoc.uid import make_uid
    muids = []
    for m in modules:
        try:
            muids.append(make_uid(m))
        except:
            raise
            if sys.stderr.softspace: print >> sys.stderr
            print >> sys.stderr, 'Failed to create a UID for %s' % m

    # Build their documentation
    docmap = _make_docmap(modules, options)
    f = Formatter(docmap)
    print f.format(module_list)
Beispiel #4
0
def epydoc_object__init__(self, uid, verbosity=0):
        cls = uid.value()
        # Variables:
        self._tmp_ivar = {}
        self._tmp_cvar = {}
        self._tmp_type = {}
        self._property_type = {}

        ObjDoc.__init__(self, uid, verbosity)

        # Handle methods & class variables
        self._methods = []
        self._cvariables = []
        self._ivariables = []
        self._staticmethods = []
        self._classmethods = []
        self._properties = []

        # Find the order that bases are searched in.
        base_order =  _find_base_order(cls)
        self._base_order = [make_uid(b) for b in base_order]

        try: fields = dir(cls)
        except: fields = []
        for field in fields:
            # Don't do anything for these special variables:
            # this is fenix changes
            docstring = ''
            try:
                docstring = getattr(cls, field).__doc__
            except:
                pass
            if field in ('__doc__', '__module__', '__dict__',
                         '__weakref__', '__basicnew__', '__reduce__','__repr__')\
            or (not field.startswith('__') and docstring in ( "PermissionRole",
                                                              "Default Accessor.",
                                                              "Default Mutator.",
                                                              "Default Edit Accessor."
                                                            )):
                continue

            # Find the class that defines the field; and get the value
            # directly from that class (so methods & variables have
            # the right uids).
            (val, container) = _lookup_class_field(cls, field, base_order)

            linkname = field
            private_prefix = '_%s__' % container.shortname()
            if field.startswith(private_prefix):
                if container == self._uid:
                    # If it's private and belongs to this class, then
                    # undo the private name mangling.
                    linkname = linkname[len(private_prefix)-2:]
                else:
                    # If it's private, and belongs to a parent class,
                    # then don't even list it here.
                    continue

            # Deal with static/class methods and properties. (Python 2.2)
            try:
                # Get the un-munged value.
                try: rawval = container.value().__dict__.get(field)
                except: pass

                if isinstance(rawval, staticmethod):
                    vuid = make_uid(rawval, container, linkname)
                    vlink = Link(linkname, vuid)
                    self._staticmethods.append(vlink)
                    continue
                elif isinstance(rawval, classmethod):
                    vuid = make_uid(rawval, container, linkname)
                    vlink = Link(linkname, vuid)
                    self._classmethods.append(vlink)
                    continue
                elif isinstance(rawval, property):
                    vuid = make_uid(rawval, container, linkname)
                    vlink = Link(linkname, vuid)
                    self._properties.append(vlink)
                    continue
            except NameError: pass

            # Create a UID and Link for the field value.
            vuid = make_uid(val, container, linkname)
            vlink = Link(linkname, vuid)

            # Don't do anything if it doesn't have a full-path UID.
            if vuid is None: continue
            # Don't do anything for modules.
            if vuid.is_module(): continue

            # Is it a method?
            if vuid.is_routine():
                self._methods.append(vlink)

            elif container == self._uid:
                # Is it an instance variable?
                if self._tmp_ivar.has_key(field):
                    descr = self._tmp_ivar[field]
                    del self._tmp_ivar[field]
                    typ = self._tmp_type.get(field)
                    if typ is not None: del self._tmp_type[field]
                    else: typ = markup.parse_type_of(val)
                    self._ivariables.append(Var(field, vuid, descr, typ, 1))

                # Is it a class variable?
                else:
                    autogen = 1 # is it autogenerated?
                    descr = self._tmp_cvar.get(field)
                    if descr is not None:
                        del self._tmp_cvar[field]
                        autogen = 0
                    typ = self._tmp_type.get(field)
                    if typ is not None:
                        del self._tmp_type[field]
                        autogen = 0
                    else: typ = markup.parse_type_of(val)
                    self._cvariables.append(Var(field, vuid, descr,
                                                typ, 1, autogen))

        # Keep track of types for properties.
        for prop in self._properties:
            name = prop.name()
            typ = self._tmp_type.get(name)
            if typ is not None:
                if prop.target().cls() != self._uid:
                    estr = "@type can't be used on an inherited properties"
                    self._field_warnings.append(estr)
                self._property_type[prop.target()] = typ
                del self._tmp_type[name]

        # Add the remaining class variables
        for (name, descr) in self._tmp_cvar.items():
            typ = self._tmp_type.get(name)
            if typ is not None: del self._tmp_type[name]
            vuid = make_uid(None, self._uid, name)
            self._cvariables.append(Var(name, vuid, descr, typ, 0))

        # Add the instance variables.
        for (name, descr) in self._tmp_ivar.items():
            typ = self._tmp_type.get(name)
            if typ is not None: del self._tmp_type[name]
            vuid = make_uid(None, self._uid, name)
            self._ivariables.append(Var(name, vuid, descr, typ, 0))

        # Make sure we used all the type fields.
        if self._tmp_type:
            for key in self._tmp_type.keys():
                estr = '@type for unknown variable %s' % key
                self._field_warnings.append(estr)
        del self._tmp_ivar
        del self._tmp_cvar
        del self._tmp_type

        # Add links to base classes.
        try: bases = cls.__bases__
        except AttributeError: bases = []
        self._bases = [Link(base.__name__, make_uid(base)) for base in bases
                       if (type(base) in (types.ClassType, _ZopeType) or
                           (isinstance(base, types.TypeType)))]

        # Initialize subclass list.  (Subclasses get added
        # externally with add_subclass())
        self._subclasses = []

        # Is it an exception?
        try: self._is_exception = issubclass(cls, Exception)
        except TypeError: self._is_exception = 0

        # Inherited variables (added externally with inherit())
        self._inh_cvariables = []
        self._inh_ivariables = []

        # Assemble a list of all methods
        self._allmethods = (self._methods) #XXX+ self._classmethods +
                            #self._staticmethods)

        # Put everything in sorted order.
        self._methods = self._sort(self._methods)
        self._classmethods = self._sort(self._classmethods)
        self._staticmethods = self._sort(self._staticmethods)
        self._properties = self._sort(self._properties)
        self._cvariables = self._sort(self._cvariables)
        self._ivariables = self._sort(self._ivariables)
        self._bases = self._sort(self._bases)
        self._subclasses = self._sort(self._subclasses)
        self._allmethods = self._sort(self._allmethods)

        # Print out any errors/warnings that we encountered.
        self._print_errors()