NAME

Wikibase::Datatype::Print::Utils - Wikibase pretty print helper utils.

SYNOPSIS

use Wikibase::Datatype::Print::Utils qw(print_aliases print_common print_descriptions
        print_forms print_glosses print_labels print_references print_senses
        print_sitelinks print_statements);

my @aliase_strings = print_aliases($obj, $opts_hr, $alias_cb);
my @common_strings = print_common($obj, $opts_hr, $list_method, $print_cb, $title, $input_cb, $flag_one_line);
my @desc_strings = print_descriptions($obj, $opts_hr, $desc_cb);
my @form_strings = print_forms($obj, $opts_hr, $form_cb);
my @glosse_strings = print_glosses($obj, $opts_hr, $glosse_cb);
my @label_strings = print_labels($obj, $opts_hr, $label_cb);
my @reference_strings = print_references($obj, $opts_hr, $reference_cb);
my @sense_strings = print_senses($obj, $opts_hr, $sense_cb);
my @sitelink_strings = print_sitelinks($obj, $opts_hr, $sitelink_cb);
my @statement_strings = print_statements($obj, $opts_hr, $statement_cb);

SUBROUTINES

my @aliase_strings = print_aliases($obj, $opts_hr, $alias_cb);

Get aliase strings from data object.

Returns array with pretty print strings.

my @common_strings = print_common($obj, $opts_hr, $list_method, $print_cb, $title, $input_cb, $flag_one_line);

Common function for get pretty print strings from object.

Returns array with pretty print strings.

my @desc_strings = print_descriptions($obj, $opts_hr, $desc_cb);

Get description strings from data object.

Returns array with pretty print strings.

my @form_strings = print_forms($obj, $opts_hr, $form_cb);

Get form strings from data object.

Returns array with pretty print strings.

my @glosse_strings = print_glosses($obj, $opts_hr, $glosse_cb);

Get glosse strings from data object.

Returns array with pretty print strings.

my @label_strings = print_labels($obj, $opts_hr, $label_cb);

Get label strings from data object.

Returns array with pretty print strings.

my @reference_strings = print_references($obj, $opts_hr, $reference_cb);

Get reference strings from data object.

Returns array with pretty print strings.

my @sense_strings = print_senses($obj, $opts_hr, $sense_cb);

Get sense strings from data object.

Returns array with pretty print strings.

my @sitelink_strings = print_sitelinks($obj, $opts_hr, $sitelink_cb);

Get sitelink strings from data object.

Returns array with pretty print strings.

my @statement_strings = print_statements($obj, $opts_hr, $statement_cb);

Get statement strings from data object.

Returns array with pretty print strings.

ERRORS

print_common():
        Multiple values are printed to one line.

print_descriptions():
        From print_common():
                Multiple values are printed to one line.

print_labels():
        From print_common():
                Multiple values are printed to one line.

EXAMPLE1

use strict;
use warnings;

use Unicode::UTF8 qw(encode_utf8);
use Test::Shared::Fixture::Wikibase::Datatype::Item::Wikidata::Dog;
use Wikibase::Datatype::Print::Utils qw(print_aliases);
use Wikibase::Datatype::Print::Value::Monolingual;

my $obj = Test::Shared::Fixture::Wikibase::Datatype::Item::Wikidata::Dog->new;
my @ret = print_aliases($obj, {'lang' => 'cs'},
        \&Wikibase::Datatype::Print::Value::Monolingual::print);

# Print.
print encode_utf8(join "\n", @ret);
print "\n";

# Output:
# Aliases:
#   pes domácí (cs)

EXAMPLE2

use strict;
use warnings;

use Unicode::UTF8 qw(encode_utf8);
use Test::Shared::Fixture::Wikibase::Datatype::Item::Wikidata::Dog;
use Wikibase::Datatype::Print::Utils qw(print_descriptions);
use Wikibase::Datatype::Print::Value::Monolingual;

my $obj = Test::Shared::Fixture::Wikibase::Datatype::Item::Wikidata::Dog->new;
my @ret = print_descriptions($obj, {'lang' => 'cs'},
        \&Wikibase::Datatype::Print::Value::Monolingual::print);

# Print.
print encode_utf8(join "\n", @ret);
print "\n";

# Output:
# Description: domácí zvíře (cs)

EXAMPLE3

use strict;
use warnings;

use Unicode::UTF8 qw(encode_utf8);
use Test::Shared::Fixture::Wikibase::Datatype::Lexeme::Wikidata::DogCzechNoun;
use Wikibase::Datatype::Print::Form;
use Wikibase::Datatype::Print::Utils qw(print_forms);

my $obj = Test::Shared::Fixture::Wikibase::Datatype::Lexeme::Wikidata::DogCzechNoun->new;
my @ret = print_forms($obj, {'lang' => 'cs'},
        \&Wikibase::Datatype::Print::Form::print);

# Print.
print encode_utf8(join "\n", @ret);
print "\n";

# Output:
# Forms:
#   Id: L469-F1
#   Representation: pes (cs)
#   Grammatical features: Q110786, Q131105
#   Statements:
#     P898: pɛs (normal)

DEPENDENCIES

Error::Pure, Exporter, Readonly.

REPOSITORY

https://github.com/michal-josef-spacek/Wikibase-Datatype-Print

AUTHOR

Michal Josef Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT

© 2020-2023 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.14