Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes
pydoc.HTMLDoc Class Reference
Inheritance diagram for pydoc.HTMLDoc:
Inheritance graph
[legend]
Collaboration diagram for pydoc.HTMLDoc:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def page
def heading
def section
def bigsection
def preformat
def multicolumn
def grey
def namelink
def classlink
def modulelink
def modpkglink
def filelink
def markup
def formattree
def docmodule
def docclass
def formatvalue
def docroutine
def docproperty
def docother
def docdata
def index
def document
def fail
def getdocloc

Public Attributes

 needone

Static Public Attributes

 repr = _repr_instance.repr
 escape = _repr_instance.escape
tuple PYTHONDOCS
 docmodule = docclassdocroutinedocotherdocpropertydocdatafail

Private Member Functions

def _docdescriptor

Static Private Attributes

tuple _repr_instance = HTMLRepr()

Detailed Description

Formatter class for HTML documentation.

Definition at line 425 of file pydoc.py.


Member Function Documentation

def pydoc.HTMLDoc._docdescriptor (   self,
  name,
  value,
  mod 
) [private]

Definition at line 923 of file pydoc.py.

00923 
00924     def _docdescriptor(self, name, value, mod):
00925         results = []
00926         push = results.append
00927 
00928         if name:
00929             push('<dl><dt><strong>%s</strong></dt>\n' % name)
00930         if value.__doc__ is not None:
00931             doc = self.markup(getdoc(value), self.preformat)
00932             push('<dd><tt>%s</tt></dd>\n' % doc)
00933         push('</dl>\n')
00934 
00935         return ''.join(results)

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLDoc.bigsection (   self,
  title,
  args 
)
Format a section with a big heading.

Definition at line 477 of file pydoc.py.

00477 
00478     def bigsection(self, title, *args):
00479         """Format a section with a big heading."""
00480         title = '<big><strong>%s</strong></big>' % title
00481         return self.section(title, *args)

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLDoc.classlink (   self,
  object,
  modname 
)
Make a link for a class.

Definition at line 509 of file pydoc.py.

00509 
00510     def classlink(self, object, modname):
00511         """Make a link for a class."""
00512         name, module = object.__name__, sys.modules.get(object.__module__)
00513         if hasattr(module, name) and getattr(module, name) is object:
00514             return '<a href="%s.html#%s">%s</a>' % (
00515                 module.__name__, name, classname(object, modname))
00516         return classname(object, modname)

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLDoc.docclass (   self,
  object,
  name = None,
  mod = None,
  funcs = {},
  classes = {},
  ignored 
)
Produce HTML documentation for a class object.

Definition at line 722 of file pydoc.py.

