The branch master has been updated via 1763c4db685b43c58b33d2ace0435da1a067ba24 (commit) via 8e80d7699c38ef890cc62da9fd713bcfc49152db (commit) via 98d1be0a1bcd7ae582753e54b523faf6b4bd1360 (commit) from 04c0cb565a81ed4357722dcce70c50b3575e2863 (commit)
- Log ----------------------------------------------------------------- commit 1763c4db685b43c58b33d2ace0435da1a067ba24 Author: Richard Levitte <levi...@openssl.org> Date: Tue Jan 29 22:21:39 2019 +0100 bin/mk-mancross: new manpage cross reference script Reviewed-by: Matt Caswell <m...@openssl.org> (Merged from https://github.com/openssl/web/pull/107) commit 8e80d7699c38ef890cc62da9fd713bcfc49152db Author: Richard Levitte <levi...@openssl.org> Date: Tue Jan 29 21:33:30 2019 +0100 bin/mk-manpages: refactor to allow cross references between releases So far, we created one HTML file for each POD file, and then made hard links to it for other names that are in the POD file's NAMES section. However, this came with the assumption that cross referencing between releases would work simply be linking to the same name on other releases. This, however, did not take into account that manuals in newer releases don't necessarily exist in older releases, or that some files may have changed names. Names in NAMES sections are, however, fairly constant, and are therefore much safer to link to. At the same time, it's safe to say that if a particular name doesn't exist in some other releases, there should simply not be a link. A conclusion to draw from is that cross referencing must be made on a per NAMES section name basis, rather than on POD file name basis. To allow this to happen and still not have to rewrite the same Pod2Html result for every name in a specific POD file's NAMES section, the structure of the rendered man pages are changed to this: - POD files are rendered into a .inc file with the exact same basename as the POD file. - For every name in the NAMES section, am HTML file is created. It contains the standard header and footer stuff, and includes the generated .inc file in the middle. It also includes a .cross file with the same basename as the HTML file as part of the sidebar. In another commit, there will be a script for cross referencing, which will generate the .cross files mentioned above. Reviewed-by: Matt Caswell <m...@openssl.org> (Merged from https://github.com/openssl/web/pull/107) commit 98d1be0a1bcd7ae582753e54b523faf6b4bd1360 Author: Richard Levitte <levi...@openssl.org> Date: Thu Jan 3 16:37:24 2019 +0100 Handle document sectioning correctly Gone are the apps/, crypto/ and ssl/ directories. We move to a Unix manpage structure for older releases as well as new ones. With that, there's no more need for a separate bin/mk-newmanpages, bin/mk-manpages can handle both the old and the new POD directory structure. For a document tree that previously had apps/, crypto/ and ssl/, we provide a .htaccess that accepts the old URLs and maps them correctly to man1/ or man3/. Reviewed-by: Matt Caswell <m...@openssl.org> (Merged from https://github.com/openssl/web/pull/107) ----------------------------------------------------------------------- Summary of changes: .gitignore | 1 + Makefile | 26 +- bin/mk-mancross | 54 ++++ bin/mk-manmap | 27 ++ bin/mk-manpages | 300 ++++++++++----------- bin/mk-newmanpages | 315 ----------------------- docs/man1.0.2/crypto/index.html | 43 ---- docs/man1.0.2/index.html | 7 +- docs/{man1.1.0/apps => man1.0.2/man1}/index.html | 5 +- docs/{man1.1.0/ssl => man1.0.2/man3}/index.html | 17 +- docs/{man1.1.1/man7 => man1.0.2/man5}/index.html | 8 +- docs/{man1.1.1 => man1.0.2}/man7/index.html | 8 +- docs/man1.1.0/crypto/index.html | 43 ---- docs/man1.1.0/index.html | 7 +- docs/{man1.0.2/apps => man1.1.0/man1}/index.html | 4 +- docs/{man1.0.2/ssl => man1.1.0/man3}/index.html | 16 +- docs/{man1.1.1/man7 => man1.1.0/man5}/index.html | 8 +- docs/{man1.1.1/man1 => man1.1.0/man7}/index.html | 5 +- docs/man1.1.1/man3/index.html | 6 + docs/manmaster/man3/index.html | 6 + 20 files changed, 306 insertions(+), 600 deletions(-) create mode 100755 bin/mk-mancross create mode 100755 bin/mk-manmap delete mode 100755 bin/mk-newmanpages delete mode 100644 docs/man1.0.2/crypto/index.html rename docs/{man1.1.0/apps => man1.0.2/man1}/index.html (91%) rename docs/{man1.1.0/ssl => man1.0.2/man3}/index.html (68%) copy docs/{man1.1.1/man7 => man1.0.2/man5}/index.html (83%) copy docs/{man1.1.1 => man1.0.2}/man7/index.html (83%) delete mode 100644 docs/man1.1.0/crypto/index.html rename docs/{man1.0.2/apps => man1.1.0/man1}/index.html (91%) rename docs/{man1.0.2/ssl => man1.1.0/man3}/index.html (70%) copy docs/{man1.1.1/man7 => man1.1.0/man5}/index.html (83%) copy docs/{man1.1.1/man1 => man1.1.0/man7}/index.html (91%) diff --git a/.gitignore b/.gitignore index 86cadae..51ee8fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *~ *.swp +*.cross blog sitemap.txt docs/*/apps/* diff --git a/Makefile b/Makefile index 2418e5e..d1a8651 100644 --- a/Makefile +++ b/Makefile @@ -41,11 +41,11 @@ SRCLISTS = \ source/old/fips/index.inc \ -all: suball +all: suball manmaster mancross -suball: $(SIMPLE) $(SRCLISTS) manmaster +suball: $(SIMPLE) $(SRCLISTS) -relupd: suball manpages +relupd: suball manpages mancross clean: rm -f $(SIMPLE) $(SRCLISTS) @@ -57,25 +57,27 @@ generated: all rebuild: all define makemanpages - ./bin/mk-manpages $(1) $(2) docs - ./bin/mk-apropos docs/man$(2)/apps > docs/man$(2)/apps/index.inc - ./bin/mk-apropos docs/man$(2)/crypto > docs/man$(2)/crypto/index.inc - ./bin/mk-apropos docs/man$(2)/ssl > docs/man$(2)/ssl/index.inc -endef -define newmakemanpages - ./bin/mk-newmanpages $(1) $(2) docs + ./bin/mk-manpages $(1)/doc $(2) docs/man$(2) ./bin/mk-apropos docs/man$(2)/man1 > docs/man$(2)/man1/index.inc ./bin/mk-apropos docs/man$(2)/man3 > docs/man$(2)/man3/index.inc ./bin/mk-apropos docs/man$(2)/man5 > docs/man$(2)/man5/index.inc ./bin/mk-apropos docs/man$(2)/man7 > docs/man$(2)/man7/index.inc endef +define makemanmap + ./bin/mk-manmap docs/man$(1) > docs/man$(1)/.htaccess +endef manpages: manmaster - $(call newmakemanpages,$(CHECKOUTS)/openssl-1.1.1-stable,1.1.1) + $(call makemanpages,$(CHECKOUTS)/openssl-1.1.1-stable,1.1.1) $(call makemanpages,$(CHECKOUTS)/openssl-1.1.0-stable,1.1.0) + $(call makemanmap,1.1.0) $(call makemanpages,$(CHECKOUTS)/openssl-1.0.2-stable,1.0.2) + $(call makemanmap,1.0.2) manmaster: - $(call newmakemanpages,$(CHECKOUTS)/openssl,master) + $(call makemanpages,$(CHECKOUTS)/openssl,master) + +mancross: + ./bin/mk-mancross ## $(SIMPLE) -- SIMPLE GENERATED FILES .PHONY: sitemap community/committers.inc community/omc.inc community/omc-alumni.inc diff --git a/bin/mk-mancross b/bin/mk-mancross new file mode 100755 index 0000000..e197b06 --- /dev/null +++ b/bin/mk-mancross @@ -0,0 +1,54 @@ +#! /bin/sh + +releases="master 1.1.1 1.1.0 1.0.2" + +log () { + echo >&2 "$@" +} + +debug=: +if [ "$DEBUG" != "" ]; then + debug=log +fi + +for r in $releases; do + echo >&2 -n "$r : " + for s in 1 3 5 7; do + echo >&2 -n $s + for f in docs/man$r/man$s/*.html; do + $debug -n '.' + # Check that it's a rendered manpage + if grep -F '<!-- OSSL: description:' $f > /dev/null; then + existsin='' + b=`basename $f .html` + for x in $releases; do + if [ "$x" = "$r" ]; then + continue + fi + if [ -f "docs/man$x/man$s/$b.html" ]; then + existsin="$existsin $x" + fi + done + ( + if [ "$existsin" != "" ]; then + cat <<EOF + <section> + <h1>This manpage</h1> + <ul> +EOF + for x in $existsin; do + cat <<EOF + <li><a href="/docs/man$x/man$s/$b.html">$x version</a></li> +EOF + done + cat <<EOF + </ul> + </section> +EOF + fi + ) > docs/man$r/man$s/$b.cross + fi + done + done + echo >&2 +done diff --git a/bin/mk-manmap b/bin/mk-manmap new file mode 100755 index 0000000..7bde661 --- /dev/null +++ b/bin/mk-manmap @@ -0,0 +1,27 @@ +#! /bin/sh +# $1 is the top of the manual page tree to look through + +dir=$1 +cd $dir + +for m in `find . -name '*.html'`; do + origsubdir=`grep -F '<!-- OSSL: original subdir:' $m | cut -f3 -d: | sed -e 's| *-->||' -e 's| ||g'` + subdir=`grep -F '<!-- OSSL: subdir:' $m | cut -f3 -d: | sed -e 's| *-->||' -e 's| ||g'` + # If no subdir information is present, this is not a rendered manpage, + # but something else, like index.html + if [ "$origsubdir$subdir" = "" ]; then + continue + fi + manfile=`echo $m | sed -e 's|\./||'` + origmanfile=`echo $manfile | sed -e "s|^$subdir|$origsubdir|"` + case ${origsubdir}:${subdir} in + apps:man1 | crypto:man3 | ssl:man3 ) ;; + * ) echo Redirect permanent /$dir/$origmanfile /$dir/$manfile ;; + esac +done + +cat <<EOF +Redirect permanent /$dir/apps /$dir/man1 +Redirect permanent /$dir/crypto /$dir/man3 +Redirect permanent /$dir/ssl /$dir/man3 +EOF diff --git a/bin/mk-manpages b/bin/mk-manpages index 0096ec2..3b1d32a 100755 --- a/bin/mk-manpages +++ b/bin/mk-manpages @@ -1,21 +1,5 @@ #! /usr/bin/perl -{ - package Local::PSX; - use Pod::Simple::XHTML; - use parent qw(Pod::Simple::XHTML); - - sub resolve_man_page_link { - my ( $self, $to, $section ) = @_; - return undef unless defined $to; - my ( $page, $part ) = $to =~ /^([^(]+)(?:[(](\d+)[)])?$/; - return undef unless $page; - - return ( $self->man_url_prefix || '' ) - . $self->encode_entities($page) . ( $self->man_url_postfix || '' ); - } -} - package Local::MkManPages; use strict; @@ -24,11 +8,14 @@ use File::Basename qw(basename); use File::Spec (); use Getopt::Long qw(GetOptionsFromArray); use Pod::Usage qw(pod2usage); +use Pod::Simple::XHTML; __PACKAGE__->run(@ARGV); -sub Releases { return (qw(master 1.1.0 1.0.2)); } -sub Sections { return (qw(apps crypto ssl)); } +sub Releases { return (qw(master 1.1.1 1.1.0 1.0.2)) } +sub Dirs { return (qw(apps crypto ssl + man1 man3 man5 man7)) } +sub Dir2Section { return ( apps => "man1", crypto => "man3", ssl => "man3" ) } sub getRelease { my ( $class, $ver ) = @_; @@ -46,47 +33,123 @@ sub run { sub main { my ( $class, $srcdir, $wwwdir, $release ) = @_; - foreach my $sect ( $class->Sections ) { - my $dir = File::Spec->catfile( $srcdir, "doc", $sect ); - opendir( my $dh, $dir ) or $class->die("opendir '$dir': $!"); - while ( my $ent = readdir($dh) ) { - next if $ent =~ /^\./; - next if $ent !~ /\.pod$/; - - my $filename = File::Spec->catfile( $dir, $ent ); - my $basename = basename( $ent, ".pod" ); - my $title = $basename; - my %data = $class->getdata( $filename ); - my $out = - $class->genhtml( $release, $sect, $filename, $title, $basename, - $data{description}); - my $outfile = File::Spec->catfile( $wwwdir, "man$release", $sect, - "$basename.html" ); - open( my $fh, ">", $outfile ) - or $class->die("Can't open $outfile: $!"); - print $fh $out or $class->die("Can't print $outfile: $!"); - close($fh) or $class->die("Can't close $outfile: $!"); - - foreach my $alt (grep { $_ ne $basename } @{$data{names}}) { - my $target = File::Spec->catfile( $wwwdir, "man$release", $sect, - "$alt.html" ); - if ( ! -f $target ) { - link( $outfile, $target ) - or $class->die("Can't link $outfile to $target: $!"); - } + foreach my $subdir ( $class->Dirs ) { + my $dir = File::Spec->catfile( $srcdir, $subdir ); + if ( opendir( my $dh, $dir ) ) { + while ( my $ent = readdir($dh) ) { + next if $ent =~ /^\./; + next if $ent !~ /\.pod$/; + + my $origbase = basename( $ent, ".pod" ); + my $title = $origbase; + my $tmp_sect = { $class->Dir2Section }->{$subdir} // $subdir; + (my $tmp_sectnum = $tmp_sect) =~ s|^man||; + # In addition to what getdata() gives us, we add a few + # defaults of our own: + # + # release => "..." # + # subdir => "..." # The original subdir + # sect => "..." # Output section subdir + # sectnum => n # Default section number + # + my %data = ( + subdir => $subdir, + sect => $tmp_sect, + sectnum => $tmp_sectnum, + $class->getdata( File::Spec->catfile ( $dir, $ent ) ) + ); + # These are for display + my $podfile = File::Spec->catfile( $subdir, $ent ); + my $incfile = File::Spec->catfile( $data{sect}, + "$origbase.inc" ); + # These are files we're actually manipulating + my $inpod = File::Spec->catfile( $srcdir, $podfile ); + my $outinc = File::Spec->catfile( $wwwdir, $incfile ); + + # Get main HTML output + my $out = $class->geninc( $release, $inpod, %data ); + open( my $fh, ">", $outinc ) + or $class->die("Can't open $outinc: $!"); + print $fh $out or $class->die("Can't print $outinc: $!"); + close($fh) or $class->die("Can't close $outinc: $!"); + + foreach my $htmlname (@{$data{names}}) { + my $htmlfile = File::Spec->catdir( $data{sect}, + "$htmlname.html" ); + my $outhtml = File::Spec->catfile( $wwwdir, $htmlfile ); + $out = $class->genhtml( $release, $title, $origbase, + $htmlname, %data ); + open( $fh, ">", $outhtml ) + or $class->die("Can't open $outhtml: $!"); + print $fh $out or $class->die("Can't print $outhtml: $!"); + close($fh) or $class->die("Can't close $outhtml: $!"); + } } } } } -# Generate a manpage +# Generate manpag HTML wrapper sub genhtml { - my ( $class, $release, $section, $filename, $title, $file, $desc ) = @_; - my $header = $class->htmlHeader( $title, $desc ); - my $footer = $class->htmlFooter( $release, $section, $file ); + my ( $class, $release, $title, $origbase, $htmlbase, %data ) = @_; + return <<EOH; +<!DOCTYPE html> +<html lang="en"> +<!-- OSSL: original subdir: $data{subdir} --> +<!-- OSSL: subdir: $data{sect} --> +<!-- OSSL: section: $data{sectnum} --> +<!-- OSSL: description: $data{description} --> +<!--#include virtual="/inc/head.shtml" --> +<body> +<!--#include virtual="/inc/banner.shtml" --> + <div id="main"> + <div id="content"> + <div class="blog-index"> + <article> + <header><h2>$title</h2></header> + <div class="entry-content"> + <p> +<!--#include virtual="$origbase.inc" --> + </p> + </div> + <footer> + You are here: <a href="/">Home</a> + : <a href="/docs">Docs</a> + : <a href="/docs/manpages.html">Manpages</a> + : <a href="/docs/man$release/">$release</a> + : <a href="/docs/man$release/$data{sect}">$data{sect}</a> + : <a href="/docs/man$release/$data{sect}/$htmlbase.html">$htmlbase</a> + <br/><a href="/sitemap.txt">Sitemap</a> + </footer> + </article> + </div> + <aside class="sidebar"> + <section> + <h1><a href="/docs/man$release/">$release manpages</a></h1> + <ul> + <li><a href="../man1">Commands</a></li> + <li><a href="../man3">Libraries</a></li> + <li><a href="../man5">File Formats</a></li> + <li><a href="../man7">Overviews</a></li> + </ul> + </section> +<!--#include virtual="$htmlbase.cross" --> + </aside> + </div> + </div> +<!--#include virtual="/inc/footer.shtml" --> +</body> +</html> +EOH +} + +# Generate manpage content +sub geninc { + my ( $class, $release, $filename, %data ) = @_; - open( my $fh, $filename ) || $class->die("Can't open $filename: $!"); + open( my $fh, $filename ) or $class->die("Can't open $filename: $!"); my $infile = do { local $/; <$fh>; }; + close( $fh ); # L<asdf...|qwer...> ==> L<qwer> $infile =~ s/L<[^|>]*\|([^>]+)>/L<$1>/g; @@ -95,14 +158,14 @@ sub genhtml { $infile =~ s/L<([^>]+)\(\d\)>/L<$1>/g; my $out; - my $pod = Local::PSX->new; + my $pod = Pod::Simple::XHTML->new; $pod->html_h_level(3); - $pod->perldoc_url_prefix("/docs/man$release/$section/"); + $pod->perldoc_url_prefix("/docs/man$release/$data{sect}/"); $pod->perldoc_url_postfix(".html"); - $pod->man_url_prefix("/docs/man$release/$section/"); + $pod->man_url_prefix("/docs/man$release/$data{sect}/"); $pod->man_url_postfix(".html"); - $pod->html_header($header); - $pod->html_footer($footer); + $pod->html_header(''); + $pod->html_footer(''); $pod->output_string( \$out ); $pod->parse_string_document($infile); return $out; @@ -112,6 +175,7 @@ sub genhtml { # { # names => [ ... ] # list of all OTHER names # description => "text" # the short description from NAME +# section => n # the section number # } sub getdata { my ( $class, $infile ) = @_; @@ -123,7 +187,11 @@ sub getdata { while (<$fh>) { chop; s/\n/ /gm; - if (/^=head1 /) { + if (/^=for comment openssl_manual_section:\s*(\d+)/) { + $data{sectnum} = "$1"; + $data{sect} = "man$1"; + } + elsif (/^=head1\s/) { $foundname = 0; } elsif ($foundname) { @@ -162,28 +230,36 @@ sub error { # the index and the section subdirs. sub cleanup { my ( $class, $wwwdir, $release ) = @_; - my $dir = File::Spec->catfile( $wwwdir, "man$release" ); - my $idx = File::Spec->catfile( $dir, "index.html" ); + my $idx = File::Spec->catfile( $wwwdir, "index.html" ); - if ( !-d $dir ) { - mkdir($dir) or $class->die("mkdir '$dir': $!"); + if ( !-d $wwwdir ) { + mkdir($wwwdir) or $class->die("mkdir '$wwwdir': $!"); } # TBD: was $class->die $class->error("No $idx") unless ( -f $idx ); - foreach my $sect ( $class->Sections ) { - my $sdir = File::Spec->catfile( $dir, $sect ); - if ( !-d $sdir ) { - mkdir($sdir) or $class->die("mkdir '$sdir': $!"); + foreach my $subdir ( $class->Dirs ) { + my $realsubdir = { $class->Dir2Section }->{$subdir} // $subdir; + my $realsdir = File::Spec->catfile( $wwwdir, $realsubdir ); + if ( !-d $realsdir ) { + mkdir($realsdir) or $class->die("mkdir '$realsdir': $!"); next; } - opendir( my $dh, $sdir ) or $class->die("opendir '$sdir': $!"); - while ( my $ent = readdir($dh) ) { - next if $ent =~ /^\./; - next if $ent =~ /^index.(?:html|inc)$/; - my $f = File::Spec->catfile( $sdir, $ent ); - unlink($f) or $class->error("Can't unlink '$f': $!"); + my $sdir = File::Spec->catfile( $wwwdir, $subdir ); + if ( -d $sdir ) { + opendir( my $dh, $sdir ) or $class->die("opendir '$sdir': $!"); + while ( my $ent = readdir($dh) ) { + next if $ent =~ /^\./; + next if $realsdir eq $sdir && $ent =~ /^index.(?:html|inc)$/; + my $f = File::Spec->catfile( $sdir, $ent ); + unlink($f) or $class->error("Can't unlink '$f': $!"); + } + closedir( $dh ); + + if ( $realsubdir ne $subdir ) { + rmdir $sdir; + } } } } @@ -213,10 +289,14 @@ sub process_options { $class->die(@err) if @err; # each source dir has a set of subdirs with documentation - foreach my $sect ( $class->Sections ) { - my $dir = File::Spec->catfile( $opt{SrcDir}, "doc", $sect ); - push( @err, "No directory '$dir'" ) unless ( -d $dir ); + my @found_dirs = (); + my $docdir = File::Spec->catfile( $opt{SrcDir} ); + foreach my $subdir ( $class->Dirs ) { + my $dir = File::Spec->catfile( $docdir, $subdir ); + push @found_dirs, $dir if -d $dir; } + push( @err, "No documentation directories in $docdir" ) + unless ( @found_dirs ); # verify release push( @err, "Unknown release '$opt{RelVer}'" ) @@ -226,76 +306,6 @@ sub process_options { return \%opt; } -sub htmlHeader { - my ( $class, $title, $desc ) = @_; - return <<EOFH; -<!DOCTYPE html> -<html lang="en"> -<!-- OSSL: description: $desc --> -<!--#include virtual="/inc/head.shtml" --> -<body> - <!--#include virtual="/inc/banner.shtml" --> - <div id="main"> - <div id="content"> - <div class="blog-index"> - <article> - <header><h2>$title</h2></header> - <div class="entry-content"> - <p> - -EOFH -} - -# note: links could be bogus if file DNE in one of the other releases -sub htmlSidebar { - my ( $class, $release, $section, $file ) = @_; - - my $lirel = ""; - foreach my $v ( grep { $release ne $_ } $class->Releases ) { - $lirel .= -"\n<li><a href=\"/docs/man$v/$section/$file.html\">$v version</a></li>"; - } - - return <<EOS; -<aside class="sidebar"> - <section> - <h1><a href="/docs/manpages.html">$release manpages</a></h1> - <ul> - <li><a href="../apps/openssl.html">The openssl command</a></li> - <li><a href="../ssl/ssl.html">The ssl library</a></li> - <li><a href="../crypto/crypto.html">The crypto library</a></li>$lirel - </ul> - </section> -</aside> -EOS -} - -sub htmlFooter { - my ( $class, $release, $section, $file ) = @_; - my $sidebar = $class->htmlSidebar( $release, $section, $file ); - return <<EOFT; - </p> - </div> - <footer> - You are here: <a href="/">Home</a> - : <a href="/docs">Docs</a> - : <a href="/docs/manpages.html">Manpages</a> - : <a href="/docs/man$release">$release</a> - : <a href="/docs/man$release/$section">$section</a> - : <a href="/docs/man$release/$section/$file.html">$file</a> - <br/><a href="/sitemap.txt">Sitemap</a> - </footer> - </article> - </div> - $sidebar - </div> - </div> - <!--#include virtual="/inc/footer.shtml" --> -</body> -</html> -EOFT -} - __END__ =pod @@ -308,7 +318,7 @@ mk-manpages - htmlize man pages from POD for the OpenSSL website mk-manpages [options] <SrcDir> <RelVer> <WwwDir> - <SrcDir> top level directory of release <RelVer>, example 'OpenSSL_1_0_2-stable' + <SrcDir> doc directory of release <RelVer>, example 'OpenSSL_1_0_2-stable/doc' <RelVer> version number associated with <SrcDir>, example '1.0.2' <WwwDir> top level directory beneath which generated html is stored, example 'web' diff --git a/bin/mk-newmanpages b/bin/mk-newmanpages deleted file mode 100755 index f8a3ffd..0000000 --- a/bin/mk-newmanpages +++ /dev/null @@ -1,315 +0,0 @@ -#! /usr/bin/perl - -package Local::MkManPages; - -use strict; -use warnings; -use File::Basename qw(basename); -use File::Spec (); -use Getopt::Long qw(GetOptionsFromArray); -use Pod::Usage qw(pod2usage); -use Pod::Simple::XHTML; - -__PACKAGE__->run(@ARGV); - -sub Releases { return (qw(1.1.1 master)); } -sub Sections { return (qw(man1 man3 man5 man7)); } - -sub getRelease { - my ( $class, $ver ) = @_; - my %known = map { $_ => 1 } $class->Releases; - return @_ != 2 ? %known : defined $known{$ver} ? $ver : undef; -} - -sub run { - my ( $class, @argv ) = @_; - my $opt = $class->process_options(@argv); - $class->cleanup( $opt->{WwwDir}, $opt->{RelVer} ); - exit $class->main( $opt->{SrcDir}, $opt->{WwwDir}, $opt->{RelVer} ); -} - -sub main { - my ( $class, $srcdir, $wwwdir, $release ) = @_; - - foreach my $sect ( $class->Sections ) { - my $dir = File::Spec->catfile( $srcdir, "doc", $sect ); - opendir( my $dh, $dir ) or $class->die("opendir '$dir': $!"); - while ( my $ent = readdir($dh) ) { - next if $ent =~ /^\./; - next if $ent !~ /\.pod$/; - - my $filename = File::Spec->catfile( $dir, $ent ); - my $basename = basename( $ent, ".pod" ); - my $title = $basename; - my %data = $class->getdata( $filename ); - my $out = - $class->genhtml( $release, $sect, $filename, $title, $basename, - $data{description}); - my $outfile = File::Spec->catfile( $wwwdir, "man$release", $sect, - "$basename.html" ); - open( my $fh, ">", $outfile ) - or $class->die("Can't open $outfile: $!"); - print $fh $out or $class->die("Can't print $outfile: $!"); - close($fh) or $class->die("Can't close $outfile: $!"); - - foreach my $alt (grep { $_ ne $basename } @{$data{names}}) { - my $target = File::Spec->catfile( $wwwdir, "man$release", $sect, - "$alt.html" ); - if ( ! -f $target ) { - link( $outfile, $target ) - or $class->die("Can't link $outfile to $target: $!"); - } - } - } - } -} - -# Generate a manpage -sub genhtml { - my ( $class, $release, $section, $filename, $title, $file, $desc ) = @_; - my $header = $class->htmlHeader( $title, $desc ); - my $footer = $class->htmlFooter( $release, $section, $file ); - - open( my $fh, $filename ) || $class->die("Can't open $filename: $!"); - my $infile = do { local $/; <$fh>; }; - - my $out; - my $pod = Pod::Simple::XHTML->new; - $pod->html_h_level(3); - $pod->perldoc_url_prefix("/docs/man$release/man"); - $pod->perldoc_url_postfix(".html"); - $pod->man_url_prefix("/docs/man$release/man"); - $pod->man_url_postfix(".html"); - $pod->html_header($header); - $pod->html_footer($footer); - $pod->output_string( \$out ); - $pod->parse_string_document($infile); - return $out; -} - -# Return diverse data from a manpage if available, currently: -# { -# names => [ ... ] # list of all OTHER names -# description => "text" # the short description from NAME -# } -sub getdata { - my ( $class, $infile ) = @_; - my %data = (); - open( my $fh, "<", $infile ) or $class->die("Can't open $infile: $!"); - { - local $/ = ""; - my $foundname = 0; - while (<$fh>) { - chop; - s/\n/ /gm; - if (/^=head1 /) { - $foundname = 0; - } - elsif ($foundname) { - if (/ - /) { - $data{description} = $'; - $_ = $`; - s/,\s+/,/g; - s/\s+,/,/g; - s/^\s+//g; - s/\s+$//g; - s/\s/_/g; - push @{$data{names}}, split ','; - } - } - if (/^=head1\s+NAME\s*$/) { - $foundname = 1; - } - } - } - return %data; -} - -sub die { - my $class = shift; - $class->error(@_); - exit(2); -} - -sub error { - my $class = shift; - my $prog = basename($0); - warn("$prog: $_\n") for @_; -} - -# Remove all files from a manpage subtree, and leave only -# the index and the section subdirs. -sub cleanup { - my ( $class, $wwwdir, $release ) = @_; - my $dir = File::Spec->catfile( $wwwdir, "man$release" ); - my $idx = File::Spec->catfile( $dir, "index.html" ); - - if ( !-d $dir ) { - mkdir($dir) or $class->die("mkdir '$dir': $!"); - } - - # TBD: was $class->die - $class->error("No $idx") unless ( -f $idx ); - foreach my $sect ( $class->Sections ) { - my $sdir = File::Spec->catfile( $dir, $sect ); - if ( !-d $sdir ) { - mkdir($sdir) or $class->die("mkdir '$sdir': $!"); - next; - } - - opendir( my $dh, $sdir ) or $class->die("opendir '$sdir': $!"); - while ( my $ent = readdir($dh) ) { - next if $ent =~ /^\./; - next if $ent =~ /^index.(?:html|inc)$/; - my $f = File::Spec->catfile( $sdir, $ent ); - unlink($f) or $class->error("Can't unlink '$f': $!"); - } - } -} - -sub process_options { - my ( $class, @argv ) = @_; - my %opt; - - GetOptionsFromArray( \@argv, \%opt, "help", "man" ) - or pod2usage( -verbose => 0 ); - - pod2usage( -verbose => 1 ) if ( $opt{help} or @argv != 3 ); - pod2usage( -verbose => 2 ) if ( $opt{man} ); - - # <src/dir> <rel.ver> <www/dir> - my @argkeys = qw(SrcDir RelVer WwwDir); - @opt{@argkeys} = @argv; - - # no empty values, directories must exist - my @err; - foreach my $key (@argkeys) { - push( @err, "Invalid $key argument '$opt{$key}'" ) - if ( $opt{$key} =~ /^\s*$/ ); - push( @err, "Directory '$opt{$key}': $!" ) - if ( $key =~ /Dir$/ and !-d $opt{$key} ); - } - $class->die(@err) if @err; - - # each source dir has a set of subdirs with documentation - foreach my $sect ( $class->Sections ) { - my $dir = File::Spec->catfile( $opt{SrcDir}, "doc", $sect ); - push( @err, "No directory '$dir'" ) unless ( -d $dir ); - } - - # verify release - push( @err, "Unknown release '$opt{RelVer}'" ) - unless ( $class->getRelease( $opt{RelVer} ) ); - $class->die(@err) if @err; - - return \%opt; -} - -sub htmlHeader { - my ( $class, $title, $desc ) = @_; - return <<EOFH; -<!DOCTYPE html> -<html lang="en"> -<!-- OSSL: description: $desc --> -<!--#include virtual="/inc/head.shtml" --> -<body> - <!--#include virtual="/inc/banner.shtml" --> - <div id="main"> - <div id="content"> - <div class="blog-index"> - <article> - <header><h2>$title</h2></header> - <div class="entry-content"> - <p> - -EOFH -} - -# note: links could be bogus if file DNE in one of the other releases -sub htmlSidebar { - my ( $class, $release, $section, $file ) = @_; - - my $lirel = ""; - foreach my $v ( grep { $release ne $_ } $class->Releases ) { - $lirel .= -"\n<li><a href=\"/docs/man$v/$section/$file.html\">$v version</a></li>"; - } - - return <<EOS; -<aside class="sidebar"> - <section> - <h1><a href="/docs/manpages.html">$release manpages</a></h1> - <ul> - <li><a href="../man1">Commands</a></li> - <li><a href="../man3">Libraries</a></li> - <li><a href="../man5">File Formats</a></li> - <li><a href="../man7">Overviews</a></li> - </ul> - </section> -</aside> -EOS -} - -sub htmlFooter { - my ( $class, $release, $section, $file ) = @_; - my $sidebar = $class->htmlSidebar( $release, $section, $file ); - return <<EOFT; - </p> - </div> - <footer> - You are here: <a href="/">Home</a> - : <a href="/docs">Docs</a> - : <a href="/docs/manpages.html">Manpages</a> - : <a href="/docs/man$release">$release</a> - : <a href="/docs/man$release/$section">$section</a> - : <a href="/docs/man$release/$section/$file.html">$file</a> - <br/><a href="/sitemap.txt">Sitemap</a> - </footer> - </article> - </div> - $sidebar - </div> - </div> - <!--#include virtual="/inc/footer.shtml" --> -</body> -</html> -EOFT -} - -__END__ - -=pod - -=head1 NAME - -mk-manpages - htmlize man pages from POD for the OpenSSL website - -=head1 SYNOPSIS - -mk-manpages [options] <SrcDir> <RelVer> <WwwDir> - - <SrcDir> top level directory of release <RelVer>, example 'OpenSSL_1_0_2-stable' - <RelVer> version number associated with <SrcDir>, example '1.0.2' - <WwwDir> top level directory beneath which generated html is stored, example 'web' - - --help display a brief help message - --man display full documentation - -=head1 DESCRIPTION - -This utility is run on a web server generate the htmlized version of -OpenSSL documentation from the original POD. The resultant directory -structure may look something like the following (where the contents of -index.html do not come from this tool): - - $ ls some/path/to/web - man1.0.2 man1.1.0 manmaster - $ ls some/path/to/web/man1.0.2 - apps crypto index.html ssl - $ ls some/path/to/web/man1.0.2/apps - CA.pl.html - asn1parse.html - c_rehash.html - ... - -=cut diff --git a/docs/man1.0.2/crypto/index.html b/docs/man1.0.2/crypto/index.html deleted file mode 100644 index 0791e21..0000000 --- a/docs/man1.0.2/crypto/index.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<!--#include virtual="/inc/head.shtml" --> -<body> - <!--#include virtual="/inc/banner.shtml" --> - <div id="main"> - <div id="content"> - <div class="blog-index"> - <article> - <header><h2>crypto library</h2></header> - <div class="entry-content"> - <p> - The <a href="crypto.html">crypto</a> manpage provides a - general overview of the crypto library. - The detailed list is here: - </p> - - <table style="border-spacing: 10px 0;"> - <tr> - <td>NAME</td> - <td>Description</td> - </tr> - <!--#include virtual="index.inc" --> - </table> - <p> </p> - - </div> - <footer> - You are here: <a href="/">Home</a> - : <a href="/docs">Documentation</a> - : <a href="/docs/manpages.html">Manpages</a> - : <a href="/docs/man1.0.2">master</a> - : <a href="/docs/man1.0.2/crypto">crypto</a> - <br/><a href="/sitemap.txt">Sitemap</a> - </footer> - </article> - </div> - <!--#include virtual="/inc/mansidebar.shtml" --> - </div> - </div> -<!--#include virtual="/inc/footer.shtml" --> -</body> -</html> diff --git a/docs/man1.0.2/index.html b/docs/man1.0.2/index.html index c789469..c937ef0 100644 --- a/docs/man1.0.2/index.html +++ b/docs/man1.0.2/index.html @@ -16,9 +16,10 @@ parts: </p> <ul> - <li><a href="apps">The commands</a></li> - <li><a href="ssl">The ssl library</a></li> - <li><a href="crypto">The crypto library</a></li> + <li><a href="man1">Commands</a></li> + <li><a href="man3">Libraries</a></li> + <li><a href="man5">File Formats</a></li> + <li><a href="man7">Overviews</a></li> </ul> </div> <footer> diff --git a/docs/man1.1.0/apps/index.html b/docs/man1.0.2/man1/index.html similarity index 91% rename from docs/man1.1.0/apps/index.html rename to docs/man1.0.2/man1/index.html index 6e7076b..485bdc3 100644 --- a/docs/man1.1.0/apps/index.html +++ b/docs/man1.0.2/man1/index.html @@ -29,8 +29,8 @@ You are here: <a href="/">Home</a> : <a href="/docs">Documentation</a> : <a href="/docs/manpages.html">Manpages</a> - : <a href="/docs/man1.1.0">master</a> - : <a href="/docs/man1.1.0/apps">commands</a> + : <a href="/docs/man1.0.2">1.0.2</a> + : <a href="/docs/man1.0.2/man1">commands</a> <br/><a href="/sitemap.txt">Sitemap</a> </footer> </article> @@ -41,4 +41,3 @@ <!--#include virtual="/inc/footer.shtml" --> </body> </html> - diff --git a/docs/man1.1.0/ssl/index.html b/docs/man1.0.2/man3/index.html similarity index 68% rename from docs/man1.1.0/ssl/index.html rename to docs/man1.0.2/man3/index.html index 031132b..d5690f6 100644 --- a/docs/man1.1.0/ssl/index.html +++ b/docs/man1.0.2/man3/index.html @@ -7,12 +7,16 @@ <div id="content"> <div class="blog-index"> <article> - <header><h2>ssl library</h2></header> + <header><h2>libraries</h2></header> <div class="entry-content"> <p> - The <a href="ssl.html">ssl</a> manpage provides a - general overview of the ssl library. - The detailed list is here: + This is the OpenSSL API for the SSL and Crypto libraries. + The <a href="ssl.html">ssl</a> and <a href="crypto.html">crypto</a> + manpages are general overviews of those libraries. + </p> + + <p> + The detailed list is here: </p> <table style="border-spacing: 10px 0;"> @@ -29,8 +33,8 @@ You are here: <a href="/">Home</a> : <a href="/docs">Documentation</a> : <a href="/docs/manpages.html">Manpages</a> - : <a href="/docs/man1.1.0">master</a> - : <a href="/docs/man1.1.0/ssl">ssl</a> + : <a href="/docs/man1.0.2">1.0.2</a> + : <a href="/docs/man1.0.2/man3">libraries</a> <br/><a href="/sitemap.txt">Sitemap</a> </footer> </article> @@ -41,4 +45,3 @@ <!--#include virtual="/inc/footer.shtml" --> </body> </html> - diff --git a/docs/man1.1.1/man7/index.html b/docs/man1.0.2/man5/index.html similarity index 83% copy from docs/man1.1.1/man7/index.html copy to docs/man1.0.2/man5/index.html index 7223213..651592f 100644 --- a/docs/man1.1.1/man7/index.html +++ b/docs/man1.0.2/man5/index.html @@ -7,10 +7,9 @@ <div id="content"> <div class="blog-index"> <article> - <header><h2>crypto library</h2></header> + <header><h2>file formats</h2></header> <div class="entry-content"> <p> - OpenSSL overviews. The detailed list is here: </p> @@ -28,8 +27,8 @@ You are here: <a href="/">Home</a> : <a href="/docs">Documentation</a> : <a href="/docs/manpages.html">Manpages</a> - : <a href="/docs/man1.1.1">1.1.1</a> - : <a href="/docs/man1.1.1/man7">overviews</a> + : <a href="/docs/man1.0.2">1.0.2</a> + : <a href="/docs/man1.0.2/man5">file formats</a> <br/><a href="/sitemap.txt">Sitemap</a> </footer> </article> @@ -40,4 +39,3 @@ <!--#include virtual="/inc/footer.shtml" --> </body> </html> - diff --git a/docs/man1.1.1/man7/index.html b/docs/man1.0.2/man7/index.html similarity index 83% copy from docs/man1.1.1/man7/index.html copy to docs/man1.0.2/man7/index.html index 7223213..0b6ebc4 100644 --- a/docs/man1.1.1/man7/index.html +++ b/docs/man1.0.2/man7/index.html @@ -7,10 +7,9 @@ <div id="content"> <div class="blog-index"> <article> - <header><h2>crypto library</h2></header> + <header><h2>overviews</h2></header> <div class="entry-content"> <p> - OpenSSL overviews. The detailed list is here: </p> @@ -28,8 +27,8 @@ You are here: <a href="/">Home</a> : <a href="/docs">Documentation</a> : <a href="/docs/manpages.html">Manpages</a> - : <a href="/docs/man1.1.1">1.1.1</a> - : <a href="/docs/man1.1.1/man7">overviews</a> + : <a href="/docs/man1.0.2">1.0.2</a> + : <a href="/docs/man1.0.2/man7">overviews</a> <br/><a href="/sitemap.txt">Sitemap</a> </footer> </article> @@ -40,4 +39,3 @@ <!--#include virtual="/inc/footer.shtml" --> </body> </html> - diff --git a/docs/man1.1.0/crypto/index.html b/docs/man1.1.0/crypto/index.html deleted file mode 100644 index 1b3545e..0000000 --- a/docs/man1.1.0/crypto/index.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<!--#include virtual="/inc/head.shtml" --> -<body> - <!--#include virtual="/inc/banner.shtml" --> - <div id="main"> - <div id="content"> - <div class="blog-index"> - <article> - <header><h2>crypto library</h2></header> - <div class="entry-content"> - <p> - The <a href="crypto.html">crypto</a> manpage provides a - general overview of the crypto library. - The detailed list is here: - </p> - - <table style="border-spacing: 10px 0;"> - <tr> - <td>NAME</td> - <td>Description</td> - </tr> - <!--#include virtual="index.inc" --> - </table> - <p> </p> - - </div> - <footer> - You are here: <a href="/">Home</a> - : <a href="/docs">Documentation</a> - : <a href="/docs/manpages.html">Manpages</a> - : <a href="/docs/man1.1.0">master</a> - : <a href="/docs/man1.1.0/crypto">crypto</a> - <br/><a href="/sitemap.txt">Sitemap</a> - </footer> - </article> - </div> - <!--#include virtual="/inc/mansidebar.shtml" --> - </div> - </div> -<!--#include virtual="/inc/footer.shtml" --> -</body> -</html> diff --git a/docs/man1.1.0/index.html b/docs/man1.1.0/index.html index 3d41a80..de57e64 100644 --- a/docs/man1.1.0/index.html +++ b/docs/man1.1.0/index.html @@ -16,9 +16,10 @@ parts: </p> <ul> - <li><a href="apps">The commands</a></li> - <li><a href="ssl">The ssl library</a></li> - <li><a href="crypto">The crypto library</a></li> + <li><a href="man1">Commands</a></li> + <li><a href="man3">Libraries</a></li> + <li><a href="man5">File Formats</a></li> + <li><a href="man7">Overviews</a></li> </ul> </div> <footer> diff --git a/docs/man1.0.2/apps/index.html b/docs/man1.1.0/man1/index.html similarity index 91% rename from docs/man1.0.2/apps/index.html rename to docs/man1.1.0/man1/index.html index 5c5e77e..c8562a0 100644 --- a/docs/man1.0.2/apps/index.html +++ b/docs/man1.1.0/man1/index.html @@ -29,8 +29,8 @@ You are here: <a href="/">Home</a> : <a href="/docs">Documentation</a> : <a href="/docs/manpages.html">Manpages</a> - : <a href="/docs/man1.0.2">master</a> - : <a href="/docs/man1.0.2/apps">commands</a> + : <a href="/docs/man1.1.0">1.1.0</a> + : <a href="/docs/man1.1.0/man1">commands</a> <br/><a href="/sitemap.txt">Sitemap</a> </footer> </article> diff --git a/docs/man1.0.2/ssl/index.html b/docs/man1.1.0/man3/index.html similarity index 70% rename from docs/man1.0.2/ssl/index.html rename to docs/man1.1.0/man3/index.html index 5cd9454..388816a 100644 --- a/docs/man1.0.2/ssl/index.html +++ b/docs/man1.1.0/man3/index.html @@ -7,11 +7,16 @@ <div id="content"> <div class="blog-index"> <article> - <header><h2>ssl library</h2></header> + <header><h2>libraries</h2></header> <div class="entry-content"> <p> - The <a href="ssl.html">ssl</a> manpage provides a - general overview of the ssl library. + This is the OpenSSL API for the SSL and Crypto libraries. + The <a href="../man7/ssl.html">ssl</a> and + <a href="../man7/crypto.html">crypto</a> manpages are + general overviews of those libraries. + </p> + + <p> The detailed list is here: </p> @@ -29,8 +34,8 @@ You are here: <a href="/">Home</a> : <a href="/docs">Documentation</a> : <a href="/docs/manpages.html">Manpages</a> - : <a href="/docs/man1.0.2">master</a> - : <a href="/docs/man1.0.2/ssl">ssl</a> + : <a href="/docs/man1.1.0">1.1.0</a> + : <a href="/docs/man1.1.0/man3">libraries</a> <br/><a href="/sitemap.txt">Sitemap</a> </footer> </article> @@ -41,4 +46,3 @@ <!--#include virtual="/inc/footer.shtml" --> </body> </html> - diff --git a/docs/man1.1.1/man7/index.html b/docs/man1.1.0/man5/index.html similarity index 83% copy from docs/man1.1.1/man7/index.html copy to docs/man1.1.0/man5/index.html index 7223213..8b39715 100644 --- a/docs/man1.1.1/man7/index.html +++ b/docs/man1.1.0/man5/index.html @@ -7,10 +7,9 @@ <div id="content"> <div class="blog-index"> <article> - <header><h2>crypto library</h2></header> + <header><h2>overviews</h2></header> <div class="entry-content"> <p> - OpenSSL overviews. The detailed list is here: </p> @@ -28,8 +27,8 @@ You are here: <a href="/">Home</a> : <a href="/docs">Documentation</a> : <a href="/docs/manpages.html">Manpages</a> - : <a href="/docs/man1.1.1">1.1.1</a> - : <a href="/docs/man1.1.1/man7">overviews</a> + : <a href="/docs/man1.1.0">1.1.0</a> + : <a href="/docs/man1.1.0/man5">file formats</a> <br/><a href="/sitemap.txt">Sitemap</a> </footer> </article> @@ -40,4 +39,3 @@ <!--#include virtual="/inc/footer.shtml" --> </body> </html> - diff --git a/docs/man1.1.1/man1/index.html b/docs/man1.1.0/man7/index.html similarity index 91% copy from docs/man1.1.1/man1/index.html copy to docs/man1.1.0/man7/index.html index b008c2b..d6c8b64 100644 --- a/docs/man1.1.1/man1/index.html +++ b/docs/man1.1.0/man7/index.html @@ -29,8 +29,8 @@ You are here: <a href="/">Home</a> : <a href="/docs">Documentation</a> : <a href="/docs/manpages.html">Manpages</a> - : <a href="/docs/man1.1.1">1.1.1</a> - : <a href="/docs/man1.1.1/man1">commands</a> + : <a href="/docs/man1.1.0">1.1.0</a> + : <a href="/docs/man1.1.0/man7">overviews</a> <br/><a href="/sitemap.txt">Sitemap</a> </footer> </article> @@ -41,4 +41,3 @@ <!--#include virtual="/inc/footer.shtml" --> </body> </html> - diff --git a/docs/man1.1.1/man3/index.html b/docs/man1.1.1/man3/index.html index b7adf3d..afe7dd6 100644 --- a/docs/man1.1.1/man3/index.html +++ b/docs/man1.1.1/man3/index.html @@ -11,6 +11,12 @@ <div class="entry-content"> <p> This is the OpenSSL API for the SSL and Crypto libraries. + The <a href="../man7/ssl.html">ssl</a> and + <a href="../man7/crypto.html">crypto</a> manpages are + general overviews of those libraries. + </p> + + <p> The detailed list is here: </p> diff --git a/docs/manmaster/man3/index.html b/docs/manmaster/man3/index.html index 9de91ae..79ddc60 100644 --- a/docs/manmaster/man3/index.html +++ b/docs/manmaster/man3/index.html @@ -11,6 +11,12 @@ <div class="entry-content"> <p> This is the OpenSSL API for the SSL and Crypto libraries. + The <a href="../man7/ssl.html">ssl</a> and + <a href="../man7/crypto.html">crypto</a> manpages are + general overviews of those libraries. + </p> + + <p> The detailed list is here: </p> _____ openssl-commits mailing list To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-commits