def _docArg(self, doc, arg): """Add documentation string for *arg* to *doc*.""" kwargs = self._args[arg] dest = kwargs.get('dest', arg[0]) desc = ':arg {0}: {1}'.format(dest, kwargs['help']) choices = kwargs.get('choices') if choices: desc += ', one of ' + ', '.join(['``' + repr(ch) + '``' for ch in choices]) default = kwargs.get('default') if default: desc += ', default is ``{0}``'.format(repr(default)) doc.extend(wrapText(desc, join=False, subsequent_indent=' ')) try: type = kwargs['type'] except KeyError: try: action = kwargs['action'] except KeyError: type = None else: if action.startswith('store') and action.endswith('e'): type = bool else: type = None if type is not None: doc.append(':type {0}: {1}'.format(dest, type.__name__)) doc.append('')
def getDocstr(self, meth, plural=True, selex=True): """Return documentation string for the field.""" assert meth in ('set', 'get', '_get'), "meth must be 'set' or 'get'" assert isinstance(plural, bool), 'plural must be a boolean' assert isinstance(selex, bool), 'selex must be a boolean' if meth == 'get': if plural: docstr = 'Return a copy of {0}.'.format(self.doc_pl) else: docstr = 'Return {0} of the atom.'.format(self.doc) elif meth == 'set': if plural: docstr = 'Set {0}.'.format(self.doc_pl) else: docstr = 'Set {0} of the atom.'.format(self.doc) else: selex = False if plural: docstr = 'Return {0} array.'.format(self.doc_pl) if self.desc: docstr += ' ' + self.desc selstr = self.selstr if selex and selstr: if plural: doc = self.doc_pl else: doc = self.doc if '(' in doc: doc = doc[:doc.index('(')] selex = "``, ``".join([repr(s) for s in selstr]) selex = (" {0} can be used in atom selections, e.g. " "``{1}``.").format(doc.capitalize(), selex) if self.synonym is not None: selex = selex + (' Note that *{0}* is a synonym for ' '*{1}*.').format(self.synonym, self.name) return wrapText(docstr + selex) else: return wrapText(docstr)
backbonefull bbfull backbone atoms of :term:`protein` residues, same as selection ``'name CA C O N H H1 H2 H3 OXT and protein'`` sidechain sc side-chain atoms of :term:`protein` residues, same as selection ``'protein and not backbonefull'`` """.format( stdaa = wrapText('indicates the standard amino acid residues: ' + joinLinks(DEFAULTS['stdaa'], last=', and ', sort=True), subsequent_indent=' '*6), ) cats = list(CATEGORIZED) cats.sort() for cat in cats: res = CATEGORIZED[cat] res.sort() __doc__ += """ {cat:s} {res:s}
backbonefull bbfull backbone atoms of :term:`protein` residues, same as selection ``'name CA C O N H H1 H2 H3 OXT and protein'`` sidechain sc side-chain atoms of :term:`protein` residues, same as selection ``'protein and not backbonefull'`` """.format( stdaa=wrapText('indicates the standard amino acid residues: ' + joinLinks(DEFAULTS['stdaa'], last=', and ', sort=True), subsequent_indent=' ' * 6)) cats = list(CATEGORIZED) cats.sort() for cat in cats: res = CATEGORIZED[cat] res.sort() __doc__ += """ {cat} {res} """.format(cat=cat, res=wrapText('residues ' + ', '.join(res), subsequent_indent=' ' * 6))
""" keys = list(ATOMIC_FIELDS.keys()) keys.sort() for key in keys: field = ATOMIC_FIELDS[key] __doc__ += '\n\n ' + key + '\n' if field.synonym: __doc__ += ' ' + field.synonym + '\n' __doc__ += wrapText(field.doc + (' *(read only)*' if field.readonly else ''), indent=6) if field.selstr: sel = "\n ``'" + "'``,\n ``'".join(field.selstr) + "'``" __doc__ += '\n\n *E.g.:* ' + sel for key in FLAG_FIELDS.keys(): ATOMIC_FIELDS[key].flags = True def wrapGetMethod(fn): def getMethod(self): return fn(self) return getMethod