Services for generation of a UML package diagram based on a Model

Redefined classes

redef class MAttributeDef

nitc :: uml_module $ MAttributeDef

A local definition of an attribute
redef class MClassDef

nitc :: uml_module $ MClassDef

A definition (an introduction or a refinement) of a class in a module
redef abstract class MEntity

nitc :: uml_module $ MEntity

A named and possibly documented entity in the model.
redef class MMethodDef

nitc :: uml_module $ MMethodDef

A local definition of a method
redef class MModule

nitc :: uml_module $ MModule

A Nit module is usually associated with a Nit source file.
redef class UMLModel

nitc :: uml_module $ UMLModel

UML model builder.

All class definitions

redef class MAttributeDef

nitc :: uml_module $ MAttributeDef

A local definition of an attribute
redef class MClassDef

nitc :: uml_module $ MClassDef

A definition (an introduction or a refinement) of a class in a module
redef abstract class MEntity

nitc :: uml_module $ MEntity

A named and possibly documented entity in the model.
redef class MMethodDef

nitc :: uml_module $ MMethodDef

A local definition of a method
redef class MModule

nitc :: uml_module $ MModule

A Nit module is usually associated with a Nit source file.
redef class UMLModel

nitc :: uml_module $ UMLModel

UML model builder.
package_diagram nitc::uml_module uml_module nitc::uml_class uml_class nitc::uml_module->nitc::uml_class nitc::uml_base uml_base nitc::uml_class->nitc::uml_base ...nitc::uml_base ... ...nitc::uml_base->nitc::uml_base nitc::uml uml nitc::uml->nitc::uml_module nitc::commands_graph commands_graph nitc::commands_graph->nitc::uml nitc::nituml nituml nitc::nituml->nitc::uml nitc::commands_graph... ... nitc::commands_graph...->nitc::commands_graph nitc::nituml... ... nitc::nituml...->nitc::nituml

Ancestors

module abstract_collection

core :: abstract_collection

Abstract collection classes and services.
module abstract_text

core :: abstract_text

Abstract class for manipulation of sequences of characters
module annotation

nitc :: annotation

Management and utilities on annotations
module array

core :: array

This module introduces the standard array structure.
module bitset

core :: bitset

Services to handle BitSet
module bytes

core :: bytes

Services for byte streams and arrays
module caching

serialization :: caching

Services for caching serialization engines
module circular_array

core :: circular_array

Efficient data structure to access both end of the sequence.
module codec_base

core :: codec_base

Base for codecs to use with streams
module codecs

core :: codecs

Group module for all codec-related manipulations
module collection

core :: collection

This module define several collection classes.
module console

console :: console

Defines some ANSI Terminal Control Escape Sequences.
module core

core :: core

Standard classes and methods used by default by Nit programs and libraries.
module digraph

graph :: digraph

Implementation of directed graphs, also called digraphs.
module engine_tools

serialization :: engine_tools

Advanced services for serialization engines
module environ

core :: environ

Access to the environment variables of the process
module error

core :: error

Standard error-management infrastructure.
module exec

core :: exec

Invocation and management of operating system sub-processes.
module file

core :: file

File manipulations (create, read, write, etc.)
module fixed_ints

core :: fixed_ints

Basic integers of fixed-precision
module fixed_ints_text

core :: fixed_ints_text

Text services to complement fixed_ints
module flat

core :: flat

All the array-based text representations
module gc

core :: gc

Access to the Nit internal garbage collection mechanism
module hash_collection

core :: hash_collection

Introduce HashMap and HashSet.
module ini

ini :: ini

Read and write INI configuration files
module inspect

serialization :: inspect

Refine Serializable::inspect to show more useful information
module iso8859_1

core :: iso8859_1

Codec for ISO8859-1 I/O
module kernel

core :: kernel

Most basic classes and methods.
module lexer

nitc :: lexer

Lexer and its tokens.
module lexer_work

nitc :: lexer_work

Internal algorithm and data structures for the Nit lexer
module list

core :: list

This module handle double linked lists
module literal

nitc :: literal

Parsing of literal values in the abstract syntax tree.
module loader

nitc :: loader

Loading of Nit source files
module location

nitc :: location

Nit source-file and locations in source-file
module math

core :: math

Mathematical operations
module mdoc

nitc :: mdoc

