mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 22:19:44 +00:00
Fixes for the online docs
This commit is contained in:
@@ -1,19 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
die() {
|
|
||||||
echo "$1" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
file=$1
|
|
||||||
from=$2
|
|
||||||
to=$3
|
|
||||||
|
|
||||||
start_line=$(grep --line-number "$from" $file | cut -d':' -f1)
|
|
||||||
if [ -z "$start_line" ]; then
|
|
||||||
die "Cannot find $from in $file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
tail -n +$start_line $file | awk "BEGIN { getline; print \$0 } /$to/ { exit } { print }"
|
|
||||||
|
|
||||||
exit $?
|
|
@@ -11,6 +11,8 @@ use Pod::POM::View::Restructured;
|
|||||||
|
|
||||||
my $input_file = shift @ARGV or die "Need an input file";
|
my $input_file = shift @ARGV or die "Need an input file";
|
||||||
|
|
||||||
|
my $nofix = scalar @ARGV;
|
||||||
|
|
||||||
my $tool = basename($input_file);
|
my $tool = basename($input_file);
|
||||||
|
|
||||||
open my $in_fh, q{<:encoding(UTF-8)}, $input_file
|
open my $in_fh, q{<:encoding(UTF-8)}, $input_file
|
||||||
@@ -44,6 +46,11 @@ my $section = '';
|
|||||||
my $fixed_output = '';
|
my $fixed_output = '';
|
||||||
|
|
||||||
while (my $para = <$in>) {
|
while (my $para = <$in>) {
|
||||||
|
if ( $nofix ) {
|
||||||
|
$fixed_output .= $para;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
next if $para =~ m/^\.\. highlight:: perl/;
|
next if $para =~ m/^\.\. highlight:: perl/;
|
||||||
|
|
||||||
$in_code_block = $para =~ m/^\s{2,}/ ? 1 : 0;
|
$in_code_block = $para =~ m/^\s{2,}/ ? 1 : 0;
|
||||||
@@ -77,6 +84,7 @@ while (my $para = <$in>) {
|
|||||||
$para =~ s/^[ ]+$//mg;
|
$para =~ s/^[ ]+$//mg;
|
||||||
$para =~ s/^\n\n/\n/mg;
|
$para =~ s/^\n\n/\n/mg;
|
||||||
$para =~ s/code-block:: bash(\s+)CREATE/code-block:: sql$1CREATE/sg;
|
$para =~ s/code-block:: bash(\s+)CREATE/code-block:: sql$1CREATE/sg;
|
||||||
|
$para =~ s/\*\*:program/** :program/g;
|
||||||
if ( ($section || '') eq 'OUTPUT' ) {
|
if ( ($section || '') eq 'OUTPUT' ) {
|
||||||
$para =~ s/^([A-Z_]+)\n\n/$1\n/;
|
$para =~ s/^([A-Z_]+)\n\n/$1\n/;
|
||||||
}
|
}
|
||||||
@@ -86,7 +94,12 @@ while (my $para = <$in>) {
|
|||||||
|
|
||||||
close $in;
|
close $in;
|
||||||
|
|
||||||
print $header . $fixed_output;
|
if ($nofix) {
|
||||||
|
print $fixed_output;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print $header . $fixed_output;
|
||||||
|
}
|
||||||
|
|
||||||
sub format_links {
|
sub format_links {
|
||||||
if ( my ($label, $url) = split /\|/, $_[0] ) {
|
if ( my ($label, $url) = split /\|/, $_[0] ) {
|
||||||
|
@@ -5683,6 +5683,8 @@ use Pod::POM::View::Restructured;
|
|||||||
|
|
||||||
my $input_file = shift @ARGV or die "Need an input file";
|
my $input_file = shift @ARGV or die "Need an input file";
|
||||||
|
|
||||||
|
my $nofix = scalar @ARGV;
|
||||||
|
|
||||||
my $tool = basename($input_file);
|
my $tool = basename($input_file);
|
||||||
|
|
||||||
open my $in_fh, q{<:encoding(UTF-8)}, $input_file
|
open my $in_fh, q{<:encoding(UTF-8)}, $input_file
|
||||||
@@ -5716,6 +5718,11 @@ my $section = '';
|
|||||||
my $fixed_output = '';
|
my $fixed_output = '';
|
||||||
|
|
||||||
while (my $para = <$in>) {
|
while (my $para = <$in>) {
|
||||||
|
if ( $nofix ) {
|
||||||
|
$fixed_output .= $para;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
next if $para =~ m/^\.\. highlight:: perl/;
|
next if $para =~ m/^\.\. highlight:: perl/;
|
||||||
|
|
||||||
$in_code_block = $para =~ m/^\s{2,}/ ? 1 : 0;
|
$in_code_block = $para =~ m/^\s{2,}/ ? 1 : 0;
|
||||||
@@ -5749,6 +5756,7 @@ while (my $para = <$in>) {
|
|||||||
$para =~ s/^[ ]+$//mg;
|
$para =~ s/^[ ]+$//mg;
|
||||||
$para =~ s/^\n\n/\n/mg;
|
$para =~ s/^\n\n/\n/mg;
|
||||||
$para =~ s/code-block:: bash(\s+)CREATE/code-block:: sql$1CREATE/sg;
|
$para =~ s/code-block:: bash(\s+)CREATE/code-block:: sql$1CREATE/sg;
|
||||||
|
$para =~ s/\*\*:program/** :program/g;
|
||||||
if ( ($section || '') eq 'OUTPUT' ) {
|
if ( ($section || '') eq 'OUTPUT' ) {
|
||||||
$para =~ s/^([A-Z_]+)\n\n/$1\n/;
|
$para =~ s/^([A-Z_]+)\n\n/$1\n/;
|
||||||
}
|
}
|
||||||
@@ -5758,7 +5766,12 @@ while (my $para = <$in>) {
|
|||||||
|
|
||||||
close $in;
|
close $in;
|
||||||
|
|
||||||
print $header . $fixed_output;
|
if ($nofix) {
|
||||||
|
print $fixed_output;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print $header . $fixed_output;
|
||||||
|
}
|
||||||
|
|
||||||
sub format_links {
|
sub format_links {
|
||||||
if ( my ($label, $url) = split /\|/, $_[0] ) {
|
if ( my ($label, $url) = split /\|/, $_[0] ) {
|
||||||
|
@@ -72,17 +72,17 @@ fix_html () {
|
|||||||
my $f = shift;
|
my $f = shift;
|
||||||
my $tool = basename($f);
|
my $tool = basename($f);
|
||||||
$tool =~ s/\.html//;
|
$tool =~ s/\.html//;
|
||||||
my $out = do { open my $fh, '<', $f or die $!; local $/; <$fh> };
|
my $out = do { open my $fh, q{<}, $f or die "$f: $!"; local $/; <$fh> };
|
||||||
$out =~ s{
|
$out =~ s{
|
||||||
\Q<dt id="\E(cmdoption-$tool--)\Q">\E\s*
|
\Q<dt id="\E(cmdoption-$tool--)\Q">\E\s*
|
||||||
\Q<tt class="descname">--</tt><tt class="descclassname">\E([^<]+)
|
\Q<tt class="descname">--</tt><tt class="descclassname">\E([^<]+)
|
||||||
\Q</tt><a class="headerlink" href="\E[^"]+"
|
\Q</tt><a class="headerlink" href="\E[^"]+"
|
||||||
}{<dt id="$1$2">
|
}{<dt id="$1$2">
|
||||||
<tt class="descname">--$2</tt><tt class="descclassname"></tt><a class="headerlink" href="#$1$2"}xg;
|
<tt class="descname">--$2</tt><tt class="descclassname"></tt><a class="headerlink" href="#$1$2"}xg;
|
||||||
open my $fh, '>', $f or die "Cannot open $f for writing: $!";
|
open my $fh, q{>}, $f or die "Cannot open $f for writing: $!";
|
||||||
print { $f } $out;
|
print { $f } $out;
|
||||||
close $fh or die "Cannot close $f: $!";
|
close $fh or die "Cannot close $f: $!";
|
||||||
' $RST_DIR/html/$name.html
|
' "$RST_DIR/html/$name.html"
|
||||||
}
|
}
|
||||||
|
|
||||||
write_rst() {
|
write_rst() {
|
||||||
@@ -120,10 +120,15 @@ write_sections() {
|
|||||||
filename=$(echo $section | sed -e 's/,//g' -e 's/[()]//g' | tr "[:upper:]" "[:lower:]");
|
filename=$(echo $section | sed -e 's/,//g' -e 's/[()]//g' | tr "[:upper:]" "[:lower:]");
|
||||||
|
|
||||||
# Extract the section as POD.
|
# Extract the section as POD.
|
||||||
$BRANCH/util/extract-text $DOCS_DIR/percona-toolkit.pod "^=head1 $header" "^=head1|=cut" > /tmp/$filename.pod
|
local start_line=$(grep --line-number "^=head1 $header" $DOCS_DIR/percona-toolkit.pod | cut -d':' -f1)
|
||||||
|
if [ -z "$start_line" ]; then
|
||||||
|
die "Cannot find $from in $DOCS_DIR/percona-toolkit.pod"
|
||||||
|
fi
|
||||||
|
|
||||||
|
tail -n +$start_line $DOCS_DIR/percona-toolkit.pod | awk "BEGIN { getline; print \$0 } /^=head1|=cut/ { exit } { print }" > /tmp/$filename.pod
|
||||||
|
|
||||||
# Convert POD to RST and remove all the Perl highlight blocks.
|
# Convert POD to RST and remove all the Perl highlight blocks.
|
||||||
$BRANCH/util/pod2rst-fixed.packed /tmp/$filename.pod | sed -e 's/.. highlight:: perl//g' > /tmp/$filename.tmp
|
$BRANCH/util/pod2rst-fixed.packed /tmp/$filename.pod --no-fix | sed -e 's/.. highlight:: perl//g' > /tmp/$filename.tmp
|
||||||
|
|
||||||
# Remove extra blank lines.
|
# Remove extra blank lines.
|
||||||
cat -s /tmp/$filename.tmp > $RST_DIR/$filename.rst
|
cat -s /tmp/$filename.tmp > $RST_DIR/$filename.rst
|
||||||
|
Reference in New Issue
Block a user