00722 
00723                  *ignored):
00724         """Produce HTML documentation for a class object."""
00725         realname = object.__name__
00726         name = name or realname
00727         bases = object.__bases__
00728 
00729         contents = []
00730         push = contents.append
00731 
00732         # Cute little class to pump out a horizontal rule between sections.
00733         class HorizontalRule:
00734             def __init__(self):
00735                 self.needone = 0
00736             def maybe(self):
00737                 if self.needone:
00738                     push('<hr>\n')
00739                 self.needone = 1
00740         hr = HorizontalRule()
00741 
00742         # List the mro, if non-trivial.
00743         mro = deque(inspect.getmro(object))
00744         if len(mro) > 2:
00745             hr.maybe()
00746             push('<dl><dt>Method resolution order:</dt>\n')
00747             for base in mro:
00748                 push('<dd>%s</dd>\n' % self.classlink(base,
00749                                                       object.__module__))
00750             push('</dl>\n')
00751 
00752         def spill(msg, attrs, predicate):
00753             ok, attrs = _split_list(attrs, predicate)
00754             if ok:
00755                 hr.maybe()
00756                 push(msg)
00757                 for name, kind, homecls, value in ok:
00758                     push(self.document(getattr(object, name), name, mod,
00759                                        funcs, classes, mdict, object))
00760                     push('\n')
00761             return attrs
00762 
00763         def spilldescriptors(msg, attrs, predicate):
00764             ok, attrs = _split_list(attrs, predicate)
00765             if ok:
00766                 hr.maybe()
00767                 push(msg)
00768                 for name, kind, homecls, value in ok:
00769                     push(self._docdescriptor(name, value, mod))
00770             return attrs
00771 
00772         def spilldata(msg, attrs, predicate):
00773             ok, attrs = _split_list(attrs, predicate)
00774             if ok:
00775                 hr.maybe()
00776                 push(msg)
00777                 for name, kind, homecls, value in ok:
00778                     base = self.docother(getattr(object, name), name, mod)
00779                     if hasattr(value, '__call__') or inspect.isdatadescriptor(value):
00780                         doc = getattr(value, "__doc__", None)
00781                     else:
00782                         doc = None
00783                     if doc is None:
00784                         push('<dl><dt>%s</dl>\n' % base)
00785                     else:
00786                         doc = self.markup(getdoc(value), self.preformat,
00787                                           funcs, classes, mdict)
00788                         doc = '<dd><tt>%s</tt>' % doc
00789                         push('<dl><dt>%s%s</dl>\n' % (base, doc))
00790                     push('\n')
00791             return attrs
00792 
00793         attrs = [(name, kind, cls, value)
00794                  for name, kind, cls, value in classify_class_attrs(object)
00795                  if visiblename(name, obj=object)]
00796 
00797         mdict = {}
00798         for key, kind, homecls, value in attrs:
00799             mdict[key] = anchor = '#' + name + '-' + key
00800             value = getattr(object, key)
00801             try:
00802                 # The value may not be hashable (e.g., a data attr with
00803                 # a dict or list value).
00804                 mdict[value] = anchor
00805             except TypeError:
00806                 pass
00807 
00808         while attrs:
00809             if mro:
00810                 thisclass = mro.popleft()
00811             else:
00812                 thisclass = attrs[0][2]
00813             attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
00814 
00815             if thisclass is builtins.object:
00816                 attrs = inherited
00817                 continue
00818             elif thisclass is object:
00819                 tag = 'defined here'
00820             else:
00821                 tag = 'inherited from %s' % self.classlink(thisclass,
00822                                                            object.__module__)
00823             tag += ':<br>\n'
00824 
00825             # Sort attrs by name.
00826             attrs.sort(key=lambda t: t[0])
00827 
00828             # Pump out the attrs, segregated by kind.
00829             attrs = spill('Methods %s' % tag, attrs,
00830                           lambda t: t[1] == 'method')
00831             attrs = spill('Class methods %s' % tag, attrs,
00832                           lambda t: t[1] == 'class method')
00833             attrs = spill('Static methods %s' % tag, attrs,
00834                           lambda t: t[1] == 'static method')
00835             attrs = spilldescriptors('Data descriptors %s' % tag, attrs,
00836                                      lambda t: t[1] == 'data descriptor')
00837             attrs = spilldata('Data and other attributes %s' % tag, attrs,
00838                               lambda t: t[1] == 'data')
00839             assert attrs == []
00840             attrs = inherited
00841 
00842         contents = ''.join(contents)
00843 
00844         if name == realname:
00845             title = '<a name="%s">class <strong>%s</strong></a>' % (
00846                 name, realname)
00847         else:
00848             title = '<strong>%s</strong> = <a name="%s">class %s</a>' % (
00849                 name, name, realname)
00850         if bases:
00851             parents = []
00852             for base in bases:
00853                 parents.append(self.classlink(base, object.__module__))
00854             title = title + '(%s)' % ', '.join(parents)
00855         doc = self.markup(getdoc(object), self.preformat, funcs, classes, mdict)
00856         doc = doc and '<tt>%s<br>&nbsp;</tt>' % doc
00857 
00858         return self.section(title, '#000000', '#ffc8d8', contents, 3, doc)

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLDoc.docdata (   self,
  object,
  name = None,
  mod = None,
  cl = None 
)
Produce html documentation for a data descriptor.

