PageRenderTime 20ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 0ms app.codeStats 0ms

/devtools/gendocs.pl

http://github.com/perlbal/Perlbal
Perl | 58 lines | 52 code | 4 blank | 2 comment | 1 complexity | 8b26760253dc0c5ceebbf8ce41b75122 MD5 | raw file
 1#!/usr/bin/env perl
 2#
 3
 4use strict;
 5use FindBin;
 6use lib "$FindBin::Bin/../lib";
 7use Perlbal;
 8
 9my $tunables = Perlbal::Service::autodoc_get_tunables();
10
11my %by_role;
12while (my ($k, $tun) = each %$tunables) {
13    $by_role{$tun->{check_role}}{$k} = $tun;
14}
15
16my $docs = $FindBin::Bin . "/../doc";
17open (H, ">$docs/service-parameters.html") or die "Can't open $docs/service-parameters.html for writing";
18
19print H <<HTML;
20<h1 align='left'>Perlbal Service parameters</h1>Set via commands of either forms:
21<pre>SET &lt;service-name&gt; &lt;param&gt; = &lt;value&gt;
22SET &lt;param&gt; = &lt;value&gt;
23</pre>
24
25<p>Note on types:  'bool' values can be set using one of 1, true, yes, on, 0, false, off, or no.
26'size' values are in integer bytes, or an integer followed by 'b', 'k', or 'm' (case-insensitive)
27for bytes, KiB, or MiB.</p>
28
29<p>Note that you can set defaults for all services you create by using the DEFAULT command:</p>
30
31<pre>DEFAULT &lt;param&gt; = &lt;value&gt;</pre>
32HTML
33
34foreach my $role ("*", "reverse_proxy", "web_server") {
35    if ($role eq "*") {
36        print H "<h2>For all services:</h2>";
37    } else {
38        print H "<h2>Only for '$role' services:</h2>";
39    }
40    print H "<table border='2' cellspacing='1' cellpadding='4'>\n";
41    print H "<tr align='left'><th>Param</th><th>type</th><th>Default</th><th>Description</th></tr>\n";
42
43    foreach my $param (sort keys %{$by_role{$role}}) {
44        my $tun = $by_role{$role}{$param};
45        my $def = $tun->{default};
46        my $type = $tun->{check_type} || "";
47        undef $type unless $type && $type =~ /^bool|int|size$/;
48        if ($type eq "bool") {
49            $def = $def ? "true" : "false";
50        }
51        print H "<tr><td>$param</td><td>$type</td><td>$def</td><td>$tun->{des}</td></tr>\n";
52    }
53    print H "</table>\n";
54}
55
56system("links -dump $docs/service-parameters.html > $docs/service-parameters.txt")
57    and die "Error: links not installed";
58unlink "$docs/service-parameters.html";