Documentation of model entities
module meta

meta :: meta

Simple user-defined meta-level to manipulate types of instances as object.
module mmodule

nitc :: mmodule

modules and module hierarchies in the metamodel
module mmodule_data

nitc :: mmodule_data

Define and retrieve data in modules
module model

nitc :: model

Classes, types and properties
module model_base

nitc :: model_base

The abstract concept of model and related common things
module model_collect

nitc :: model_collect

Collect things from the model.
module model_examples

nitc :: model_examples

Examples for Model entities
module modelbuilder_base

nitc :: modelbuilder_base

Load nit source files and build the associated model
module modelize_class

nitc :: modelize_class

Analysis and verification of class definitions to instantiate model element
module modelize_property

nitc :: modelize_property

Analysis and verification of property definitions to instantiate model element
module more_collections

more_collections :: more_collections

Highly specific, but useful, collections-related classes.
module mpackage

nitc :: mpackage

Modelisation of a Nit package
module native

core :: native

Native structures for text and bytes
module nitpm_shared

nitc :: nitpm_shared

Services related to the Nit package manager
module numeric

core :: numeric

Advanced services for Numeric types
module opts

opts :: opts

Management of options on the command line
module ordered_tree

ordered_tree :: ordered_tree

Manipulation and presentation of ordered trees.
module parse_annotations

nitc :: parse_annotations

Simple annotation parsing
module parser

nitc :: parser

Parser.
module parser_nodes

nitc :: parser_nodes

AST nodes of the Nit language
module parser_prod

nitc :: parser_prod

Production AST nodes full definition.
module parser_work

nitc :: parser_work

Internal algorithm and data structures for the Nit parser
module phase

nitc :: phase

Phases of the processing of nit programs
module poset

poset :: poset

Pre order sets and partial order set (ie hierarchies)
module protocol

core :: protocol

module queue

core :: queue

Queuing data structures and wrappers
module range

core :: range

Module for range of discrete objects.
module re

core :: re

Regular expression support for all services based on Pattern
module ropes

core :: ropes

Tree-based representation of a String.
module serialization

serialization :: serialization

General serialization services
module serialization_core

serialization :: serialization_core

Abstract services to serialize Nit objects to different formats
module sorter

core :: sorter

This module contains classes used to compare things and sorts arrays.
module stream

core :: stream

Input and output streams of characters
module tables

nitc :: tables

Module that interfaces the parsing tables.
module template

template :: template

Basic template system
module text

core :: text

All the classes and methods related to the manipulation of text entities
module time

core :: time

Management of time and dates
module toolcontext

nitc :: toolcontext

Common command-line tool infrastructure than handle options and error messages
module uml_base

nitc :: uml_base

Exposes the base class for UML generation of a Model
module union_find

core :: union_find

union–find algorithm using an efficient disjoint-set data structure
module utf8

core :: utf8

Codec for UTF-8 I/O
module version

nitc :: version

This file was generated by git-gen-version.sh

Parents

module uml_class

nitc :: uml_class

Provides facilities of exporting a Model to a UML class diagram

Children

module uml

nitc :: uml

Group head module for UML generation services

Descendants

module a_star-m

a_star-m

module api

nitc :: api

Components required to build a web server about the nit model.
module api_auth

nitc :: api_auth

module api_base

nitc :: api_base

Base classes used by nitweb.
module api_docdown

nitc :: api_docdown

Nitdoc specific Markdown format handling for Nitweb
module api_feedback

nitc :: api_feedback

Feedback related features
module api_light

nitc :: api_light

Highlight and collect messages from a piece of code
module api_model

nitc :: api_model

module commands_docdown

nitc :: commands_docdown

Doc down related queries
module commands_graph

nitc :: commands_graph

Graph commands
module commands_http

nitc :: commands_http

Initialize commands from HTTP requests
module commands_parser

nitc :: commands_parser

A parser that create DocCommand from a string
module html_commands

nitc :: html_commands

Render commands results as HTML
module json_commands

nitc :: json_commands

Translate command results to json
module md_commands

nitc :: md_commands

Render commands results as Markdown
module nitdoc

nitc :: nitdoc

Generator of static API documentation for the Nit language
module nituml

nitc :: nituml

UML generator in dot format.
module nitweb

nitc :: nitweb