Definition at line 945 of file pydoc.py.

00945 
00946     def docdata(self, object, name=None, mod=None, cl=None):
00947         """Produce html documentation for a data descriptor."""
00948         return self._docdescriptor(name, object, mod)

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLDoc.docmodule (   self,
  object,
  name = None,
  mod = None,
  ignored 
)
Produce HTML documentation for a module object.

Definition at line 597 of file pydoc.py.

00597 
00598     def docmodule(self, object, name=None, mod=None, *ignored):
00599         """Produce HTML documentation for a module object."""
00600         name = object.__name__ # ignore the passed-in name
00601         try:
00602             all = object.__all__
00603         except AttributeError:
00604             all = None
00605         parts = name.split('.')
00606         links = []
00607         for i in range(len(parts)-1):
00608             links.append(
00609                 '<a href="%s.html"><font color="#ffffff">%s</font></a>' %
00610                 ('.'.join(parts[:i+1]), parts[i]))
00611         linkedname = '.'.join(links + parts[-1:])
00612         head = '<big><big><strong>%s</strong></big></big>' % linkedname
00613         try:
00614             path = inspect.getabsfile(object)
00615             url = path
00616             if sys.platform == 'win32':
00617                 import nturl2path
00618                 url = nturl2path.pathname2url(path)
00619             filelink = self.filelink(url, path)
00620         except TypeError:
00621             filelink = '(built-in)'
00622         info = []
00623         if hasattr(object, '__version__'):
00624             version = str(object.__version__)
00625             if version[:11] == '$' + 'Revision: ' and version[-1:] == '$':
00626                 version = version[11:-1].strip()
00627             info.append('version %s' % self.escape(version))
00628         if hasattr(object, '__date__'):
00629             info.append(self.escape(str(object.__date__)))
00630         if info:
00631             head = head + ' (%s)' % ', '.join(info)
00632         docloc = self.getdocloc(object)
00633         if docloc is not None:
00634             docloc = '<br><a href="%(docloc)s">Module Reference</a>' % locals()
00635         else:
00636             docloc = ''
00637         result = self.heading(
00638             head, '#ffffff', '#7799ee',
00639             '<a href=".">index</a><br>' + filelink + docloc)
00640 
00641         modules = inspect.getmembers(object, inspect.ismodule)
00642 
00643         classes, cdict = [], {}
00644         for key, value in inspect.getmembers(object, inspect.isclass):
00645             # if __all__ exists, believe it.  Otherwise use old heuristic.
00646             if (all is not None or
00647                 (inspect.getmodule(value) or object) is object):
00648                 if visiblename(key, all, object):
00649                     classes.append((key, value))
00650                     cdict[key] = cdict[value] = '#' + key
00651         for key, value in classes:
00652             for base in value.__bases__:
00653                 key, modname = base.__name__, base.__module__
00654                 module = sys.modules.get(modname)
00655                 if modname != name and module and hasattr(module, key):
00656                     if getattr(module, key) is base:
00657                         if not key in cdict:
00658                             cdict[key] = cdict[base] = modname + '.html#' + key
00659         funcs, fdict = [], {}
00660         for key, value in inspect.getmembers(object, inspect.isroutine):
00661             # if __all__ exists, believe it.  Otherwise use old heuristic.
00662             if (all is not None or
00663                 inspect.isbuiltin(value) or inspect.getmodule(value) is object):
00664                 if visiblename(key, all, object):
00665                     funcs.append((key, value))
00666                     fdict[key] = '#-' + key
00667                     if inspect.isfunction(value): fdict[value] = fdict[key]
00668         data = []
00669         for key, value in inspect.getmembers(object, isdata):
00670             if visiblename(key, all, object):
00671                 data.append((key, value))
00672 
00673         doc = self.markup(getdoc(object), self.preformat, fdict, cdict)
00674         doc = doc and '<tt>%s</tt>' % doc
00675         result = result + '<p>%s</p>\n' % doc
00676 
00677         if hasattr(object, '__path__'):
00678             modpkgs = []
00679             for importer, modname, ispkg in pkgutil.iter_modules(object.__path__):
00680                 modpkgs.append((modname, name, ispkg, 0))
00681             modpkgs.sort()
00682             contents = self.multicolumn(modpkgs, self.modpkglink)
00683             result = result + self.bigsection(
00684                 'Package Contents', '#ffffff', '#aa55cc', contents)
00685         elif modules:
00686             contents = self.multicolumn(
00687                 modules, lambda t: self.modulelink(t[1]))
00688             result = result + self.bigsection(
00689                 'Modules', '#ffffff', '#aa55cc', contents)
00690 
00691         if classes:
00692             classlist = [value for (key, value) in classes]
00693             contents = [
00694                 self.formattree(inspect.getclasstree(classlist, 1), name)]
00695             for key, value in classes:
00696                 contents.append(self.document(value, key, name, fdict, cdict))
00697             result = result + self.bigsection(
00698                 'Classes', '#ffffff', '#ee77aa', ' '.join(contents))
00699         if funcs:
00700             contents = []
00701             for key, value in funcs:
00702                 contents.append(self.document(value, key, name, fdict, cdict))
00703             result = result + self.bigsection(
00704                 'Functions', '#ffffff', '#eeaa77', ' '.join(contents))
00705         if data:
00706             contents = []
00707             for key, value in data:
00708                 contents.append(self.document(value, key))
00709             result = result + self.bigsection(
00710                 'Data', '#ffffff', '#55aa55', '<br>\n'.join(contents))
00711         if hasattr(object, '__author__'):
00712             contents = self.markup(str(object.__author__), self.preformat)
00713             result = result + self.bigsection(
00714                 'Author', '#ffffff', '#7799ee', contents)
00715         if hasattr(object, '__credits__'):
00716             contents = self.markup(str(object.__credits__), self.preformat)
00717             result = result + self.bigsection(
00718                 'Credits', '#ffffff', '#7799ee', contents)
00719 
00720         return result

