diff --git a/lib/WeBWorK/ContentGenerator/PODViewer.pm b/lib/WeBWorK/ContentGenerator/PODViewer.pm index e07ac0a61a..f1c2498df0 100644 --- a/lib/WeBWorK/ContentGenerator/PODViewer.pm +++ b/lib/WeBWorK/ContentGenerator/PODViewer.pm @@ -32,13 +32,32 @@ sub PODindex ($c) { my $podFiles = Pod::Simple::Search->new->inc(0)->limit_re(qr/^doc|^lib|^macros/)->survey($pgRoot); - my $sections = {}; + my $docs = []; + my $macros = {}; + my $libs = []; for (sort keys %$podFiles) { my $section = $_ =~ s/::.*$//r; - push(@{ $sections->{$section} }, $podFiles->{$_} =~ s!^$pgRoot/$section/!!r); + if ($section eq 'doc') { + push(@$docs, $podFiles->{$_} =~ s!^$pgRoot/!!r); + } elsif ($section eq 'lib') { + push(@$libs, $podFiles->{$_} =~ s!^$pgRoot/lib/!!r); + } else { + my $macro = $podFiles->{$_} =~ s!^$pgRoot/macros/(.+)/.+$!$1!r; + if ($macro =~ /^$pgRoot/) { + push(@$docs, $podFiles->{$_} =~ s!^$pgRoot/!!r); + } else { + push(@{ $macros->{$macro} }, $podFiles->{$_} =~ s!^$pgRoot/macros/$macro/!!r); + } + } } - return $c->render('ContentGenerator/PODViewer', sections => $sections, sidebar_title => $c->maketext('Categories')); + return $c->render( + 'ContentGenerator/PODViewer', + docs => $docs, + macros => $macros, + libs => $libs, + sidebar_title => $c->maketext('Categories') + ); } sub renderPOD ($c) { diff --git a/templates/ContentGenerator/PODViewer.html.ep b/templates/ContentGenerator/PODViewer.html.ep index 89804f5fa6..416486dc49 100644 --- a/templates/ContentGenerator/PODViewer.html.ep +++ b/templates/ContentGenerator/PODViewer.html.ep @@ -6,26 +6,62 @@ % lib => maketext('Libraries'), % macros => maketext('Macros') % ); +% my %macro_names = ( + % answers => maketext('Answers'), + % contexts => maketext('Contexts'), + % core => maketext('Core'), + % deprecated => maketext('Deprecated'), + % graph => maketext('Graph'), + % math => maketext('Math'), + % misc => maketext('Miscellaneous'), + % parsers => maketext('Parsers'), + % ui => maketext('User Interface') +% ); % -% for my $section (sort keys %$sections) { - % content_for toc => begin - <%= link_to $section_names{$section} => "#$section", class => 'nav-link' %> +% content_for pod_links => begin +

<%= $section_names{doc} %>

+
+ % for (@$docs) { + % my $link_name = $_ =~ s!^(doc|macros)/!!r; + <%= link_to $link_name, 'pod_viewer', { filePath => "$_" }, + class => 'list-group-item list-group-item-action' =%> + % } +
+

<%= $section_names{macros} %>

+% end +% for my $macro (qw(core contexts parsers answers graph math ui misc deprecated)) { + % content_for macros_toc => begin + <%= link_to $macro_names{$macro} => "#macro-$macro", class => 'nav-link' %> % end - % content_for subjects => begin -

<%= $section_names{$section} %>

+ % content_for pod_links => begin +

<%= $macro_names{$macro} %>

- % for (@{ $sections->{$section} }) { - % my $link_name = $_; - % $link_name = $1 =~ s!/!::!gr if $link_name =~ m/^(.*)\.pm$/; - <%= link_to $link_name, 'pod_viewer', { filePath => "$section/$_" }, + % for (@{ $macros->{$macro} }) { + <%= link_to $_, 'pod_viewer', { filePath => "macros/$macro/$_" }, class => 'list-group-item list-group-item-action' =%> % }
% end % } +% content_for pod_links => begin +

<%= $section_names{lib} %>

+
+ % for (@$libs) { + % my $link_name = $_; + % $link_name = $1 =~ s!/!::!gr if $link_name =~ m/^(.*)\.pm$/; + <%= link_to $link_name, 'pod_viewer', { filePath => "lib/$_" }, + class => 'list-group-item list-group-item-action' =%> + % } +
+% end % content_for sidebar => begin % end -<%= content 'subjects' %> +<%= content 'pod_links' %>