Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
TextDoc Class Reference
Inheritance diagram for TextDoc:
Doc

Public Member Functions

def bold
 
def indent
 
def section
 
def formattree
 
def docmodule
 
def docclass
 
def formatvalue
 
def docroutine
 
def docother
 
- Public Member Functions inherited from Doc
def document
 
def fail
 

Data Fields

 needone
 

Static Public Attributes

 repr = _repr_instance.repr
 
- Static Public Attributes inherited from Doc
 docmodule = fail
 

Detailed Description

Formatter class for text documentation.

Definition at line 874 of file pydoc.py.

Member Function Documentation

def bold (   self,
  text 
)
Format a string in bold by overstriking.

Definition at line 882 of file pydoc.py.

References dospath.join().

883  def bold(self, text):
884  """Format a string in bold by overstriking."""
885  return join(map(lambda ch: ch + '\b' + ch, text), '')
def docclass (   self,
  object,
  name = None,
  mod = None 
)
Produce text documentation for a given class object.

Definition at line 989 of file pydoc.py.

References audiodev.__init__(), TextDoc.bold(), pydoc.classname(), pydoc.getdoc(), inspect.getmro(), and dospath.join().

990  def docclass(self, object, name=None, mod=None):
991  """Produce text documentation for a given class object."""
992  realname = object.__name__
993  name = name or realname
994  bases = object.__bases__
995 
996  def makename(c, m=object.__module__):
997  return classname(c, m)
998 
999  if name == realname:
1000  title = 'class ' + self.bold(realname)
1001  else:
1002  title = self.bold(name) + ' = class ' + realname
1003  if bases:
1004  parents = map(makename, bases)
1005  title = title + '(%s)' % join(parents, ', ')
1006 
1007  doc = getdoc(object)
1008  contents = doc and [doc + '\n'] or []
1009  push = contents.append
1010 
1011  # List the mro, if non-trivial.
1012  mro = list(inspect.getmro(object))
1013  if len(mro) > 2:
1014  push("Method resolution order:")
1015  for base in mro:
1016  push(' ' + makename(base))
1017  push('')
1018 
1019  # Cute little class to pump out a horizontal rule between sections.
1020  class HorizontalRule:
1021  def __init__(self):
1022  self.needone = 0
1023  def maybe(self):
1024  if self.needone:
1025  push('-' * 70)
1026  self.needone = 1
1027  hr = HorizontalRule()
1028 
1029  def spill(msg, attrs, predicate):
1030  ok, attrs = _split_list(attrs, predicate)
1031  if ok:
1032  hr.maybe()
1033  push(msg)
1034  for name, kind, homecls, value in ok:
1035  push(self.document(getattr(object, name),
1036  name, mod, object))
1037  return attrs
1038 
1039  def spillproperties(msg, attrs, predicate):
1040  ok, attrs = _split_list(attrs, predicate)
1041  if ok:
1042  hr.maybe()
1043  push(msg)
1044  for name, kind, homecls, value in ok:
1045  push(name)
1046  need_blank_after_doc = 0
1047  doc = getdoc(value) or ''
1048  if doc:
1049  push(self.indent(doc))
1050  need_blank_after_doc = 1
1051  for attr, tag in [("fget", " getter"),
1052  ("fset", " setter"),
1053  ("fdel", " deleter")]:
1054  func = getattr(value, attr)
1055  if func is not None:
1056  if need_blank_after_doc:
1057  push('')
1058  need_blank_after_doc = 0
1059  base = self.docother(func, name + tag, mod, 70)
1060  push(self.indent(base))
1061  push('')
1062  return attrs
1063 
1064  def spilldata(msg, attrs, predicate):
1065  ok, attrs = _split_list(attrs, predicate)
1066  if ok:
1067  hr.maybe()
1068  push(msg)
1069  for name, kind, homecls, value in ok:
1070  doc = getattr(value, "__doc__", None)
1071  push(self.docother(getattr(object, name),
1072  name, mod, 70, doc) + '\n')
1073  return attrs
1074 
1075  attrs = inspect.classify_class_attrs(object)
1076  while attrs:
1077  if mro:
1078  thisclass = mro.pop(0)
1079  else:
1080  thisclass = attrs[0][2]
1081  attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
1082 
1083  if thisclass is object:
1084  tag = "defined here"
1085  else:
1086  tag = "inherited from %s" % classname(thisclass,
1087  object.__module__)
1088 
1089  # Sort attrs by name.
1090  attrs.sort(lambda t1, t2: cmp(t1[0], t2[0]))
1091 
1092  # Pump out the attrs, segregated by kind.
1093  attrs = spill("Methods %s:\n" % tag, attrs,
1094  lambda t: t[1] == 'method')
1095  attrs = spill("Class methods %s:\n" % tag, attrs,
1096  lambda t: t[1] == 'class method')
1097  attrs = spill("Static methods %s:\n" % tag, attrs,
1098  lambda t: t[1] == 'static method')
1099  attrs = spillproperties("Properties %s:\n" % tag, attrs,
1100  lambda t: t[1] == 'property')
1101  attrs = spilldata("Data and non-method functions %s:\n" % tag,
1102  attrs, lambda t: t[1] == 'data')
1103  assert attrs == []
1104  attrs = inherited
1105 
1106  contents = '\n'.join(contents)
1107  if not contents:
1108  return title + '\n'
1109  return title + '\n' + self.indent(rstrip(contents), ' | ') + '\n'
def docmodule (   self,
  object,
  name = None,
  mod = None 
)
Produce text documentation for a given module object.

