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