Here is the call graph for this function:

def pydoc.HTMLDoc.docother (   self,
  object,
  name = None,
  mod = None,
  ignored 
)
Produce HTML documentation for a data object.

Definition at line 940 of file pydoc.py.

00940 
00941     def docother(self, object, name=None, mod=None, *ignored):
00942         """Produce HTML documentation for a data object."""
00943         lhs = name and '<strong>%s</strong> = ' % name or ''
00944         return lhs + self.repr(object)

Here is the caller graph for this function:

def pydoc.HTMLDoc.docproperty (   self,
  object,
  name = None,
  mod = None,
  cl = None 
)
Produce html documentation for a property.

Definition at line 936 of file pydoc.py.

00936 
00937     def docproperty(self, object, name=None, mod=None, cl=None):
00938         """Produce html documentation for a property."""
00939         return self._docdescriptor(name, object, mod)

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLDoc.docroutine (   self,
  object,
  name = None,
  mod = None,
  funcs = {},
  classes = {},
  methods = {},
  cl = None 
)
Produce HTML documentation for a function or method object.

Reimplemented in xmlrpc.server.ServerHTMLDoc.

Definition at line 864 of file pydoc.py.

00864 
00865                    funcs={}, classes={}, methods={}, cl=None):
00866         """Produce HTML documentation for a function or method object."""
00867         realname = object.__name__
00868         name = name or realname
00869         anchor = (cl and cl.__name__ or '') + '-' + name
00870         note = ''
00871         skipdocs = 0
00872         if inspect.ismethod(object):
00873             imclass = object.__self__.__class__
00874             if cl:
00875                 if imclass is not cl:
00876                     note = ' from ' + self.classlink(imclass, mod)
00877             else:
00878                 if object.__self__ is not None:
00879                     note = ' method of %s instance' % self.classlink(
00880                         object.__self__.__class__, mod)
00881                 else:
00882                     note = ' unbound %s method' % self.classlink(imclass,mod)
00883             object = object.__func__
00884 
00885         if name == realname:
00886             title = '<a name="%s"><strong>%s</strong></a>' % (anchor, realname)
00887         else:
00888             if (cl and realname in cl.__dict__ and
00889                 cl.__dict__[realname] is object):
00890                 reallink = '<a href="#%s">%s</a>' % (
00891                     cl.__name__ + '-' + realname, realname)
00892                 skipdocs = 1
00893             else:
00894                 reallink = realname
00895             title = '<a name="%s"><strong>%s</strong></a> = %s' % (
00896                 anchor, name, reallink)
00897         if inspect.isfunction(object):
00898             args, varargs, kwonlyargs, kwdefaults, varkw, defaults, ann = \
00899                 inspect.getfullargspec(object)
00900             argspec = inspect.formatargspec(
00901                 args, varargs, kwonlyargs, kwdefaults, varkw, defaults, ann,
00902                 formatvalue=self.formatvalue,
00903                 formatannotation=inspect.formatannotationrelativeto(object))
00904             if realname == '<lambda>':
00905                 title = '<strong>%s</strong> <em>lambda</em> ' % name
00906                 # XXX lambda's won't usually have func_annotations['return']
00907                 # since the syntax doesn't support but it is possible.
00908                 # So removing parentheses isn't truly safe.
00909                 argspec = argspec[1:-1] # remove parentheses
00910         else:
00911             argspec = '(...)'
00912 
00913         decl = title + argspec + (note and self.grey(
00914                '<font face="helvetica, arial">%s</font>' % note))
00915 
00916         if skipdocs:
00917             return '<dl><dt>%s</dt></dl>\n' % decl
00918         else:
00919             doc = self.markup(
00920                 getdoc(object), self.preformat, funcs, classes, methods)
00921             doc = doc and '<dd><tt>%s</tt></dd>' % doc
00922             return '<dl><dt>%s</dt>%s</dl>\n' % (decl, doc)

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.Doc.document (   self,
  object,
  name = None,
  args 
) [inherited]
Generate documentation for an object.

