FunctionalPerl
view release on metacpan or search on metacpan
htmlgen/gen view on Meta::CPAN
#!/usr/bin/env perl
#
# Copyright (c) 2014-2021 Christian Jaeger, copying@christianjaeger.ch
#
# This is free software, offered under either the same terms as perl 5
# or the terms of the Artistic License version 2 or the terms of the
# MIT License (Expat version). See the file COPYING.md that came
# bundled with this file.
#
use strict;
use warnings;
use warnings FATAL => 'uninitialized';
use experimental "signatures";
# find modules from functional-perl working directory (not installed)
use Cwd 'abs_path';
our ($mydir, $myname);
BEGIN {
my $location = (-l $0) ? abs_path($0) : $0;
$location =~ /(.*?)([^\/]+?)_?\z/s or die "?";
($mydir, $myname) = ($1, $2);
}
use lib "$mydir/../lib";
use lib "$mydir/../meta"; # for FunctionalPerl::Indexing
# and the htmlgen/ directory
use lib $mydir;
use Getopt::Long;
use FP::Docstring;
use Chj::Backtrace;
use Hash::Util 'lock_hash';
use Chj::xperlfunc qw(basename dirname);
use Chj::xIOUtil qw(xgetfile_utf8 xcopyfile);
use FP::HashSet ":all";
use PXML::XHTML ":all";
use PXML::Serialize 'puthtmlfile';
use FP::Array ":all";
use File::Spec;
use FP::Array_sort;
use FP::Ops qw(string_cmp real_cmp the_method cut_method);
use FP::Equal qw(equal);
use FP::autobox;
use Chj::TEST ":all";
use FP::List qw(is_pair list);
use PXML::Util qw(pxml_map_elements_exhaustively);
use FP::Hash ":all";
use PXML::Tags qw(with_toc);
use FP::Predicates qw(complement);
use FP::Git::Repository;
use FunctionalPerl::Htmlgen::PathTranslate;
use FunctionalPerl::Htmlgen::PathUtil qw(path_add path_diff path0);
use FunctionalPerl::Htmlgen::Cost;
use FunctionalPerl::Htmlgen::default_config qw($default_config);
use FunctionalPerl::Htmlgen::FileUtil qw(existingpath_or create_parent_dirs);
use FunctionalPerl::Htmlgen::MarkdownPlus qw(markdownplus_parse);
use FP::Lazy;
use FunctionalPerl::Htmlgen::Mediawiki qw(mediawiki_prepare mediawiki_replace
mediawiki_rexpand);
use PXML::Preserialize qw(pxmlpre);
use FP::PureHash;
use FP::Equal qw(pointer_eq);
use FP::Carp;
our $css_path = "htmlgen.css";
sub usage {
print "$myname config inbase outbase
config is the path to a Perl file ending in a hash with config
values, see functional-perl/website/gen-config.pl for an example.
inbase needs to be a git working directory.
Assumes that there is a file '$css_path', which is included in the
<head/> and copied to outbase.
Options:
--repl open a repl instead of running the main action
--trap trap uncached exception in a repl (implied by --repl)
";
exit 1;
}
our $verbose = 0;
our ($opt_repl, $opt_trap);
GetOptions(
"verbose" => \$verbose,
"help" => sub {usage},
"repl" => \$opt_repl,
"trap" => \$opt_trap,
) or exit 1;
usage unless @ARGV == 3 or ($opt_repl and @ARGV >= 1);
our ($configpath, $inbase, $outbase) = @ARGV;
( run in 1.113 second using v1.01-cache-2.11-cpan-bbe5e583499 )