Definition at line 916 of file pydoc.py.

References HTMLDoc.docother(), TextDoc.docother(), Doc.document(), HTMLDoc.formattree(), TextDoc.formattree(), inspect.getabsfile(), inspect.getclasstree(), pydoc.getdoc(), inspect.getmembers(), inspect.getmodule(), inspect.getmodulename(), inspect.isbuiltin(), pydoc.ispackage(), dospath.join(), NoSectionError.section, DuplicateSectionError.section, NoOptionError.section, InterpolationError.section, InterpolationDepthError.section, HTMLDoc.section(), TextDoc.section(), pydoc.splitdoc(), locale.str(), and string.strip().

917  def docmodule(self, object, name=None, mod=None):
918  """Produce text documentation for a given module object."""
919  name = object.__name__ # ignore the passed-in name
920  synop, desc = splitdoc(getdoc(object))
921  result = self.section('NAME', name + (synop and ' - ' + synop))
922 
923  try:
924  file = inspect.getabsfile(object)
925  except TypeError:
926  file = '(built-in)'
927  result = result + self.section('FILE', file)
928  if desc:
929  result = result + self.section('DESCRIPTION', desc)
930 
931  classes = []
932  for key, value in inspect.getmembers(object, inspect.isclass):
933  if (inspect.getmodule(value) or object) is object:
934  classes.append((key, value))
935  funcs = []
936  for key, value in inspect.getmembers(object, inspect.isroutine):
937  if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
938  funcs.append((key, value))
939  data = []
940  for key, value in inspect.getmembers(object, isdata):
941  if key not in ['__builtins__', '__doc__']:
942  data.append((key, value))
943 
944  if hasattr(object, '__path__'):
945  modpkgs = []
946  for file in os.listdir(object.__path__[0]):
947  path = os.path.join(object.__path__[0], file)
948  modname = inspect.getmodulename(file)
949  if modname and modname not in modpkgs:
950  modpkgs.append(modname)
951  elif ispackage(path):
952  modpkgs.append(file + ' (package)')
953  modpkgs.sort()
954  result = result + self.section(
955  'PACKAGE CONTENTS', join(modpkgs, '\n'))
956 
957  if classes:
958  classlist = map(lambda (key, value): value, classes)
959  contents = [self.formattree(
960  inspect.getclasstree(classlist, 1), name)]
961  for key, value in classes:
962  contents.append(self.document(value, key, name))
963  result = result + self.section('CLASSES', join(contents, '\n'))
964 
965  if funcs:
966  contents = []
967  for key, value in funcs:
968  contents.append(self.document(value, key, name))
969  result = result + self.section('FUNCTIONS', join(contents, '\n'))
970 
971  if data:
972  contents = []
973  for key, value in data:
974  contents.append(self.docother(value, key, name, 70))
975  result = result + self.section('DATA', join(contents, '\n'))
976 
977  if hasattr(object, '__version__'):
978  version = str(object.__version__)
979  if version[:11] == '$' + 'Revision: ' and version[-1:] == '$':
980  version = strip(version[11:-1])
981  result = result + self.section('VERSION', version)
982  if hasattr(object, '__date__'):
983  result = result + self.section('DATE', str(object.__date__))
984  if hasattr(object, '__author__'):
985  result = result + self.section('AUTHOR', str(object.__author__))
986  if hasattr(object, '__credits__'):
987  result = result + self.section('CREDITS', str(object.__credits__))
988  return result
def docother (   self,
  object,
  name = None,
  mod = None,
  maxlen = None,
  doc = None 
)
Produce text documentation for a data object.

Definition at line 1157 of file pydoc.py.

References TextDoc.bold(), BlockFinder.indent, TextDoc.indent(), HTMLDoc.repr, TextDoc.repr, and locale.str().

