diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-11 21:32:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-11 21:32:29 -0400 |
commit | cbd8aca472134e666eee87462177f1be854ebbf8 (patch) | |
tree | fbe0dd2ffbd14eeb1b8ec5dbb39fe52b0cbb76e5 /scripts/kernel-doc | |
parent | 35e9a274fdc9c8feb763e4970a32d7089f51393c (diff) | |
parent | 26de9c26bf8557584c1977da92f3ed1b752291cf (diff) |
Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull kbuild misc changes from Michal Marek:
"In the non-critical part of kbuild, I have
- Some make coccicheck improvements and two new tests
- Support for a cleaner html output in scripts/kernel-doc, named
html5 (no, it does not play videos, yet)
BTW, Randy wants to route further kernel-doc patches through the
kbuild tree."
* 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
Update SmPL/Coccinelle section of MAINTAINERS
coccicheck: Add the rep+ctxt mode
scripts/coccinelle/tests/odd_ptr_err.cocci: semantic patch for IS_ERR/PTR_ERR inconsistency
scripts/tags.sh: Add magic for pci access functions
scripts/coccinelle: ptr_ret: Add ternary operator version
scripts/kernel-doc: drop maintainer
scripts/kernel-doc: added support for html5
Diffstat (limited to 'scripts/kernel-doc')
-rwxr-xr-x | scripts/kernel-doc | 273 |
1 files changed, 266 insertions, 7 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 01e8a8e22602..46e7aff80d1a 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
@@ -6,6 +6,7 @@ use strict; | |||
6 | ## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## | 6 | ## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## |
7 | ## Copyright (C) 2001 Simon Huggins ## | 7 | ## Copyright (C) 2001 Simon Huggins ## |
8 | ## Copyright (C) 2005-2012 Randy Dunlap ## | 8 | ## Copyright (C) 2005-2012 Randy Dunlap ## |
9 | ## Copyright (C) 2012 Dan Luedtke ## | ||
9 | ## ## | 10 | ## ## |
10 | ## #define enhancements by Armin Kuster <akuster@mvista.com> ## | 11 | ## #define enhancements by Armin Kuster <akuster@mvista.com> ## |
11 | ## Copyright (c) 2000 MontaVista Software, Inc. ## | 12 | ## Copyright (c) 2000 MontaVista Software, Inc. ## |
@@ -35,6 +36,8 @@ use strict; | |||
35 | # Small fixes (like spaces vs. \s in regex) | 36 | # Small fixes (like spaces vs. \s in regex) |
36 | # -- Tim Jansen <tim@tjansen.de> | 37 | # -- Tim Jansen <tim@tjansen.de> |
37 | 38 | ||
39 | # 25/07/2012 - Added support for HTML5 | ||
40 | # -- Dan Luedtke <mail@danrl.de> | ||
38 | 41 | ||
39 | # | 42 | # |
40 | # This will read a 'c' file and scan for embedded comments in the | 43 | # This will read a 'c' file and scan for embedded comments in the |
@@ -44,12 +47,16 @@ use strict; | |||
44 | # Note: This only supports 'c'. | 47 | # Note: This only supports 'c'. |
45 | 48 | ||
46 | # usage: | 49 | # usage: |
47 | # kernel-doc [ -docbook | -html | -text | -man | -list ] [ -no-doc-sections ] | 50 | # kernel-doc [ -docbook | -html | -html5 | -text | -man | -list ] |
48 | # [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile | 51 | # [ -no-doc-sections ] |
52 | # [ -function funcname [ -function funcname ...] ] | ||
53 | # c file(s)s > outputfile | ||
49 | # or | 54 | # or |
50 | # [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile | 55 | # [ -nofunction funcname [ -function funcname ...] ] |
56 | # c file(s)s > outputfile | ||
51 | # | 57 | # |
52 | # Set output format using one of -docbook -html -text or -man. Default is man. | 58 | # Set output format using one of -docbook -html -html5 -text or -man. |
59 | # Default is man. | ||
53 | # The -list format is for internal use by docproc. | 60 | # The -list format is for internal use by docproc. |
54 | # | 61 | # |
55 | # -no-doc-sections | 62 | # -no-doc-sections |
@@ -182,6 +189,14 @@ my $local_lt = "\\\\\\\\lt:"; | |||
182 | my $local_gt = "\\\\\\\\gt:"; | 189 | my $local_gt = "\\\\\\\\gt:"; |
183 | my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>" | 190 | my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>" |
184 | 191 | ||
192 | # html version 5 | ||
193 | my %highlights_html5 = ( $type_constant, "<span class=\"const\">\$1</span>", | ||
194 | $type_func, "<span class=\"func\">\$1</span>", | ||
195 | $type_struct_xml, "<span class=\"struct\">\$1</span>", | ||
196 | $type_env, "<span class=\"env\">\$1</span>", | ||
197 | $type_param, "<span class=\"param\">\$1</span>" ); | ||
198 | my $blankline_html5 = $local_lt . "br /" . $local_gt; | ||
199 | |||
185 | # XML, docbook format | 200 | # XML, docbook format |
186 | my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>", | 201 | my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>", |
187 | $type_constant, "<constant>\$1</constant>", | 202 | $type_constant, "<constant>\$1</constant>", |
@@ -311,6 +326,10 @@ while ($ARGV[0] =~ m/^-(.*)/) { | |||
311 | $output_mode = "html"; | 326 | $output_mode = "html"; |
312 | %highlights = %highlights_html; | 327 | %highlights = %highlights_html; |
313 | $blankline = $blankline_html; | 328 | $blankline = $blankline_html; |
329 | } elsif ($cmd eq "-html5") { | ||
330 | $output_mode = "html5"; | ||
331 | %highlights = %highlights_html5; | ||
332 | $blankline = $blankline_html5; | ||
314 | } elsif ($cmd eq "-man") { | 333 | } elsif ($cmd eq "-man") { |
315 | $output_mode = "man"; | 334 | $output_mode = "man"; |
316 | %highlights = %highlights_man; | 335 | %highlights = %highlights_man; |
@@ -353,10 +372,11 @@ while ($ARGV[0] =~ m/^-(.*)/) { | |||
353 | # continue execution near EOF; | 372 | # continue execution near EOF; |
354 | 373 | ||
355 | sub usage { | 374 | sub usage { |
356 | print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man | -list ]\n"; | 375 | print "Usage: $0 [ -docbook | -html | -html5 | -text | -man | -list ]\n"; |
357 | print " [ -no-doc-sections ]\n"; | 376 | print " [ -no-doc-sections ]\n"; |
358 | print " [ -function funcname [ -function funcname ...] ]\n"; | 377 | print " [ -function funcname [ -function funcname ...] ]\n"; |
359 | print " [ -nofunction funcname [ -nofunction funcname ...] ]\n"; | 378 | print " [ -nofunction funcname [ -nofunction funcname ...] ]\n"; |
379 | print " [ -v ]\n"; | ||
360 | print " c source file(s) > outputfile\n"; | 380 | print " c source file(s) > outputfile\n"; |
361 | print " -v : verbose output, more warnings & other info listed\n"; | 381 | print " -v : verbose output, more warnings & other info listed\n"; |
362 | exit 1; | 382 | exit 1; |
@@ -450,7 +470,8 @@ sub output_highlight { | |||
450 | # confess "output_highlight got called with no args?\n"; | 470 | # confess "output_highlight got called with no args?\n"; |
451 | # } | 471 | # } |
452 | 472 | ||
453 | if ($output_mode eq "html" || $output_mode eq "xml") { | 473 | if ($output_mode eq "html" || $output_mode eq "html5" || |
474 | $output_mode eq "xml") { | ||
454 | $contents = local_unescape($contents); | 475 | $contents = local_unescape($contents); |
455 | # convert data read & converted thru xml_escape() into &xyz; format: | 476 | # convert data read & converted thru xml_escape() into &xyz; format: |
456 | $contents =~ s/\\\\\\/\&/g; | 477 | $contents =~ s/\\\\\\/\&/g; |
@@ -460,6 +481,11 @@ sub output_highlight { | |||
460 | die $@ if $@; | 481 | die $@ if $@; |
461 | # print STDERR "contents af:$contents\n"; | 482 | # print STDERR "contents af:$contents\n"; |
462 | 483 | ||
484 | # strip whitespaces when generating html5 | ||
485 | if ($output_mode eq "html5") { | ||
486 | $contents =~ s/^\s+//; | ||
487 | $contents =~ s/\s+$//; | ||
488 | } | ||
463 | foreach $line (split "\n", $contents) { | 489 | foreach $line (split "\n", $contents) { |
464 | if (! $output_preformatted) { | 490 | if (! $output_preformatted) { |
465 | $line =~ s/^\s*//; | 491 | $line =~ s/^\s*//; |
@@ -480,7 +506,7 @@ sub output_highlight { | |||
480 | } | 506 | } |
481 | } | 507 | } |
482 | 508 | ||
483 | #output sections in html | 509 | # output sections in html |
484 | sub output_section_html(%) { | 510 | sub output_section_html(%) { |
485 | my %args = %{$_[0]}; | 511 | my %args = %{$_[0]}; |
486 | my $section; | 512 | my $section; |
@@ -640,6 +666,239 @@ sub output_blockhead_html(%) { | |||
640 | print "<hr>\n"; | 666 | print "<hr>\n"; |
641 | } | 667 | } |
642 | 668 | ||
669 | # output sections in html5 | ||
670 | sub output_section_html5(%) { | ||
671 | my %args = %{$_[0]}; | ||
672 | my $section; | ||
673 | |||
674 | foreach $section (@{$args{'sectionlist'}}) { | ||
675 | print "<section>\n"; | ||
676 | print "<h1>$section</h1>\n"; | ||
677 | print "<p>\n"; | ||
678 | output_highlight($args{'sections'}{$section}); | ||
679 | print "</p>\n"; | ||
680 | print "</section>\n"; | ||
681 | } | ||
682 | } | ||
683 | |||
684 | # output enum in html5 | ||
685 | sub output_enum_html5(%) { | ||
686 | my %args = %{$_[0]}; | ||
687 | my ($parameter); | ||
688 | my $count; | ||
689 | my $html5id; | ||
690 | |||
691 | $html5id = $args{'enum'}; | ||
692 | $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; | ||
693 | print "<article class=\"enum\" id=\"enum:". $html5id . "\">"; | ||
694 | print "<h1>enum " . $args{'enum'} . "</h1>\n"; | ||
695 | print "<ol class=\"code\">\n"; | ||
696 | print "<li>"; | ||
697 | print "<span class=\"keyword\">enum</span> "; | ||
698 | print "<span class=\"identifier\">" . $args{'enum'} . "</span> {"; | ||
699 | print "</li>\n"; | ||
700 | $count = 0; | ||
701 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
702 | print "<li class=\"indent\">"; | ||
703 | print "<span class=\"param\">" . $parameter . "</span>"; | ||
704 | if ($count != $#{$args{'parameterlist'}}) { | ||
705 | $count++; | ||
706 | print ","; | ||
707 | } | ||
708 | print "</li>\n"; | ||
709 | } | ||
710 | print "<li>};</li>\n"; | ||
711 | print "</ol>\n"; | ||
712 | |||
713 | print "<section>\n"; | ||
714 | print "<h1>Constants</h1>\n"; | ||
715 | print "<dl>\n"; | ||
716 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
717 | print "<dt>" . $parameter . "</dt>\n"; | ||
718 | print "<dd>"; | ||
719 | output_highlight($args{'parameterdescs'}{$parameter}); | ||
720 | print "</dd>\n"; | ||
721 | } | ||
722 | print "</dl>\n"; | ||
723 | print "</section>\n"; | ||
724 | output_section_html5(@_); | ||
725 | print "</article>\n"; | ||
726 | } | ||
727 | |||
728 | # output typedef in html5 | ||
729 | sub output_typedef_html5(%) { | ||
730 | my %args = %{$_[0]}; | ||
731 | my ($parameter); | ||
732 | my $count; | ||
733 | my $html5id; | ||
734 | |||
735 | $html5id = $args{'typedef'}; | ||
736 | $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; | ||
737 | print "<article class=\"typedef\" id=\"typedef:" . $html5id . "\">\n"; | ||
738 | print "<h1>typedef " . $args{'typedef'} . "</h1>\n"; | ||
739 | |||
740 | print "<ol class=\"code\">\n"; | ||
741 | print "<li>"; | ||
742 | print "<span class=\"keyword\">typedef</span> "; | ||
743 | print "<span class=\"identifier\">" . $args{'typedef'} . "</span>"; | ||
744 | print "</li>\n"; | ||
745 | print "</ol>\n"; | ||
746 | output_section_html5(@_); | ||
747 | print "</article>\n"; | ||
748 | } | ||
749 | |||
750 | # output struct in html5 | ||
751 | sub output_struct_html5(%) { | ||
752 | my %args = %{$_[0]}; | ||
753 | my ($parameter); | ||
754 | my $html5id; | ||
755 | |||
756 | $html5id = $args{'struct'}; | ||
757 | $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; | ||
758 | print "<article class=\"struct\" id=\"struct:" . $html5id . "\">\n"; | ||
759 | print "<hgroup>\n"; | ||
760 | print "<h1>" . $args{'type'} . " " . $args{'struct'} . "</h1>"; | ||
761 | print "<h2>". $args{'purpose'} . "</h2>\n"; | ||
762 | print "</hgroup>\n"; | ||
763 | print "<ol class=\"code\">\n"; | ||
764 | print "<li>"; | ||
765 | print "<span class=\"type\">" . $args{'type'} . "</span> "; | ||
766 | print "<span class=\"identifier\">" . $args{'struct'} . "</span> {"; | ||
767 | print "</li>\n"; | ||
768 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
769 | print "<li class=\"indent\">"; | ||
770 | if ($parameter =~ /^#/) { | ||
771 | print "<span class=\"param\">" . $parameter ."</span>\n"; | ||
772 | print "</li>\n"; | ||
773 | next; | ||
774 | } | ||
775 | my $parameter_name = $parameter; | ||
776 | $parameter_name =~ s/\[.*//; | ||
777 | |||
778 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; | ||
779 | $type = $args{'parametertypes'}{$parameter}; | ||
780 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { | ||
781 | # pointer-to-function | ||
782 | print "<span class=\"type\">$1</span> "; | ||
783 | print "<span class=\"param\">$parameter</span>"; | ||
784 | print "<span class=\"type\">)</span> "; | ||
785 | print "(<span class=\"args\">$2</span>);"; | ||
786 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { | ||
787 | # bitfield | ||
788 | print "<span class=\"type\">$1</span> "; | ||
789 | print "<span class=\"param\">$parameter</span>"; | ||
790 | print "<span class=\"bits\">$2</span>;"; | ||
791 | } else { | ||
792 | print "<span class=\"type\">$type</span> "; | ||
793 | print "<span class=\"param\">$parameter</span>;"; | ||
794 | } | ||
795 | print "</li>\n"; | ||
796 | } | ||
797 | print "<li>};</li>\n"; | ||
798 | print "</ol>\n"; | ||
799 | |||
800 | print "<section>\n"; | ||
801 | print "<h1>Members</h1>\n"; | ||
802 | print "<dl>\n"; | ||
803 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
804 | ($parameter =~ /^#/) && next; | ||
805 | |||
806 | my $parameter_name = $parameter; | ||
807 | $parameter_name =~ s/\[.*//; | ||
808 | |||
809 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; | ||
810 | print "<dt>" . $parameter . "</dt>\n"; | ||
811 | print "<dd>"; | ||
812 | output_highlight($args{'parameterdescs'}{$parameter_name}); | ||
813 | print "</dd>\n"; | ||
814 | } | ||
815 | print "</dl>\n"; | ||
816 | print "</section>\n"; | ||
817 | output_section_html5(@_); | ||
818 | print "</article>\n"; | ||
819 | } | ||
820 | |||
821 | # output function in html5 | ||
822 | sub output_function_html5(%) { | ||
823 | my %args = %{$_[0]}; | ||
824 | my ($parameter, $section); | ||
825 | my $count; | ||
826 | my $html5id; | ||
827 | |||
828 | $html5id = $args{'function'}; | ||
829 | $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; | ||
830 | print "<article class=\"function\" id=\"func:". $html5id . "\">\n"; | ||
831 | print "<hgroup>\n"; | ||
832 | print "<h1>" . $args{'function'} . "</h1>"; | ||
833 | print "<h2>" . $args{'purpose'} . "</h2>\n"; | ||
834 | print "</hgroup>\n"; | ||
835 | print "<ol class=\"code\">\n"; | ||
836 | print "<li>"; | ||
837 | print "<span class=\"type\">" . $args{'functiontype'} . "</span> "; | ||
838 | print "<span class=\"identifier\">" . $args{'function'} . "</span> ("; | ||
839 | print "</li>"; | ||
840 | $count = 0; | ||
841 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
842 | print "<li class=\"indent\">"; | ||
843 | $type = $args{'parametertypes'}{$parameter}; | ||
844 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { | ||
845 | # pointer-to-function | ||
846 | print "<span class=\"type\">$1</span> "; | ||
847 | print "<span class=\"param\">$parameter</span>"; | ||
848 | print "<span class=\"type\">)</span> "; | ||
849 | print "(<span class=\"args\">$2</span>)"; | ||
850 | } else { | ||
851 | print "<span class=\"type\">$type</span> "; | ||
852 | print "<span class=\"param\">$parameter</span>"; | ||
853 | } | ||
854 | if ($count != $#{$args{'parameterlist'}}) { | ||
855 | $count++; | ||
856 | print ","; | ||
857 | } | ||
858 | print "</li>\n"; | ||
859 | } | ||
860 | print "<li>)</li>\n"; | ||
861 | print "</ol>\n"; | ||
862 | |||
863 | print "<section>\n"; | ||
864 | print "<h1>Arguments</h1>\n"; | ||
865 | print "<p>\n"; | ||
866 | print "<dl>\n"; | ||
867 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
868 | my $parameter_name = $parameter; | ||
869 | $parameter_name =~ s/\[.*//; | ||
870 | |||
871 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; | ||
872 | print "<dt>" . $parameter . "</dt>\n"; | ||
873 | print "<dd>"; | ||
874 | output_highlight($args{'parameterdescs'}{$parameter_name}); | ||
875 | print "</dd>\n"; | ||
876 | } | ||
877 | print "</dl>\n"; | ||
878 | print "</section>\n"; | ||
879 | output_section_html5(@_); | ||
880 | print "</article>\n"; | ||
881 | } | ||
882 | |||
883 | # output DOC: block header in html5 | ||
884 | sub output_blockhead_html5(%) { | ||
885 | my %args = %{$_[0]}; | ||
886 | my ($parameter, $section); | ||
887 | my $count; | ||
888 | my $html5id; | ||
889 | |||
890 | foreach $section (@{$args{'sectionlist'}}) { | ||
891 | $html5id = $section; | ||
892 | $html5id =~ s/[^a-zA-Z0-9\-]+/_/g; | ||
893 | print "<article class=\"doc\" id=\"doc:". $html5id . "\">\n"; | ||
894 | print "<h1>$section</h1>\n"; | ||
895 | print "<p>\n"; | ||
896 | output_highlight($args{'sections'}{$section}); | ||
897 | print "</p>\n"; | ||
898 | } | ||
899 | print "</article>\n"; | ||
900 | } | ||
901 | |||
643 | sub output_section_xml(%) { | 902 | sub output_section_xml(%) { |
644 | my %args = %{$_[0]}; | 903 | my %args = %{$_[0]}; |
645 | my $section; | 904 | my $section; |