]>
git.proxmox.com Git - pve-common.git/blob - data/PVE/PodParser.pm
1 package PVE
::PodParser
;
5 use base
qw(Pod::Parser);
8 pve_copyright
=> <<EODATA,
9 \=head1 COPYRIGHT AND DISCLAIMER
11 Copyright (C) 2007-2011 Proxmox Server Solutions GmbH
13 This program is free software: you can redistribute it and\/or modify
14 it under the terms of the GNU Affero General Public License as
15 published by the Free Software Foundation, either version 3 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU Affero General Public License for more details.
23 You should have received a copy of the GNU Affero General Public License
24 along with this program. If not, see L<http://www.gnu.org/licenses/>.
29 my ($self, $cmd, $text, $line_num, $pod_para) = @_;
31 if (($cmd eq 'include' && $text =~ m/^\s*(\S+)\s/)) {
33 my $data = $stdinclude->{$incl} ?
$stdinclude->{$incl} :
34 $self->{include
}->{$incl};
36 $self->textblock("$data\n\n", $line_num, $pod_para);
38 $self->textblock($pod_para->raw_text(), $line_num, $pod_para);
42 # helpers used to generate our manual pages
44 sub schema_get_type_text
{
47 if ($phash->{typetext
}) {
48 return $phash->{typetext
};
49 } elsif ($phash->{enum
}) {
50 return "(" . join(' | ', sort @{$phash->{enum
}}) . ")";
51 } elsif ($phash->{pattern
}) {
52 return $phash->{pattern
};
53 } elsif ($phash->{type
} eq 'integer' || $phash->{type
} eq 'number') {
54 if (defined($phash->{minimum
}) && defined($phash->{maximum
})) {
55 return "$phash->{type} ($phash->{minimum} - $phash->{maximum})";
56 } elsif (defined($phash->{minimum
})) {
57 return "$phash->{type} ($phash->{minimum} - N)";
58 } elsif (defined($phash->{maximum
})) {
59 return "$phash->{type} (-N - $phash->{maximum})";
63 my $type = $phash->{type
} || 'string';
68 # generta epop from JSON schema properties
70 my ($properties) = @_;
72 my $data = "=over 1\n\n";
74 my $idx_param = {}; # -vlan\d+ -scsi\d+
76 foreach my $key (sort keys %$properties) {
77 my $d = $properties->{$key};
79 if ($key =~ m/^([a-z]+)(\d+)$/) {
81 next if $idx_param->{$name};
82 $idx_param->{$name} = 1;
86 my $descr = $d->{description
} || 'No description avalable.';
89 if (defined(my $dv = $d->{default})) {
90 my $multi = $descr =~ m/\n\n/; # multi paragraph ?
91 $descr .= $multi ?
"\n\n" : " ";
92 $descr .= "Default value is '$dv'.";
95 my $typetext = schema_get_type_text
($d);
96 $data .= "=item $base: $typetext\n\n";
97 $data .= "$descr\n\n";