def __init__(self): translation.activate(settings.LANGUAGE_CODE) self.description = None self.workflow = None self.actors = [] self.usecases = [] self.class_diagrams = [] # load description for app_config in apps.get_app_configs(): if app_config.label == settings.PROJECT_NAME: self.description = app_config.module.__doc__ and app_config.module.__doc__.decode( 'utf-8').strip() or None # load actors organization_name = loader.organization_model and get_metadata( loader.organization_model, 'verbose_name') or None unit_name = loader.unit_model and get_metadata(loader.unit_model, 'verbose_name') or None for model in loader.role_models: name = loader.role_models[model]['name'] description = utils.extract_documentation(model) scope = '' if organization_name: scope = loader.role_models[model]['scope'] if scope == u'systemic': scope = _(u'Systemic') elif scope == u'organization': scope = organization_name elif scope == u'unit': scope = unit_name self.actors.append( Actor(name=name, scope=scope, description=description)) # load usecases self.workflow = Workflow() for task in self.workflow.tasks: if not task.startswith(_(u'Access')): usecase = UseCase(task) self.usecases.append(usecase) # load class diagrams for class_diagram_name, models in loader.class_diagrams.items(): class_diagram = ClassDiagram(class_diagram_name, models) self.class_diagrams.append(class_diagram)
def __init__(self): from djangoplus.cache import CACHE from djangoplus.docs.usecase import Actor, UseCase from djangoplus.docs.diagrams import Workflow, ClassDiagram translation.activate(settings.LANGUAGE_CODE) self.description = None self.workflow = None self.actors = [] self.usecases = [] self.class_diagrams = [] # load description for app_config in apps.get_app_configs(): if app_config.label == settings.PROJECT_NAME: self.description = app_config.module.__doc__ and app_config.module.__doc__.strip( ) or None # load actors self.organization_model = CACHE['ORGANIZATION_MODEL'] self.unit_model = CACHE['UNIT_MODEL'] for model in CACHE['ROLE_MODELS']: name = CACHE['ROLE_MODELS'][model]['name'] scope = CACHE['ROLE_MODELS'][model]['scope'] description = utils.extract_documentation(model) self.actors.append( Actor(name=name, scope=scope, description=description)) # load usecases self.workflow = Workflow() for task in self.workflow.tasks: if not task.startswith(_('Access')): usecase = UseCase(task) self.usecases.append(usecase) # load class diagrams for class_diagram_name, models in list( CACHE['CLASS_DIAGRAMS'].items()): class_diagram = ClassDiagram(class_diagram_name, models) self.class_diagrams.append(class_diagram)
def __init__(self): translation.activate(settings.LANGUAGE_CODE) self.description = None self.workflow = None self.actors = [] self.usecases = [] self.class_diagrams = [] # load description for app_config in apps.get_app_configs(): if app_config.label == settings.PROJECT_NAME: self.description = app_config.module.__doc__ and app_config.module.__doc__.strip( ) or None # load actors self.organization_model = loader.organization_model self.unit_model = loader.unit_model for model in loader.role_models: name = loader.role_models[model]['name'] scope = loader.role_models[model]['scope'] description = utils.extract_documentation(model) self.actors.append( Actor(name=name, scope=scope, description=description)) # load usecases self.workflow = Workflow() for task in self.workflow.tasks: if not task.startswith(_('Access')): usecase = UseCase(task) self.usecases.append(usecase) # load class diagrams for class_diagram_name, models in list(loader.class_diagrams.items()): class_diagram = ClassDiagram(class_diagram_name, models) self.class_diagrams.append(class_diagram)
def handle(self, *args, **options): for cls in Component.__subclasses__(): name = terminal.bold(cls.__name__) description = extract_documentation(cls) print('{}: {}'.format(name, description))