diff --git a/scripts/docs/update_web_vep_plugins_documentation.pl b/scripts/docs/update_web_vep_plugins_documentation.pl index 77ef3eb0d..ab7233a1a 100644 --- a/scripts/docs/update_web_vep_plugins_documentation.pl +++ b/scripts/docs/update_web_vep_plugins_documentation.pl @@ -141,12 +141,12 @@ =head1 CONTACT # Print output HTML open OUT, "> $output_file" or die $!; -my $table_content .= qq{ -
Plugin | -Description | +Description | Category | External libraries | Developer | @@ -170,13 +170,14 @@ =head1 CONTACT $plugin_class_list{$plugin_class} = $plugin_id; $table_content .= sprintf( - '
---|---|---|---|---|---|
%s | '. '%s | '. - '%s | '.
+ '%s | '.
'%s | '. '%s | '. '
' . $line if $table; + $table = 1; + $table_newline = 0; + chomp($line); + $line .= + '
Argument | Description |
---|---|
' . $arg . ' | ',
+ '' . $description . ' '); + $table_newline = 0; + } elsif ($table_newline) { + $line = ' |
' . $line; + $table = 0; + $table_newline = 0; + } elsif ($line =~ '^\s+$') { + $table_newline = 1; + } + } + # Add code block -- three types of code blocks: # 1. to show a code script - # start: line starts with ##### or contains # BEGIN - # end: line contains # END + # start: line contains # BEGIN or starts with ``` or ##### + # end: line contains # END or starts with ``` # 2. to show arbitrary code lines # line starts with > or --plugin or bash commands (see $cmds) # 3. to illustrate variant location: # start: line contains v (variant) after 3 or more spaces # end: line only contains I (intron) or ES/EE (exon start/end) - if ($line =~ /#{5,}/ || $line =~ /# BEGIN/) { - # start block of code script - $line = '
' . $line unless $code_script; - $code_script = 1; - } elsif ($code_script) { - # continue code script until getting to a line containing # END - if ($line =~ /# END/) { + if ($code_script) { + # continue code script until getting to a line containing # END or ``` + $line =~ s/^\s*>?\s?//; + if ($line =~ /# END/ || $line =~ /^\s*```\s*$/) { + $line = '' if $line =~ /^\s*```\s*$/; $line .= ''; $code_script = 0; } + } elsif ($line =~ /#{5,}/ || $line =~ /# BEGIN/ || $line =~ /^\s*```\s*$/) { + # start block of code script + $line = '' if $line =~ /^\s*```\s*$/; + $line = '
' . $line unless $code_script; + $code_script = 1; } elsif ($line =~ /^\s{3,}v/) { # start code block to illustrate variant position $line = '' . $line unless $code_block; @@ -332,30 +414,50 @@ sub read_plugin_file { # end code block to illustrate variant position $line .= ''; $code_block = 0; - } elsif ($line =~ /^\s*>\s?/ || $line =~ /^\s*($cmds)\s/ || $line =~ /^\s*--plugin/) { + } elsif ($line =~ /^\s*\>\s?/ || $line =~ /^\s*($cmds)\s/ || $line =~ /^\s*--plugin/) { # start code block (terminal commands) - $line =~ s/^\s*>?\s?//; + $line =~ s/^\s*(\>)?\s?//; $line = '' . $line unless $code_block; $code_block = 1; } else { - $line =~ s/^\s+// if $line =~ /\S+/; if ($code_block) { # remove blank lines after code block (looks nicer) $line = "" if $line =~ /^\s+$/; # end code block (terminal commands) - $line = '' . $line; + $line = '
' . $line; $code_block = 0; } } + + # Create ordered list from numbers at line start + if ($line =~ /^\s*\(?([0-9]+)[\)\.] (.*)/) { + $line = ($olist ? '' : '
' . $line; + $olist = 0; + } elsif ($line =~ '^\s+$') { + $olist_newline = 1; + } else { + $line = $line; + } + } + $desc .= $line; - $line = '' . $line if $code_block; + $line = '
' . $line if $code_block; } } chomp($line); } + $desc .= '
' if $ulist_newline; + $desc .= '
' if $olist_newline; + $desc .= '
' if $table_newline; + $desc .= '
' if $code_block; } - + # Get the non Ensembl Perl module dependencies if ($line =~ /^use\s+(.+);/) { my $lib = $1; @@ -364,24 +466,33 @@ sub read_plugin_file { $libs{$lib} = qq{$1$2}; } - } + } } + close(F); # Make URLs clickable - $desc =~ s|((http\|ftp)s?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9():]{0,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*[^\)\.,;:\s]))|$1|g; - + $desc =~ s|((http\|ftp)s?:\/\/(www\.)?[-a-zA-Z0-9\@:%._\+~#=]{1,256}\.[a-zA-Z0-9():]{0,6}\b([-a-zA-Z0-9()\@:%_\+.~#?&//=]*[^\)\.,;:\s\<]))|$1|g; + + # Convert DOI to URL + $desc =~ s|(doi:([^\s]+[A-Za-z0-9]))|$1|g; + + # Convert pair of single quotes to code + $desc =~ s|[\'\`]([\w:\-?\/_\.\|\&\,\;\=\]\[]*)[\'\`]|$1|g; + + # Add usage examples + $desc .= '
' . $usage . '
'; + # Postprocess the description content (reformatting) $desc = "$desc
"; $desc =~ s/\n\s*\n/<\/p>/g; $desc =~ s/<\/p>
<\/p>/<\/p>/g;
- $desc =~ s/\n/
/g;
$desc =~ s/
<\/p>/<\/p>/g;
if ($desc =~ /<\/p>
/) { my $lc_name = lc($name); $lc_name =~ s/ /_/g; my $desc_link = qq{ more}; - $desc =~ s/<\/p>
/$desc_link<\/p>