Skip to content

Commit cb7eab7

Browse files
committed
Changes needed to accomodate changes to the PG POD and sample problem generation.
First, there are some minor tweaks to the POD and sample problem viewers: * Fix the wording on the sample problem viewer index page for "Sample Problems by Macro". It current says, "For many macros, this lists all sample problems used by the macro." However, macros do not use sample problems. Sample problems use macros. So the wording is now, "For many macros, this lists all sample problems that use the macro." * Update the version of bootstrap in the POD templates to 5.3.7 which is currently the latest. * Update the links in the pod templates to wiki.openwebwork.org. * Remove the `favicon` links. Those are not explicitly needed. Browser's now load the favicon even if the page does not contain the link. The link only needs to be added if the file is not named favicon.ico. The following are the actual changes needed to accomodate changes to the PG POD and sample problem generation: * Remove files that are now used from the PG repository. * Remove the PODViewer js and css files, the PODParser.pm and PODtoHTML.pm modules, and category-index.mt and pod.mt templates, all of which are now provided by PG. * Make the necessary changes to the generate-ww-pg-pod.pl script so that it can use those files from the PG repository. * Update the SampleProblemParser module usage for its changes and namespace change. * The `WeBWorK::PG::SampleProblemParser` module now handles generation of the actual search data with its `getSearchData` method. So the `WeBWorK::ContentGenerator::SampleProblemViewer` just calls that method. * The `assets/stop-words-en.txt` file is now in the PG repository so that the `WeBWorK::PG::SampleProblemParser::getSearchData` method can get at it easily. * The `htdocs/js/SampleProblemViewer/documentation-search.js` file is now in the PG repository, and webwork2 uses it from there. PG also copies it to the PG docs github pages site in its new workflow. The options are passed in via the script in `templates/ContentGenerator/SampleProblemViewer.html.ep`.
1 parent c5a2717 commit cb7eab7

File tree

13 files changed

+64
-2124
lines changed

13 files changed

+64
-2124
lines changed

assets/stop-words-en.txt

Lines changed: 0 additions & 1320 deletions
This file was deleted.

bin/dev_scripts/PODtoHTML.pm

Lines changed: 0 additions & 201 deletions
This file was deleted.

bin/dev_scripts/generate-ww-pg-pod.pl

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ =head1 SYNOPSIS
99
generate-ww-pg-pod.pl [options]
1010
1111
Options:
12-
-p|--pg-root Directory containing a git clone of pg.
13-
If this option is not set, then the environment
14-
variable $PG_ROOT will be used if it is set.
1512
-o|--output-dir Directory to save the output files to. (required)
1613
-b|--base-url Base url location used on server. (default: /)
1714
This is needed for internal POD links to work correctly.
1815
-v|--verbose Increase the verbosity of the output.
1916
(Use multiple times for more verbosity.)
2017
21-
Note that --pg-root must be provided or the PG_ROOT environment variable set
22-
if the POD for pg is desired.
18+
Note that C<pg_dir> must be set in the C<conf/webwork2.mojolicious.yml> file, or
19+
if that file does not exist then the clone of the PG repository must be located
20+
at C</opt/webwork/pg> as defined in the C<conf/webwork2.mojolicious.dist.yml>
21+
file.
2322
2423
=head1 DESCRIPTION
2524
@@ -30,37 +29,47 @@ =head1 DESCRIPTION
3029
use strict;
3130
use warnings;
3231

32+
my ($webwork_root, $pg_root);
33+
34+
BEGIN {
35+
use File::Basename qw(dirname);
36+
use Cwd qw(abs_path);
37+
use YAML::XS qw(LoadFile);
38+
39+
$webwork_root = abs_path(dirname(dirname(dirname(__FILE__))));
40+
41+
# Load the configuration file to obtain the PG root directory.
42+
my $config_file = "$webwork_root/conf/webwork2.mojolicious.yml";
43+
$config_file = "$webwork_root/conf/webwork2.mojolicious.dist.yml" unless -e $config_file;
44+
my $config = LoadFile($config_file);
45+
46+
$pg_root = $config->{pg_dir};
47+
}
48+
3349
use Getopt::Long qw(:config bundling);
3450
use Pod::Usage;
3551

