Skip Menu |

This queue is for tickets about the Autodia CPAN distribution.

Report information
The Basics
Id: 63372
Status: stalled
Estimated: 2 hours (120 min)
Priority: 0/
Queue: Autodia

People
Owner: Nobody in particular
Requestors:
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 2.10
Fixed in: (no value)



Subject: Sort identifiers in graphviz mode
I like seeing identifiers sorted. The attached patch file will make this so for GraphViz files.
Subject: autodia.sorted_identifiers.patch
diff -ur Autodia-2.10/lib/Autodia/Diagram.pm Autodia/lib/Autodia/Diagram.pm --- Autodia-2.10/lib/Autodia/Diagram.pm 2009-06-24 03:49:02.000000000 -0700 +++ Autodia/lib/Autodia/Diagram.pm 2010-11-26 22:58:57.000000000 -0800 @@ -470,6 +470,26 @@ return \@dependancies; } +# ================ +# group by visibility, then by leading underscores, then by remaining name... +sub _sort_by_visibility_then_identifier { + my @sorted = map { + $_->[0] + } + sort { + $a->[1] <=> $b->[1] || # visibility + length($b->[2]) <=> length($a->[2]) || # inverse by number of underscores + $a->[3] cmp $b->[3] # remaining name + } + map { + # Create list reference with these elements: + # 0. original reference, 1. visibility 2. leading underscores, 3. name stripped of underscores + [ $_, $_->{visibility}, ( $_->{name} =~ m/ ^ (_*) (.*) /x ) ] + } @_; + # warn "returning from _sort_by_visibility_then_identifier:\n", Dumper \@sorted; + return @sorted; +} + ########################################################## # export_graphviz - output to file via GraphViz.pm and dot @@ -505,8 +525,12 @@ if ($config{methods}) { my @method_strings = (); my ($methods) = ($Class->Operations); - foreach my $method (@$methods) { - next if ($method->{visibility} == 1 && $config{public}); + my @sorted_methods = _sort_by_visibility_then_identifier @$methods; + # printf("%s sorted_methods:\n\t", $Class->Name); + # printf('(%s->%d)', $_->{name}, $_->{visibility}) foreach @sorted_methods; + # print "\n"; + foreach my $method ( @sorted_methods ) { + next if ($method->{visibility} == 1 && $config{public}); my $method_string = ($method->{visibility} == 0) ? '+ ' : '- '; $method_string .= $method->{name}."("; if (ref $method->{"Params"} ) { @@ -526,7 +550,8 @@ $node .= "|"; if ($config{attributes}) { my ($attributes) = ($Class->Attributes); - foreach my $attribute (@$attributes) { + my @sorted_attributes = _sort_by_visibility_then_identifier @$attributes; + foreach my $attribute ( @sorted_attributes ) { next if ($attribute->{visibility} == 1 && $config{public}); $node .= ($attribute->{visibility} == 0) ? '+ ' : '- '; $node .= $attribute->{name}; @@ -538,6 +563,7 @@ } else { $node .= '\l'; } + # warn "adding $attribute->{name} node: $node"; } } @@ -2142,8 +2168,7 @@ <dia:point val="[% realization.Orth_Top_Right %]"/> </dia:attribute> <dia:attribute name="obj_bb"> - <dia:rectangle val="[% realization.Orth_Top_Right %];[% realization.Orth -_Bottom_Left %]"/> + <dia:rectangle val="[% realization.Orth_Top_Right %];[% realization.Orth_Bottom_Left %]"/> </dia:attribute> <dia:attribute name="orth_points"> <dia:point val="[% realization.Orth_Bottom_Left%]"/>
Hmm... this is very much a matter of taste - I want to see if it's worth or possible to make sorting of functions, etc an option Will get back to you on this