From 87e26f41a8ab42342ffd5bd1549e4eb1cff41a0d Mon Sep 17 00:00:00 2001 From: Aristotle Pagaltzis Date: Mon, 5 Jan 2015 13:41:07 +0100 Subject: [PATCH] reflow and de-boilerplate the docs --- lib/Parse/MIME.pm | 58 +++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/Parse/MIME.pm b/lib/Parse/MIME.pm index c650c40..e6e6ca8 100644 --- a/lib/Parse/MIME.pm +++ b/lib/Parse/MIME.pm @@ -128,38 +128,52 @@ __END__ =head1 DESCRIPTION -This module provides basic functions for handling mime-types. It can handle matching mime-types against a list of media-ranges. See section 14.1 of the HTTP specification [RFC 2616] for a complete explanation: L +This module provides basic functions for handling mime-types. It can handle +matching mime-types against a list of media-ranges. See section 14.1 of the +HTTP specification [RFC 2616] for a complete explanation: +L =head1 INTERFACE -None of the following functions are exported by default. You can use the C<:all> tag to import all of them into your package: +None of the following functions are exported by default. You can use the +C<:all> tag to import all of them into your package: use Parse::MIME ':all'; =head2 parse_mime_type -Parses a mime-type into its component parts and returns type, subtype and params, where params is a reference to a hash of all the parameters for the media range: +Parses a mime-type into its component parts and returns type, subtype and +params, where params is a reference to a hash of all the parameters for the +media range: parse_mime_type 'application/xhtml;q=0.5' # ( 'application', 'xhtml', { q => 0.5 } ) =head2 parse_media_range -Media-ranges are mime-types with wild-cards and a C quality parameter. This function works just like L, but also guarantees that there is a value for C in the params hash, supplying the default value if necessary. +Media-ranges are mime-types with wild-cards and a C quality parameter. This +function works just like L, but also guarantees that there is +a value for C in the params hash, supplying the default value if necessary. parse_media_range 'application/xhtml' # ( 'application', 'xhtml', { q => 1 } ) =head2 parse_media_range_list -Media-range lists are comma-separated lists of media ranges. This function works just like L, but accepts a list of media ranges and returns for all of media-ranges. +Media-range lists are comma-separated lists of media ranges. This function +works just like L, but accepts a list of media ranges and +returns for all of media-ranges. my @l = parse_media_range_list 'application/xhtml, text/html;q=0.7' # ( 'application', 'xhtml', { q => 1 }, 'text', 'html', { q => 0.7 } ) =head2 fitness_and_quality_parsed -Find the best match for a given mime-type (passed as the first parameter) against a list of media ranges that have already been parsed by L (passed as a flat list). Returns the fitness value and the value of the C quality parameter of the best match, or C<( -1, 0 )> if no match was found. +Find the best match for a given mime-type (passed as the first parameter) +against a list of media ranges that have already been parsed by +L (passed as a flat list). Returns the fitness value and +the value of the C quality parameter of the best match, or C<( -1, 0 )> if +no match was found. # for @l see above fitness_and_quality_parsed( 'text/html', @l ) @@ -167,38 +181,24 @@ Find the best match for a given mime-type (passed as the first parameter) agains =head2 quality -Determines the quality (C) of a mime-type (passed as the first parameter) when compared against a media-range list string. F.ex.: +Determines the quality (C) of a mime-type (passed as the first parameter) +when compared against a media-range list string. F.ex.: quality( 'text/html', 'text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5' ) # 0.7 =head2 quality_parsed -Just like L, except the second parameter must be pre-parsed by L. +Just like L, except the second parameter must be pre-parsed by +L. =head2 best_match -Choose the mime-type with the highest quality (C) from a list of candidates. Takes an array of supported mime-types as the first parameter and finds the best match for all the media-ranges listed in header, which is passed as the second parameter. The value of header must be a string that conforms to the format of the HTTP C header. F.ex.: +Choose the mime-type with the highest quality (C) from a list of candidates. +Takes an array of supported mime-types as the first parameter and finds the +best match for all the media-ranges listed in header, which is passed as the +second parameter. The value of header must be a string that conforms to the +format of the HTTP C header. F.ex.: best_match( [ qw( application/xbel+xml text/xml ) ], 'text/*;q=0.5,*/*; q=0.1' ) # 'text/xml' - -=head1 AUTHOR - -=over 4 - -=item * Joe Gregorio L - -Original Python code - -=item * Aristotle Pagaltzis L - -Perl port - -=back - -=head1 COPYRIGHT AND LICENCE - -Documentation: Copyright (c) 2008, Joe Gregorio. All rights reserved. - -Perl code: Copyright (c) 2008, Aristotle Pagaltzis. All rights reserved.