def test_getmembers(self): """ Test getmembers() """ m = exdoc.getmembers(C) self.assertEqual(m, [ ('c', C.c), ('f', C.f), ('p', C.p), ('s', C.s), ]) # Try with predicate m = exdoc.getmembers(C, lambda key, value: key not in ('p', 's')) self.assertEqual(m, [ ('c', C.c), ('f', C.f), ])
def test_getmembers(self): """ Test getmembers() """ m = exdoc.getmembers(C) self.assertEqual(list(m), [ ('c', C.c), ('f', C.f), ('p', C.p), ('s', C.s), ]) # Try with predicate m = exdoc.getmembers(C, lambda key, value: key not in ('p', 's')) self.assertEqual(list(m), [ ('c', C.c), ('f', C.f), ])
def doccls(cls, *predicates): return { 'class': doc(cls), 'attrs': {key: doc(value, cls) for key, value in getmembers(cls, *predicates)}, }
def docmodule(module, *predicates): return { 'module': doc(module), 'attrs': {key: doc(value) for key, value in getmembers(module, *predicates)}, }
import mailem from exdoc import doc, getmembers import json doccls = lambda cls, *predicates: { 'cls': doc(cls), 'attrs': {name: doc(m) for name, m in getmembers(cls, *predicates)} } data = { 'mailem': doc(mailem), 'Message': doc(mailem.Message), 'Attachment': doc(mailem.Attachment), 'ImageAttachment': doc(mailem.ImageAttachment), 'Postman': doccls(mailem.Postman), 'connection': doc(mailem.connection), 'SMTPConnection': doc(mailem.connection.SMTPConnection), 'LoopbackConnection': doc(mailem.connection.LoopbackConnection), 'Template': doccls(mailem.template.Template, None, lambda k, v: k=='__call__' or not k.startswith('_')), 'TemplateRegistry': doccls(mailem.template.TemplateRegistry), } print json.dumps(data, indent=2)
#! /usr/bin/env python import json import inspect from exdoc import doc, getmembers import j2cli import j2cli.context import j2cli.extras.filters README = { 'formats': { name: doc(f) for name, f in j2cli.context.FORMATS.items() }, 'extras': { 'filters': [doc(v) for k, v in getmembers(j2cli.extras.filters) if inspect.isfunction(v) and inspect.getmodule(v) is j2cli.extras.filters] } } print(json.dumps(README))
import good, good.schema.errors, good.voluptuous from exdoc import doc, getmembers import json doccls = lambda cls, *allowed_keys: { 'cls': doc(cls), 'attrs': {name: doc(m, cls) for name, m in getmembers(cls, None, lambda key, value: key in allowed_keys or not key.startswith('_'))} } joindict = lambda *dicts: reduce(lambda memo, d: memo.update(d) or memo, dicts, {}) docmodule = lambda mod: { 'module': doc(mod), 'members': [ doc(getattr(mod, name)) for name in mod.__all__] } data = { 'good': doc(good), 'voluptuous': doc(good.voluptuous), 'Schema': doccls(good.Schema, None, '__call__'), 'errors': doc(good.schema.errors), 'Invalid': doccls(good.Invalid), 'MultipleInvalid': doccls(good.MultipleInvalid), 'markers': docmodule(good.markers), 'helpers': docmodule(good.helpers), 'predicates': docmodule(good.validators.predicates), 'types': docmodule(good.validators.types),
import json from exdoc import doc, getmembers, subclasses # Methods doccls = lambda cls, *allowed_keys: { 'cls': doc(cls), 'attrs': {name: doc(m, cls) for name, m in getmembers(cls, None, lambda key, value: key in allowed_keys or not key.startswith('_'))} } docmodule = lambda mod: { 'module': doc(mod), 'members': [ doc(getattr(mod, name)) for name in mod.__all__] } # Data import mongosql from mongosql.handlers import project, sort, group, filter, join, joinf, aggregate, limit, count from mongosql import query, MongoQuerySettingsDict, StrictCrudHelperSettingsDict from mongosql import ModelPropertyBags, CombinedBag, CountingQuery from mongosql.crud import crudhelper, CrudHelper, StrictCrudHelper, CrudViewMixin, saves_relations data = dict( mongosql=doc(mongosql), handlers=doc(mongosql.handlers), operations={ m.__name__.rsplit('.', 1)[1]: doc(m) for m in (project, sort, group, filter, join, joinf, aggregate, limit, count)}, mongosql_query=doc(mongosql.query),
#! /usr/bin/env python import json import inspect from exdoc import doc, getmembers import j2cli import j2cli.context import j2cli.extras.filters README = { 'formats': { name: doc(f) for name, f in j2cli.context.FORMATS.items() }, 'extras': { 'filters': {k: doc(v) for k, v in getmembers(j2cli.extras.filters) if inspect.isfunction(v) and inspect.getmodule(v) is j2cli.extras.filters} } } assert 'yaml' in README['formats'], 'Looks like the YAML library is not installed!' print(json.dumps(README))
#! /usr/bin/env python import json import inspect from exdoc import doc, getmembers import shinto_cli import shinto_cli.context import shinto_cli.extras.filters README = { 'formats': {name: doc(f) for name, f in shinto_cli.context.FORMATS.items()}, 'extras': { 'filters': [ doc(v) for k, v in getmembers(shinto_cli.extras.filters) if inspect.isfunction(v) ] } } print json.dumps(README)
def doccls(cls, *predicates): return { 'class': doc(cls), 'attrs': {key: doc(value) for key, value in getmembers(cls, *predicates)}, }
def docmodule(module): return { name: doc(value) for name, value in list(getmembers(module)) + [('__module__', module)] }
def docmodule(module): return { name: doc(value) for name, value in getmembers(module) + [('__module__', module)] }
#! /usr/bin/env python import json import inspect from exdoc import doc, getmembers import shinto_cli import shinto_cli.context import shinto_cli.extras.filters README = { 'formats': { name: doc(f) for name, f in shinto_cli.context.FORMATS.items() }, 'extras': { 'filters': [doc(v) for k, v in getmembers(shinto_cli.extras.filters) if inspect.isfunction(v)] } } print json.dumps(README)
#! /usr/bin/env python import json import inspect from exdoc import doc, getmembers import j2cli_3 import j2cli_3.context import j2cli_3.extras.filters README = { 'formats': {name: doc(f) for name, f in list(j2cli_3.context.FORMATS.items())}, 'extras': { 'filters': [ doc(v) for k, v in getmembers(j2cli_3.extras.filters) if inspect.isfunction(v) ] } } print(json.dumps(README))