You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-16 23:47:38 +02:00
Improvements to documentation engine:
* Documentation can now be built with reusable blocks to reduce duplication. * Added ability to pass options to containers within the documentation. * Add proper tag to slightly emphasize proper nouns.
This commit is contained in:
@ -9,6 +9,8 @@ use Carp qw(confess);
|
||||
|
||||
use Exporter qw(import);
|
||||
our @EXPORT = qw();
|
||||
use JSON::PP;
|
||||
use Storable qw(dclone);
|
||||
|
||||
use pgBackRest::Common::Log;
|
||||
use pgBackRest::Common::String;
|
||||
@ -48,6 +50,7 @@ my $oRenderTag =
|
||||
# 'code-block' => ['```', '```'],
|
||||
# 'exe' => [undef, ''],
|
||||
'backrest' => [undef, ''],
|
||||
'proper' => ['', ''],
|
||||
'postgres' => ['PostgreSQL', '']
|
||||
},
|
||||
|
||||
@ -73,6 +76,7 @@ my $oRenderTag =
|
||||
'code-block' => ['', ''],
|
||||
'exe' => [undef, ''],
|
||||
'backrest' => [undef, ''],
|
||||
'proper' => ['', ''],
|
||||
'postgres' => ['PostgreSQL', '']
|
||||
},
|
||||
|
||||
@ -103,6 +107,7 @@ my $oRenderTag =
|
||||
# 'code-block' => ['', ''],
|
||||
# 'exe' => [undef, ''],
|
||||
'backrest' => [undef, ''],
|
||||
'proper' => ['\textnormal{\texttt{', '}}'],
|
||||
'postgres' => ['PostgreSQL', '']
|
||||
},
|
||||
|
||||
@ -130,6 +135,7 @@ my $oRenderTag =
|
||||
'exe' => [undef, ''],
|
||||
'setting' => ['<span class="br-setting">', '</span>'], # ??? This will need to be fixed
|
||||
'backrest' => [undef, ''],
|
||||
'proper' => ['<span class="host">', '</span>'],
|
||||
'postgres' => ['<span class="postgres">PostgreSQL</span>', '']
|
||||
}
|
||||
};
|
||||
@ -160,6 +166,9 @@ sub new
|
||||
{name => 'strRenderOutKey', required => false}
|
||||
);
|
||||
|
||||
# Create JSON object
|
||||
$self->{oJSON} = JSON::PP->new()->allow_nonref();
|
||||
|
||||
# Initialize project tags
|
||||
$$oRenderTag{markdown}{backrest}[0] = "{[project]}";
|
||||
$$oRenderTag{markdown}{exe}[0] = "{[project-exe]}";
|
||||
@ -373,6 +382,56 @@ sub build
|
||||
$oNode->paramSet('section', $strNewPath);
|
||||
}
|
||||
}
|
||||
# Store block defines
|
||||
elsif ($strName eq 'block-define')
|
||||
{
|
||||
my $strBlockId = $oNode->paramGet('id');
|
||||
|
||||
if (defined($self->{oyBlockDefine}{$strBlockId}))
|
||||
{
|
||||
confess &log(ERROR, "block ${strBlockId} is already defined");
|
||||
}
|
||||
|
||||
$self->{oyBlockDefine}{$strBlockId} = dclone($oNode->{oDoc}{children});
|
||||
$oParent->nodeRemove($oNode);
|
||||
# use Data::Dumper; confess "DATA" . Dumper($self->{oyBlockDefine});
|
||||
# confess "GOT HERE";
|
||||
}
|
||||
# Copy blocks
|
||||
elsif ($strName eq 'block')
|
||||
{
|
||||
my $strBlockId = $oNode->paramGet('id');
|
||||
|
||||
if (!defined($self->{oyBlockDefine}{$strBlockId}))
|
||||
{
|
||||
confess &log(ERROR, "block ${strBlockId} is not defined");
|
||||
}
|
||||
|
||||
my $strNodeJSON = $self->{oJSON}->encode($self->{oyBlockDefine}{$strBlockId});
|
||||
|
||||
foreach my $oVariable ($oNode->nodeList('block-variable-replace'))
|
||||
{
|
||||
my $strVariableKey = $oVariable->paramGet('key');
|
||||
my $strVariableReplace = $oVariable->valueGet();
|
||||
|
||||
$strNodeJSON =~ s/\{\[$strVariableKey\]\}/$strVariableReplace/g;
|
||||
}
|
||||
|
||||
my ($iReplaceIdx, $iReplaceTotal) = $oParent->nodeReplace($oNode, $self->{oJSON}->decode($strNodeJSON));
|
||||
|
||||
# Build any new children that were added
|
||||
my $iChildIdx = 0;
|
||||
|
||||
foreach my $oChild ($oParent->nodeList(undef, false))
|
||||
{
|
||||
if ($iChildIdx >= $iReplaceIdx && $iChildIdx < ($iReplaceIdx + $iReplaceTotal))
|
||||
{
|
||||
$self->build($oChild, $oParent, $strPath, $strPathPrefix);
|
||||
}
|
||||
|
||||
$iChildIdx++;
|
||||
}
|
||||
}
|
||||
|
||||
# Iterate all text nodes
|
||||
if (defined($oNode->textGet(false)))
|
||||
|
Reference in New Issue
Block a user