# Generating package diagrams Package diagrams are simple diagrams, which can be useful to visualize a high level structure of a C++ project, by rendering all projects namespaces or subdirectories as UML packages and their interdependencies. The minimal config required to generate a package diagram is presented below: ```yaml # Path to the directory where `compile_commands.json` can be found compilation_database_dir: _build # Output directory for the diagrams output_directory: diagrams # Diagrams definitions diagrams: # Diagram name my_class_diagram: # Type of diagram (has to be `package`) type: package # Include only translation units matching the following patterns glob: - src/*.cc # Include only classes and functions from files in `src` directory include: namespaces: - ns1::ns2 ``` For instance the following C++ code: ```cpp namespace A::AA { namespace A1 { struct CA { }; } namespace A2 { struct CB { }; } namespace A3 { struct CC { }; } namespace A4 { struct CD { }; } namespace A5 { struct CE { }; } namespace A6 { struct CF { }; } namespace A7 { struct CG { }; } namespace A8 { struct CH { }; } namespace A9 { struct CI { }; } namespace A10 { struct CJ { }; } namespace A11 { struct CK { }; } namespace A12 { struct CL { }; } namespace A13 { struct CM { }; } namespace A14 { struct CN { }; } namespace A15 { struct CO { }; } namespace A16 { struct CP { }; } namespace A17 { struct CR { }; } } namespace B::BB::BBB { class CBA : public A::AA::A6::CF { public: A::AA::A1::CA *ca_; A::AA::A2::CB cb_; std::shared_ptr cc_; std::map> *cd_; std::array co_; static A::AA::A16::CP *cp_; CBA() = default; CBA(A::AA::A14::CN *cn) { } friend A::AA::A17::CR; template CBA(std::tuple &items) { } void ce(const std::vector /*ce_*/) { } std::shared_ptr cg() { return {}; } template void ch(std::map> &ch_) { } template std::map> ci(T * /*t*/) { return {}; } }; void cj(std::unique_ptr /*cj_*/) { } std::unique_ptr ck() { return {}; } template void cl(std::map> & /*ch_*/) { } template std::map> cm() { return {}; } } ``` results the following diagram: ![package_deps](./test_cases/t30002_package.svg) By default, packages are generated from C++ namespaces in the code. However, they can also be generated from the subdirectories in the filesystem tree by adding the following option to the configuration file: ```yaml package_type: directory ``` for example checkout this diagram ![t30011_package](./test_cases/t30011_package.svg)