Definition at line 328 of file pydoc.py.

00328 
00329     def document(self, object, name=None, *args):
00330         """Generate documentation for an object."""
00331         args = (object, name) + args
00332         # 'try' clause is to attempt to handle the possibility that inspect
00333         # identifies something in a way that pydoc itself has issues handling;
00334         # think 'super' and how it is a descriptor (which raises the exception
00335         # by lacking a __name__ attribute) and an instance.
00336         if inspect.isgetsetdescriptor(object): return self.docdata(*args)
00337         if inspect.ismemberdescriptor(object): return self.docdata(*args)
00338         try:
00339             if inspect.ismodule(object): return self.docmodule(*args)
00340             if inspect.isclass(object): return self.docclass(*args)
00341             if inspect.isroutine(object): return self.docroutine(*args)
00342         except AttributeError:
00343             pass
00344         if isinstance(object, property): return self.docproperty(*args)
00345         return self.docother(*args)

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.Doc.fail (   self,
  object,
  name = None,
  args 
) [inherited]
Raise an exception for unimplemented types.

Definition at line 346 of file pydoc.py.

00346 
00347     def fail(self, object, name=None, *args):
00348         """Raise an exception for unimplemented types."""
00349         message = "don't know how to document object%s of type %s" % (
00350             name and ' ' + repr(name), type(object).__name__)
00351         raise TypeError(message)

def pydoc.HTMLDoc.filelink (   self,
  url,
  path 
)
Make a link to source file.

Definition at line 536 of file pydoc.py.

00536 
00537     def filelink(self, url, path):
00538         """Make a link to source file."""
00539         return '<a href="file:%s">%s</a>' % (url, path)

