def depdencies_of_view_decorator(graph): """ To minimize the bootstrapping of each view, we chose to create view decorators that make it easy to add relevant details to the specific view function but also make it easy for the Codoc Python framework to find any defined view function. The current version of the view decorator is closely knitted to the Codoc API, however, we plan to refactor this to make it simply return a view, rather than publish a view. The view decorator overrides the __name__, __docs__ attributes but also sets label, description, and graph_id on the function before returning it. It also changes the return type to simply return a success or failure regarding whether the publishing step succeeded. Lastly, it creates a __is_codoc_view attribute, with the True value. This can then be used when Codoc Python searches for views by checking objects whether it has that attribute. def is_a_codoc_view(obj: object) -> bool: return getattr(obj, "__is_codoc_view", False) """ return filters.get_children_of(codoc.service.export.codoc_view, keep_external_nodes=True)( filters.get_children_of(codoc)(graph))
def view_graph_rendering(graph): """ This graph showcases the inter dependencies of the graph, as well as the direct dependencies of the internal aspects. """ # TODO makes sure the order of filters doesn't matter when looking at children. return filters.get_children_of(codoc.service.graph, keep_external_nodes=True)( filters.get_children_of(codoc)(graph))
def view_context_of_finder_module(graph): """ This graph showcases the inter dependencies of the graph, as well as the direct dependencies of the internal aspects. """ finder_graph = filters.get_children_of( codoc.service.finder, keep_external_nodes=True)(filters.get_children_of(codoc)(graph)) service_layer_graph = filters.get_depth_based_filter(2)( filters.get_children_of(codoc.service, keep_external_nodes=True)(graph)) return finder_graph | service_layer_graph
def view_modules_internal(graph): """ This view displays the internal structure of the Codoc Python system. The main purpose is to see how different elements are inter-dependent. The service layer is created to expose pure functionality of the framework. We try to develop things in a pure functional fashion without side effects, and general adhere to immutable data types. We utilize a service layer with the intent of separating the domain model from usage. The top level of the service layer should expose a bunch of functions that can be used by a given entry point (be it the CLI or when used as a functional framework) Our usage of a service layer is heavily inspired by [Architectural Patterns In Python](https://cosmicpython.com). We also have a data model. These are pure dataclasses, and are the basis of the overall system. """ return filters.get_depth_based_filter(2)( filters.get_children_of(codoc)(graph))
def domain_model(graph): """ This view presents the basic domain model of the Codoc Python system. It shows the core models. To actually utilize the classes, look at the service layer. """ graph = filters.get_children_of(codoc.domain.model)(graph) return filters.include_only_classes(graph)
def view_cli_dependencies(graph): """ Here we show the dependencies of the CLI. """ return filters.get_children_of(codoc.entrypoints, keep_external_nodes=True)(graph)
def service_layer_view(graph): return filters.get_depth_based_filter(2)(filters.get_children_of( codoc.service, keep_external_nodes=True)(graph))
def view_parsing(graph): return filters.get_children_of(codoc.service.parsing)(graph)
def view_modules_internal_detailed(graph): return filters.include_only_modules( filters.get_depth_based_filter(3)( filters.get_children_of(codoc)(graph)))
def domain(graph): graph = filters.get_children_of(codoc.domain)(graph) return graph
def domain_model_extra(graph): return filters.get_children_of(codoc.domain.model)(graph)