package JatsDocTools::TOC::HTML; use strict; use warnings; use base 'JatsDocTools::TOC'; use Data::Dumper; sub text { my $text = join("\n", @_, ""); return sub { $text }; } my $genTail = ''; sub genHeader { my ($title, $tip, $class, $open) = @_; my @tail; my @head; push @head, '
', '', '', '', ''. $title . '
', '
', '
'; if ( $open ) { push @tail, ''; } $genTail = text(@tail); return text (@head); } # extra info is tedious to collect -- is done in a subclass or something. sub extra { '' }; *header = text(''); # text ("
","JATS Core Documentation
",); *footer = text("\n\n\n\n"); *before_faq = genHeader( 'JATS FAQ', 'Selected Frequently Asked Questions on building with JATS as well as the JATS Utilities', 'faq', 0 ); *after_faq = $genTail; sub faq_section { my($self, $file, $heading) = @_; my $ref = $self->{Faqs}->{$heading}{$file}; my $tip = $file; $file =~ s~\s~ ~g; return (qq'
  • ' . _page($self->{faq}->{$ref}, $file, $self->extra($file), $tip) ); } # Create a Hash of headings sub preProcFaq { my($self) = @_; my %Faqs; foreach my $faq ( keys %{$self->{faq}}) { my $data = $faq; $faq =~ s~.*FAQ::~~; my @data = split ('::', $faq ); if ( $data[1] ) { $Faqs{$data[0]}{$data[-1]} = $data; } else { $Faqs{''}{$data[0]} = $data; } } $self->{Faqs} = \%Faqs; #print Dumper($self->{Faqs}); #print Dumper($self->{faq}); } sub after_faq_section { '';} sub before_faq_section { my($self, $header) = @_; if ( $header ) { return ('
    ' . $header . '
    '); } } *before_Jats = genHeader( 'Build and Make', 'Utilities to build and make JATS packages', 'Jats',1 ); *after_Jats = $genTail; sub Jats { my($self, $file) = @_; return (qq'
  • ' . _page($self->{Jats}->{$file}, $file, $self->extra($file))); } *before_Deploy = genHeader( 'Deployment Utilities', 'Utilities to assist in the deployment process', 'Deploy' ); *after_Deploy = $genTail; sub Deploy { my($self, $file) = @_; return (qq'
  • ' . _page($self->{Deploy}->{$file}, $file, $self->extra($file))); } *before_Core = genHeader( 'Core Documentation', 'Information about the JATS environment', 'core', 1 ); *after_Core = $genTail; sub Core { my($self, $file) = @_; return (qq'
  • ' . _page($self->{Core}->{$file}, $file, $self->extra($file))); } *before_sutil = genHeader( 'System Utilities', 'Utilities used by the JATS build system. These utilities are not normally used directly by users.', 'sutil' ); *after_sutil = $genTail; sub sutil { my($self, $file) = @_; return (qq'
  • ' . _page($self->{sutil}->{$file}, $file, $self->extra($file))); } *before_general = genHeader( 'User Utilities', 'Command line utilities available to users.', 'General', 1 ); *after_general = $genTail; # Create a Hash of headings sub preProcGeneral { my($self) = @_; my %GenSec; foreach my $entry ( keys %{$self->{General}}) { my $data = $entry; $entry =~ s~GENERAL::~~; $entry =~ s~TOOLS::(.+::)*~~; my @data = split ('::', $entry ); if ( $data[1] ) { $GenSec{$data[0]}{$data[-1]} = $data; } else { $GenSec{''}{$data[0]} = $data; } } $self->{GenSec} = \%GenSec; #print Dumper($self->{GenSec}); #print Dumper($self->{General}); } sub after_general_section { '';} sub before_general_section { my($self, $header) = @_; if ( $header ) { return ('
    ' . $header . '
    '); } } sub general_section { my($self, $file, $heading) = @_; my $ref = $self->{GenSec}->{$heading}{$file}; my $tip = $file; $file =~ s~\s~ ~g; return (qq'
  • ' . _page($self->{General}->{$ref}, $file, $self->extra($file), $tip) ); } *before_mutil = genHeader( 'Make Utilities', 'Utilities used by makefiles to assist in the build process. These are not normally used by CLI users.', 'mutil' ); *after_mutil = $genTail; sub mutil { my($self, $file) = @_; return (qq'
  • ' . _page($self->{mutil}->{$file}, $file, $self->extra($file))); } sub _page { my($href, $text, $extra, $tip) = @_; die "bad arguments to _page: ($href, $text, $extra)" unless defined $href and defined $text; $extra ||= ''; $extra = " $extra" if $extra; # just to make it EXACTLY identical to the old way. $text =~ s~.*::~~; my $inner = "class=\"doc\""; if ( $tip ) { $inner .= " title=\"$tip\""; } return qq'$text$extra
  • \n'; } sub boilerplate { return boiler_header() . boiler_links(); } sub boiler_header { return <<'HERE'; JATS User Guide - Table of Contents

    Table of Contents

    HERE } sub boiler_links { my $retval = < Getting Started
    HERE # # ToDo #
  • Installation Guide
  • #
  • Getting Started
  • #
  • Jats Change Log
  • #
  • More Resources
  • #
  • License and Copyright
  • #$retval .= <JATS Components
    # #HERE # return $retval; } 1;