Here is the caller graph for this function:

def pydoc.HTMLDoc.formattree (   self,
  tree,
  modname,
  parent = None 
)
Produce HTML for a class tree as given by inspect.getclasstree().

Definition at line 578 of file pydoc.py.

00578 
00579     def formattree(self, tree, modname, parent=None):
00580         """Produce HTML for a class tree as given by inspect.getclasstree()."""
00581         result = ''
00582         for entry in tree:
00583             if type(entry) is type(()):
00584                 c, bases = entry
00585                 result = result + '<dt><font face="helvetica, arial">'
00586                 result = result + self.classlink(c, modname)
00587                 if bases and bases != (parent,):
00588                     parents = []
00589                     for base in bases:
00590                         parents.append(self.classlink(base, modname))
00591                     result = result + '(' + ', '.join(parents) + ')'
00592                 result = result + '\n</font></dt>'
00593             elif type(entry) is type([]):
00594                 result = result + '<dd>\n%s</dd>\n' % self.formattree(
00595                     entry, modname, c)
00596         return '<dl>\n%s</dl>\n' % result

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLDoc.formatvalue (   self,
  object 
)
Format an argument default value as text.

Definition at line 859 of file pydoc.py.

00859 
00860     def formatvalue(self, object):
00861         """Format an argument default value as text."""
00862         return self.grey('=' + self.repr(object))

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.Doc.getdocloc (   self,
  object 
) [inherited]
Return the location of module docs or None

Definition at line 354 of file pydoc.py.

00354 
00355     def getdocloc(self, object):
00356         """Return the location of module docs or None"""
00357 
00358         try:
00359             file = inspect.getabsfile(object)
00360         except TypeError:
00361             file = '(built-in)'
00362 
00363         docloc = os.environ.get("PYTHONDOCS", self.PYTHONDOCS)
00364 
00365         basedir = os.path.join(sys.exec_prefix, "lib",
00366                                "python%d.%d" %  sys.version_info[:2])
00367         if (isinstance(object, type(os)) and
00368             (object.__name__ in ('errno', 'exceptions', 'gc', 'imp',
00369                                  'marshal', 'posix', 'signal', 'sys',
00370                                  '_thread', 'zipimport') or
00371              (file.startswith(basedir) and
00372               not file.startswith(os.path.join(basedir, 'site-packages')))) and
00373             object.__name__ not in ('xml.etree', 'test.pydoc_mod')):
00374             if docloc.startswith("http://"):
00375                 docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__)
00376             else:
00377                 docloc = os.path.join(docloc, object.__name__ + ".html")
00378         else:
00379             docloc = None
00380         return docloc
00381 
00382 # -------------------------------------------- HTML documentation generator

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLDoc.grey (   self,
  text 
)

Definition at line 500 of file pydoc.py.

00500 
00501     def grey(self, text): return '<font color="#909090">%s</font>' % text

Here is the caller graph for this function:

def pydoc.HTMLDoc.heading (   self,
  title,
  fgcol,
  bgcol,
  extras = '' 
)
Format a page heading.

Definition at line 444 of file pydoc.py.

00444 
00445     def heading(self, title, fgcol, bgcol, extras=''):
00446         """Format a page heading."""
00447         return '''
00448 <table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="heading">
00449 <tr bgcolor="%s">
00450 <td valign=bottom>&nbsp;<br>
00451 <font color="%s" face="helvetica, arial">&nbsp;<br>%s</font></td
00452 ><td align=right valign=bottom
00453 ><font color="%s" face="helvetica, arial">%s</font></td></tr></table>
00454     ''' % (bgcol, fgcol, title, fgcol, extras or '&nbsp;')

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLDoc.index (   self,
  dir,
  shadowed = None 
)
Generate an HTML index for a directory of modules.

Definition at line 949 of file pydoc.py.

