kernel-doc (c17add56ca4ee618b07ed9a21e2a29f0a90dc0ba) kernel-doc (af250290430e1e678eef8c5c646a1bfd6af7b68a)
1#!/usr/bin/env perl
2
3use warnings;
4use strict;
5
6## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
7## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ##
8## Copyright (C) 2001 Simon Huggins ##

--- 734 unchanged lines hidden (view full) ---

743 print "**$section**\n\n";
744 }
745 print_lineno($section_start_lines{$section});
746 output_highlight_rst($args{'sections'}{$section});
747 print "\n";
748 }
749}
750
1#!/usr/bin/env perl
2
3use warnings;
4use strict;
5
6## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
7## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ##
8## Copyright (C) 2001 Simon Huggins ##

--- 734 unchanged lines hidden (view full) ---

743 print "**$section**\n\n";
744 }
745 print_lineno($section_start_lines{$section});
746 output_highlight_rst($args{'sections'}{$section});
747 print "\n";
748 }
749}
750
751#
752# Apply the RST highlights to a sub-block of text.
753#
754sub highlight_block($) {
755 # The dohighlight kludge requires the text be called $contents
756 my $contents = shift;
757 eval $dohighlight;
758 die $@ if $@;
759 return $contents;
760}
761
762#
763# Regexes used only here.
764#
765my $sphinx_literal = '^[^.].*::$';
766my $sphinx_cblock = '^\.\.\ +code-block::';
767
751sub output_highlight_rst {
768sub output_highlight_rst {
752 my $contents = join "\n",@_;
769 my $input = join "\n",@_;
770 my $output = "";
753 my $line;
771 my $line;
772 my $in_literal = 0;
773 my $litprefix;
774 my $block = "";
754
775
755 eval $dohighlight;
756 die $@ if $@;
776 foreach $line (split "\n",$input) {
777 #
778 # If we're in a literal block, see if we should drop out
779 # of it. Otherwise pass the line straight through unmunged.
780 #
781 if ($in_literal) {
782 if (! ($line =~ /^\s*$/)) {
783 #
784 # If this is the first non-blank line in a literal
785 # block we need to figure out what the proper indent is.
786 #
787 if ($litprefix eq "") {
788 $line =~ /^(\s*)/;
789 $litprefix = '^' . $1;
790 $output .= $line . "\n";
791 } elsif (! ($line =~ /$litprefix/)) {
792 $in_literal = 0;
793 } else {
794 $output .= $line . "\n";
795 }
796 } else {
797 $output .= $line . "\n";
798 }
799 }
800 #
801 # Not in a literal block (or just dropped out)
802 #
803 if (! $in_literal) {
804 $block .= $line . "\n";
805 if (($line =~ /$sphinx_literal/) || ($line =~ /$sphinx_cblock/)) {
806 $in_literal = 1;
807 $litprefix = "";
808 $output .= highlight_block($block);
809 $block = ""
810 }
811 }
812 }
757
813
758 foreach $line (split "\n", $contents) {
814 if ($block) {
815 $output .= highlight_block($block);
816 }
817 foreach $line (split "\n", $output) {
759 print $lineprefix . $line . "\n";
760 }
761}
762
763sub output_function_rst(%) {
764 my %args = %{$_[0]};
765 my ($parameter, $section);
766 my $oldprefix = $lineprefix;

--- 1396 unchanged lines hidden ---
818 print $lineprefix . $line . "\n";
819 }
820}
821
822sub output_function_rst(%) {
823 my %args = %{$_[0]};
824 my ($parameter, $section);
825 my $oldprefix = $lineprefix;

--- 1396 unchanged lines hidden ---