PlantUML::ClassDiagram::Parse - PlantUML class diagram syntax parser
use List::Util qw/first/;
use Data::Section::Simple qw/get_data_section/;
my $pu_string = get_data_section('synopsis.pu');
my $parse = PlantUML::ClassDiagram::Parse->parse($pu_string);
my $classes = $parse->get_classes;
# bless( {
# 'relations' => [
# bless( {
# 'from' => 'Foo',
# 'to' => 'Base',
# 'name' => 'generalization'
# }, 'PlantUML::ClassDiagram::Relation' )
# ],
# 'variables' => [
# bless( {
# 'attribute' => '',
# 'name' => 'foo'
# }, 'PlantUML::ClassDiagram::Class::Variable' )
# ],
# 'attribute' => '',
# 'name' => 'Base',
# 'methods' => [
# bless( {
# 'name' => 'new',
# 'attribute' => 'static'
# }, 'PlantUML::ClassDiagram::Class::Method' ),
# bless( {
# 'name' => 'bar',
# 'attribute' => 'abstract'
# }, 'PlantUML::ClassDiagram::Class::Method' )
# ]
# }, 'PlantUML::ClassDiagram::Class' ),
# bless( {
# 'methods' => [
# bless( {
# 'name' => 'new',
# 'attribute' => 'static'
# }, 'PlantUML::ClassDiagram::Class::Method' ),
# bless( {
# 'name' => 'bar',
# 'attribute' => ''
# }, 'PlantUML::ClassDiagram::Class::Method' )
# ],
# 'name' => 'Foo',
# 'relations' => [
# $VAR1->[0]{'relations'}[0]
# ],
# 'variables' => [
# bless( {
# 'name' => 'foo',
# 'attribute' => ''
# }, 'PlantUML::ClassDiagram::Class::Variable' )
# ],
# 'attribute' => ''
# }, 'PlantUML::ClassDiagram::Class' )
my $foo = first { $_->get_name eq 'Foo' } @$classes;
$foo->get_parents;
# [ 'Base' ];
__DATA__
@@ synopsis.pu
@startuml
class Base {
foo
{static} new()
{abstract} bar()
}
class Foo {
foo
{static} new()
bar()
}
Foo --|> Base
@enduml
PlantUML::ClassDiagram::Parse is parser for PlantUML class diagram syntax It generate objects that represent class structure written in class diagram.
Generate perl module using PlantUML::ClassDiagram::Class objects. In fact you will also use template engine (ex: Text::Xslate) together.
Sample script: See examples/generate_pm_sample.pl
PlantUML::ClassDiagram::Class - represent each class
-
get_name()
own class name
-
get_attribute()
'' or 'abstract'
-
get_variables()
PlantUML::ClassDiagram::Class::Variable objects
-
get_methods()
PlantUML::ClassDiagram::Class::Method objects
-
get_relations()
PlantUML::ClassDiagram::Relation objects related in own class
-
get_parents()
parent class names it guessed from 'generalization' relation
PlantUML::ClassDiagram::Class::Method - represent each method
-
get_name()
own method name
-
get_attribute()
'' or 'abstract' or 'static'
PlantUML::ClassDiagram::Class::Variable - represent each member variable
-
get_name()
own method name
-
get_attribute()
'' or 'abstract' or 'static'
PlantUML::ClassDiagram::Relation - represent class to class relation
-
get_name()
own relation name
-
get_from()
from class name
-
get_to()
to class name
Only support follow relation syntax
- association
- generalization
- realization
- aggregation
- composite
Copyright (C) Kenta Kase.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Kenta Kase <[email protected]>