00949 
00950     def index(self, dir, shadowed=None):
00951         """Generate an HTML index for a directory of modules."""
00952         modpkgs = []
00953         if shadowed is None: shadowed = {}
00954         for importer, name, ispkg in pkgutil.iter_modules([dir]):
00955             modpkgs.append((name, '', ispkg, name in shadowed))
00956             shadowed[name] = 1
00957 
00958         modpkgs.sort()
00959         contents = self.multicolumn(modpkgs, self.modpkglink)
00960         return self.bigsection(dir, '#ffffff', '#ee77aa', contents)
00961 
00962 # -------------------------------------------- text documentation generator

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLDoc.markup (   self,
  text,
  escape = None,
  funcs = {},
  classes = {},
  methods = {} 
)
Mark up some plain text, given a context of symbols to look for.
Each context dictionary maps object names to anchor names.

Reimplemented in xmlrpc.server.ServerHTMLDoc.

Definition at line 540 of file pydoc.py.

00540 
00541     def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
00542         """Mark up some plain text, given a context of symbols to look for.
00543         Each context dictionary maps object names to anchor names."""
00544         escape = escape or self.escape
00545         results = []
00546         here = 0
00547         pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|'
00548                                 r'RFC[- ]?(\d+)|'
00549                                 r'PEP[- ]?(\d+)|'
00550                                 r'(self\.)?(\w+))')
00551         while True:
00552             match = pattern.search(text, here)
00553             if not match: break
00554             start, end = match.span()
00555             results.append(escape(text[here:start]))
00556 
00557             all, scheme, rfc, pep, selfdot, name = match.groups()
00558             if scheme:
00559                 url = escape(all).replace('"', '&quot;')
00560                 results.append('<a href="%s">%s</a>' % (url, url))
00561             elif rfc:
00562                 url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc)
00563                 results.append('<a href="%s">%s</a>' % (url, escape(all)))
00564             elif pep:
00565                 url = 'http://www.python.org/dev/peps/pep-%04d/' % int(pep)
00566                 results.append('<a href="%s">%s</a>' % (url, escape(all)))
00567             elif text[end:end+1] == '(':
00568                 results.append(self.namelink(name, methods, funcs, classes))
00569             elif selfdot:
00570                 results.append('self.<strong>%s</strong>' % name)
00571             else:
00572                 results.append(self.namelink(name, classes))
00573             here = end
00574         results.append(escape(text[here:]))
00575         return ''.join(results)

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLDoc.modpkglink (   self,
  modpkginfo 
)
Make a link for a module or package to display in an index.

Definition at line 521 of file pydoc.py.

00521 
00522     def modpkglink(self, modpkginfo):
00523         """Make a link for a module or package to display in an index."""
00524         name, path, ispackage, shadowed = modpkginfo
00525         if shadowed:
00526             return self.grey(name)
00527         if path:
00528             url = '%s.%s.html' % (path, name)
00529         else:
00530             url = '%s.html' % name
00531         if ispackage:
00532             text = '<strong>%s</strong>&nbsp;(package)' % name
00533         else:
00534             text = name
00535         return '<a href="%s">%s</a>' % (url, text)

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLDoc.modulelink (   self,
  object 
)
Make a link for a module.

Definition at line 517 of file pydoc.py.

00517 
00518     def modulelink(self, object):
00519         """Make a link for a module."""
00520         return '<a href="%s.html">%s</a>' % (object.__name__, object.__name__)

Here is the caller graph for this function:

def pydoc.HTMLDoc.multicolumn (   self,
  list,
  format,
  cols = 4 
)
Format a list of items into a multi-column list.

Definition at line 488 of file pydoc.py.