36-
my ($pg_root, $output_dir, $base_url);
52+
my ($output_dir, $base_url);
3753
my $verbose = 0;
3854
GetOptions(
39-
'p|pg-root=s' => \$pg_root,
4055
'o|output-dir=s' => \$output_dir,
4156
'b|base-url=s' => \$base_url,
4257
'v|verbose+' => \$verbose
4358
);
4459

45-
$pg_root = $ENV{PG_ROOT} if !$pg_root;
46-
47-
pod2usage(2) unless $output_dir;
60+
pod2usage(2) unless $output_dir && $pg_root && -d $pg_root;
4861

4962
$base_url = "/" if !$base_url;
5063

5164
use Mojo::Template;
5265
use IO::File;
5366
use File::Copy;
54-
use File::Path qw(make_path remove_tree);
55-
use File::Basename qw(dirname);
56-
use Cwd qw(abs_path);
57-
58-
use lib dirname(dirname(dirname(__FILE__))) . '/lib';
59-
use lib dirname(__FILE__);
67+
use File::Path qw(make_path remove_tree);
6068

61-
use PODtoHTML;
69+
use lib "$webwork_root/lib";
70+
use lib "$pg_root/lib";
6271

63-
my $webwork_root = abs_path(dirname(dirname(dirname(__FILE__))));
72+
use WeBWorK::Utils::PODtoHTML;
6473

6574
for my $dir ($webwork_root, $pg_root) {
6675
next unless $dir && -d $dir;
@@ -73,10 +82,10 @@ =head1 DESCRIPTION
7382
write_index($index_fh);
7483

7584
make_path("$output_dir/assets");
76-
copy("$webwork_root/htdocs/js/PODViewer/podviewer.css", "$output_dir/assets/podviewer.css");
77-
print "copying $webwork_root/htdocs/js/PODViewer/podviewer.css to $output_dir/assets/podviewer.css\n" if $verbose;
78-
copy("$webwork_root/htdocs/js/PODViewer/podviewer.js", "$output_dir/assets/podviewer.js");
79-
print "copying $webwork_root/htdocs/js/PODViewer/podviewer.css to $output_dir/assets/podviewer.js\n" if $verbose;
85+
copy("$pg_root/htdocs/js/PODViewer/podviewer.css", "$output_dir/assets/podviewer.css");
86+
print "copying $pg_root/htdocs/js/PODViewer/podviewer.css to $output_dir/assets/podviewer.css\n" if $verbose;
87+
copy("$pg_root/htdocs/js/PODViewer/podviewer.js", "$output_dir/assets/podviewer.js");
88+
print "copying $pg_root/htdocs/js/PODViewer/podviewer.css to $output_dir/assets/podviewer.js\n" if $verbose;
8089

8190
sub process_dir {
8291
my $source_dir = shift;
@@ -89,12 +98,15 @@ sub process_dir {
8998
remove_tree($dest_dir);
9099
make_path($dest_dir);
91100

92-
my $htmldocs = PODtoHTML->new(
93-
source_root => $source_dir,
94-
dest_root => $dest_dir,
95-
template_dir => "$webwork_root/bin/dev_scripts/pod-templates",
96-
dest_url => $base_url,
97-
verbose => $verbose
101+
my $htmldocs = WeBWorK::Utils::PODtoHTML->new(
102+
source_root => $source_dir,
103+
dest_root => $dest_dir,
104+
template_dir => "$pg_root/assets/pod-templates",
105+
dest_url => $base_url,
106+
home_url => $base_url,
107+
home_url_link_name => 'WeBWorK POD Home',
108+
page_url => $base_url . ($source_dir =~ s|^.*/||r),
109+
verbose => $verbose
98110
);
99111
$htmldocs->convert_pods;
100112

0 commit comments

Comments
 (0)