1158  def docother(self, object, name=None, mod=None, maxlen=None, doc=None):
1159  """Produce text documentation for a data object."""
1160  repr = self.repr(object)
1161  if maxlen:
1162  line = (name and name + ' = ' or '') + repr
1163  chop = maxlen - len(line)
1164  if chop < 0: repr = repr[:chop] + '...'
1165  line = (name and self.bold(name) + ' = ' or '') + repr
1166  if doc is not None:
1167  line += '\n' + self.indent(str(doc))
1168  return line
1169 
1170 # --------------------------------------------------------- user interfaces
def docroutine (   self,
  object,
  name = None,
  mod = None,
  cl = None 
)
Produce text documentation for a function or method object.

Definition at line 1114 of file pydoc.py.

References TextDoc.bold(), pydoc.classname(), inspect.formatargspec(), HTMLDoc.formatvalue(), TextDoc.formatvalue(), inspect.getargspec(), pydoc.getdoc(), BlockFinder.indent, TextDoc.indent(), inspect.isfunction(), inspect.ismethod(), and string.rstrip().

1115  def docroutine(self, object, name=None, mod=None, cl=None):
1116  """Produce text documentation for a function or method object."""
1117  realname = object.__name__
1118  name = name or realname
1119  note = ''
1120  skipdocs = 0
1121  if inspect.ismethod(object):
1122  imclass = object.im_class
1123  if cl:
1124  if imclass is not cl:
1125  note = ' from ' + classname(imclass, mod)
1126  else:
1127  if object.im_self:
1128  note = ' method of %s instance' % classname(
1129  object.im_self.__class__, mod)
1130  else:
1131  note = ' unbound %s method' % classname(imclass,mod)
1132  object = object.im_func
1133 
1134  if name == realname:
1135  title = self.bold(realname)
1136  else:
1137  if (cl and cl.__dict__.has_key(realname) and
1138  cl.__dict__[realname] is object):
1139  skipdocs = 1
1140  title = self.bold(name) + ' = ' + realname
1141  if inspect.isfunction(object):
1142  args, varargs, varkw, defaults = inspect.getargspec(object)
1143  argspec = inspect.formatargspec(
1144  args, varargs, varkw, defaults, formatvalue=self.formatvalue)
1145  if realname == '<lambda>':
1146  title = 'lambda'
1147  argspec = argspec[1:-1] # remove parentheses
1148  else:
1149  argspec = '(...)'
1150  decl = title + argspec + note
1151 
1152  if skipdocs:
1153  return decl + '\n'
1154  else:
1155  doc = getdoc(object) or ''
1156  return decl + '\n' + (doc and rstrip(self.indent(doc)) + '\n')
def formattree (   self,
  tree,
  modname,
  parent = None,
  prefix = '' 
)
Render in text a class tree as returned by inspect.getclasstree().

Definition at line 900 of file pydoc.py.

References pydoc.classname(), HTMLDoc.formattree(), TextDoc.formattree(), and dospath.join().

901  def formattree(self, tree, modname, parent=None, prefix=''):
902  """Render in text a class tree as returned by inspect.getclasstree()."""
903  result = ''
904  for entry in tree:
905  if type(entry) is type(()):
906  c, bases = entry
907  result = result + prefix + classname(c, modname)
908  if bases and bases != (parent,):
909  parents = map(lambda c, m=modname: classname(c, m), bases)
910  result = result + '(%s)' % join(parents, ', ')
911  result = result + '\n'
912  elif type(entry) is type([]):
913  result = result + self.formattree(
914  entry, modname, c, prefix + ' ')
915  return result
def formatvalue (   self,
  object 
)
Format an argument default value as text.

Definition at line 1110 of file pydoc.py.

References HTMLDoc.repr, and TextDoc.repr.

1111  def formatvalue(self, object):
1112  """Format an argument default value as text."""
1113  return '=' + self.repr(object)
def indent (   self,
  text,
  prefix = '    ' 
)
Indent text by prepending a given prefix to each line.

Definition at line 886 of file pydoc.py.

References dospath.join(), string.rstrip(), and dospath.split().

887  def indent(self, text, prefix=' '):
888  """Indent text by prepending a given prefix to each line."""
889  if not text: return ''
890  lines = split(text, '\n')
891  lines = map(lambda line, prefix=prefix: prefix + line, lines)
892  if lines: lines[-1] = rstrip(lines[-1])
893  return join(lines, '\n')
def section (   self,
  title,
  contents 
)
Format a section with a given heading.

Definition at line 894 of file pydoc.py.

References TextDoc.bold(), BlockFinder.indent, TextDoc.indent(), and string.rstrip().

895  def section(self, title, contents):
896  """Format a section with a given heading."""
897  return self.bold(title) + '\n' + rstrip(self.indent(contents)) + '\n\n'

Field Documentation

needone

Definition at line 1021 of file pydoc.py.

repr = _repr_instance.repr
static

Definition at line 880 of file pydoc.py.


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