summaryrefslogtreecommitdiff
path: root/libnm/generate-plugin-docs.pl
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2016-11-21 18:03:26 +0100
committerLubomir Rintel <lkundrak@v3.sk>2016-11-21 18:15:42 +0100
commit3b64dc9cbdc5468e899429428ad1b65e27ab15fb (patch)
treecab3ac24b797e79b4f6ae73053ead8898ad48d7d /libnm/generate-plugin-docs.pl
parent11e26d015a632b3c6866cf135f230e018b5055e9 (diff)
downloadNetworkManager-3b64dc9cbdc5468e899429428ad1b65e27ab15fb.tar.gz
libnm/generate-plugin-docs: drop YAML dependency
It makes little sense to produce a YAML and then decompose it.
Diffstat (limited to 'libnm/generate-plugin-docs.pl')
-rwxr-xr-xlibnm/generate-plugin-docs.pl40
1 files changed, 16 insertions, 24 deletions
diff --git a/libnm/generate-plugin-docs.pl b/libnm/generate-plugin-docs.pl
index 8c4a39da67..1d894bc481 100755
--- a/libnm/generate-plugin-docs.pl
+++ b/libnm/generate-plugin-docs.pl
@@ -43,10 +43,6 @@
use strict;
use warnings;
use v5.10;
-#YAML:XS is based on libyaml C library and it is a good and fast YAML implementation.
-#However it may not be present everywhere. So use YAML instead.
-#use YAML::XS qw(Load);
-use YAML qw(Load);
# global variables
my @keywords = ("property", "variable", "format", "values", "default", "example", "description");
@@ -124,35 +120,31 @@ sub scan_doc_comments {
close $fi;
}
-# process plugin property documentation comments (as a YAML document)
+# process plugin property documentation comments
sub process_data {
return if not @data;
my $kwd_pat = join("|", @keywords);
- my $yaml_literal_seq = "|\n";
+ my %parsed_data;
+ my $this_key;
foreach (@data) {
- # make a proper YAML document from @data
- $_ =~ s/^\s*\**\s+|\s+$//; # remove leading spaces and *, and traling spaces
- # Properly indent the text so that it is a valid YAML, and insert | (for literal text)
- if ($_ =~ /^($kwd_pat):\s+/) {
- # add | after "keyword:" that allows using literal text (YAML won't break on special character)
- # http://learnxinyminutes.com/docs/yaml/ and http://www.yaml.org/spec/1.2/spec.html#id2795688
- $_ =~ s/(^($kwd_pat):)/$1 $yaml_literal_seq/;
- } else {
- $_ = " " . $_; # indent the text
+ if (/^\s*\**\s+($kwd_pat):\s+(.*?)\s*$/) {
+ $this_key = $1;
+ $parsed_data{$this_key} = "$2\n";
+ } elsif (/^\s*\**\s+(.*?)\s*$/) {
+ die "Extra mess in a comment: $_" unless $this_key;
+ $parsed_data{$this_key} .= $1 ? "$1\n" : " ";
}
}
- my $str = join ("", @data);
- my $yaml_data = Load($str);
# now write a line into the XML
- my $name = $yaml_data->{property} // "";
- my $var = $yaml_data->{variable} // $name; # fallback to "property: "
- my $format = $yaml_data->{format} // "";
- my $values = $yaml_data->{values} // "";
- my $def = $yaml_data->{default} // "";
- my $exam = $yaml_data->{example} // "";
- my $desc = $yaml_data->{description} // "";
+ my $name = $parsed_data{property} // "";
+ my $var = $parsed_data{variable} // $name; # fallback to "property: "
+ my $format = $parsed_data{format} // "";
+ my $values = $parsed_data{values} // "";
+ my $def = $parsed_data{default} // "";
+ my $exam = $parsed_data{example} // "";
+ my $desc = $parsed_data{description} // "";
chomp($name, $var, $format, $values, $def, $exam, $desc);
escape_xml_chars($name, $var, $format, $values, $def, $exam, $desc);