00488 
00489     def multicolumn(self, list, format, cols=4):
00490         """Format a list of items into a multi-column list."""
00491         result = ''
00492         rows = (len(list)+cols-1)//cols
00493         for col in range(cols):
00494             result = result + '<td width="%d%%" valign=top>' % (100//cols)
00495             for i in range(rows*col, rows*col+rows):
00496                 if i < len(list):
00497                     result = result + format(list[i]) + '<br>\n'
00498             result = result + '</td>'
00499         return '<table width="100%%" summary="list"><tr>%s</tr></table>' % result

Here is the caller graph for this function:

def pydoc.HTMLDoc.namelink (   self,
  name,
  dicts 
)
Make a link for an identifier, given name-to-URL mappings.

Definition at line 502 of file pydoc.py.

00502 
00503     def namelink(self, name, *dicts):
00504         """Make a link for an identifier, given name-to-URL mappings."""
00505         for dict in dicts:
00506             if name in dict:
00507                 return '<a href="%s">%s</a>' % (dict[name], name)
00508         return name

Here is the caller graph for this function:

def pydoc.HTMLDoc.page (   self,
  title,
  contents 
)
Format an HTML page.

Definition at line 434 of file pydoc.py.

00434 
00435     def page(self, title, contents):
00436         """Format an HTML page."""
00437         return '''\
00438 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
00439 <html><head><title>Python: %s</title>
00440 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
00441 </head><body bgcolor="#f0f0f8">
00442 %s
00443 </body></html>''' % (title, contents)

def pydoc.HTMLDoc.preformat (   self,
  text 
)
Format literal preformatted text.

Definition at line 482 of file pydoc.py.

00482 
00483     def preformat(self, text):
00484         """Format literal preformatted text."""
00485         text = self.escape(text.expandtabs())
00486         return replace(text, '\n\n', '\n \n', '\n\n', '\n \n',
00487                              ' ', '&nbsp;', '\n', '<br>\n')

Here is the call graph for this function:

Here is the caller graph for this function:

def pydoc.HTMLDoc.section (   self,
  title,
  fgcol,
  bgcol,
  contents,
  width = 6,
  prelude = '',
  marginalia = None,
  gap = '&nbsp;' 
)
Format a section with a heading.

Definition at line 456 of file pydoc.py.

00456 
00457                 prelude='', marginalia=None, gap='&nbsp;'):
00458         """Format a section with a heading."""
00459         if marginalia is None:
00460             marginalia = '<tt>' + '&nbsp;' * width + '</tt>'
00461         result = '''<p>
00462 <table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
00463 <tr bgcolor="%s">
00464 <td colspan=3 valign=bottom>&nbsp;<br>
00465 <font color="%s" face="helvetica, arial">%s</font></td></tr>
00466     ''' % (bgcol, fgcol, title)
00467         if prelude:
00468             result = result + '''
00469 <tr bgcolor="%s"><td rowspan=2>%s</td>
00470 <td colspan=2>%s</td></tr>
00471 <tr><td>%s</td>''' % (bgcol, marginalia, prelude, gap)
00472         else:
00473             result = result + '''
00474 <tr><td bgcolor="%s">%s</td><td>%s</td>''' % (bgcol, marginalia, gap)
00475 
00476         return result + '\n<td width="100%%">%s</td></tr></table>' % contents

Here is the caller graph for this function:


Member Data Documentation

tuple pydoc.HTMLDoc._repr_instance = HTMLRepr() [static, private]

Definition at line 430 of file pydoc.py.

pydoc.Doc.docmodule = docclassdocroutinedocotherdocpropertydocdatafail [static, inherited]

Definition at line 352 of file pydoc.py.

pydoc.HTMLDoc.escape = _repr_instance.escape [static]

Definition at line 432 of file pydoc.py.

Definition at line 734 of file pydoc.py.

tuple pydoc.Doc.PYTHONDOCS [static, inherited]
Initial value:
os.environ.get("PYTHONDOCS",
                                "http://docs.python.org/%d.%d/library"
                                % sys.version_info[:2])

Definition at line 324 of file pydoc.py.

pydoc.HTMLDoc.repr = _repr_instance.repr [static]

Definition at line 431 of file pydoc.py.


The documentation for this class was generated from the following file: