1#################################################################################################################################### 2# DOC MARKDOWN MODULE 3#################################################################################################################################### 4package pgBackRestDoc::Markdown::DocMarkdown; 5 6use strict; 7use warnings FATAL => qw(all); 8use Carp qw(confess); 9 10use Data::Dumper; 11use Exporter qw(import); 12 our @EXPORT = qw(); 13use File::Basename qw(dirname); 14use File::Copy; 15use POSIX qw(strftime); 16use Storable qw(dclone); 17 18use pgBackRestTest::Common::ExecuteTest; 19 20use pgBackRestDoc::Common::DocConfig; 21use pgBackRestDoc::Common::DocManifest; 22use pgBackRestDoc::Common::Log; 23use pgBackRestDoc::Common::String; 24use pgBackRestDoc::Markdown::DocMarkdownRender; 25use pgBackRestDoc::ProjectInfo; 26 27#################################################################################################################################### 28# CONSTRUCTOR 29#################################################################################################################################### 30sub new 31{ 32 my $class = shift; # Class name 33 34 # Create the class hash 35 my $self = {}; 36 bless $self, $class; 37 38 $self->{strClass} = $class; 39 40 # Assign function parameters, defaults, and log debug info 41 ( 42 my $strOperation, 43 $self->{oManifest}, 44 $self->{strXmlPath}, 45 $self->{strMarkdownPath}, 46 $self->{bExe} 47 ) = 48 logDebugParam 49 ( 50 __PACKAGE__ . '->new', \@_, 51 {name => 'oManifest'}, 52 {name => 'strXmlPath'}, 53 {name => 'strMarkdownPath'}, 54 {name => 'bExe'} 55 ); 56 57 # Return from function and log return values if any 58 return logDebugReturn 59 ( 60 $strOperation, 61 {name => 'self', value => $self} 62 ); 63} 64 65#################################################################################################################################### 66# process 67# 68# Generate the site html 69#################################################################################################################################### 70sub process 71{ 72 my $self = shift; 73 74 # Assign function parameters, defaults, and log debug info 75 my $strOperation = logDebugParam(__PACKAGE__ . '->process'); 76 77 foreach my $strRenderOutId ($self->{oManifest}->renderOutList(RENDER_TYPE_MARKDOWN)) 78 { 79 my $oRenderOut = $self->{oManifest}->renderOutGet(RENDER_TYPE_MARKDOWN, $strRenderOutId); 80 my $strFile = "$self->{strMarkdownPath}/" . (defined($$oRenderOut{file}) ? $$oRenderOut{file} : "${strRenderOutId}.md"); 81 82 &log(INFO, " render out: ${strRenderOutId}"); 83 84 # Save the html page 85 $self->{oManifest}->storage()->put( 86 $strFile, $self->{oManifest}->variableReplace((new pgBackRestDoc::Markdown::DocMarkdownRender($self->{oManifest}, 87 $strRenderOutId, $self->{bExe}))->process())); 88 } 89 90 # Return from function and log return values if any 91 logDebugReturn($strOperation); 92} 93 941; 95