Build Status

NAME

PlantUML::ClassDiagram::Parse - PlantUML class diagram syntax parser

SYNOPSIS

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

DESCRIPTION

PlantUML::ClassDiagram::Parse is parser for PlantUML class diagram syntax It generate objects that represent class structure written in class diagram.

WAY TO USE

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

class

PlantUML::ClassDiagram::Class - represent each class

method

PlantUML::ClassDiagram::Class::Method - represent each method

variable

PlantUML::ClassDiagram::Class::Variable - represent each member variable

relations

PlantUML::ClassDiagram::Relation - represent class to class relation

Only support follow relation syntax

LICENSE

Copyright (C) Kenta Kase.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Kenta Kase <kesin1202000@gmail.com>