Runs a webserver based on nitcorn that render things from model.
module nitx

nitc :: nitx

nitx, a command tool that displays useful data about Nit code
module static

nitc :: static

Nitdoc generation framework
module static_base

nitc :: static_base

Base entities shared by all the nitdoc code
module static_cards

nitc :: static_cards

Cards templates for the static documentation
module static_html

nitc :: static_html

Render documentation pages as HTML
module static_index

nitc :: static_index

Manage indexing of Nit model for Nitdoc QuickSearch.
module static_structure

nitc :: static_structure

Composes the pages of the static documentation
module term

nitc :: term

# Services for generation of a UML package diagram based on a `Model`
module uml_module

import uml_base
import uml_class

redef class UMLModel
	# Generates a UML package diagram from a `Model`
	fun generate_package_uml: Writable do
		var tpl = new Template
		tpl.add "digraph G \{\n"
		tpl.add """	fontname = "Bitstream Vera Sans"
			fontsize = 8
			node [
				fontname = "Bitstream Vera Sans"
				fontsize = 8
				shape = "record"
			]
			edge [
				fontname = "Bitstream Vera Sans"
				fontsize = 8
			]\n"""
		tpl.add mainmodule.tpl_module(self)
		tpl.add "\}"
		return tpl
	end
end

redef class MEntity
	# Builds a dot UML package diagram entity from `self`
	fun tpl_module(model: UMLModel): Writable is abstract
end

redef class MModule
	redef fun tpl_module(model) do
		var name = self.name.escape_to_dot
		var t = new Template
		t.add "subgraph cluster{name} \{\n"
		t.add "label = \"{name}\"\n"
		for i in mclassdefs do
			if not model.filter.accept_mentity(i) then continue
			t.add i.tpl_module(model)
		end
		t.add "\}\n"
		return t
	end
end

redef class MClassDef

	# Colour for the border of a class when first introduced
	#
	# Defaults to a shade of green
	var intro_colour = "#58B26A"

	# Colour for the border of a class when refined
	#
	# Defaults to a shade of red
	var redef_colour = "#B24758"

	redef fun tpl_module(model) do
		var name = self.name.escape_to_dot
		var t = new Template
		t.add "{mmodule.name.escape_to_dot}{name} [\n\tlabel = \"\{"
		if mclass.kind == abstract_kind then
			t.add "abstract\\n{name}"
		else if mclass.kind == interface_kind then
			t.add "interface\\n{name}"
		else
			t.add "{name}"
		end
		if mclass.arity > 0 then
			t.add "["
			var mparameters = mclass.mparameters
			t.add mparameters.first.name
			for i in [1 .. mparameters.length[ do
				t.add ", "
				t.add mparameters[i].name
			end
			t.add "]"
		end
		t.add "|"
		for i in mpropdefs do
			if not i isa MAttributeDef then continue
			if not model.filter.accept_mentity(i) then continue
			t.add i.tpl_module(model)
			t.add "\\l"
		end
		t.add "|"
		for i in mpropdefs do
			if not i isa MMethodDef then continue
			if not model.filter.accept_mentity(i) then continue
			t.add i.tpl_module(model)
			t.add "\\l"
		end
		t.add "\}\""
		if is_intro then
			t.add "color=\"{intro_colour}\""
		else
			t.add "color=\"{redef_colour}\""
		end
		t.add "\n]\n"
		var supers = in_hierarchy.direct_greaters
		for i in supers do
			if i.mmodule != mmodule then continue
			t.add "{i.mmodule}{i.name} -> {mmodule}{name} [dir=back"
			if i.mclass.kind == interface_kind then
				t.add " arrowtail=open style=dashed"
			else
				t.add " arrowtail=empty"
			end
			t.add "]\n"
		end
		return t
	end
end

redef class MMethodDef
	redef fun tpl_module(model) do
		var t = new Template
		t.add mproperty.visibility.tpl_class
		t.add " "
		t.add name.escape_to_dot
		t.add msignature.tpl_class(model)
		return t
	end
end

redef class MAttributeDef
	redef fun tpl_module(model) do
		var t = new Template
		t.add mproperty.visibility.tpl_class
		t.add " "
		t.add name
		t.add ": "
		t.add static_mtype.tpl_class(model)
		return t
	end
end
src/uml/uml_module.nit:15,1--153,3