aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kernel-doc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-11 21:32:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-11 21:32:29 -0400
commitcbd8aca472134e666eee87462177f1be854ebbf8 (patch)
treefbe0dd2ffbd14eeb1b8ec5dbb39fe52b0cbb76e5 /scripts/kernel-doc
parent35e9a274fdc9c8feb763e4970a32d7089f51393c (diff)
parent26de9c26bf8557584c1977da92f3ed1b752291cf (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-xscripts/kernel-doc273
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:";
182my $local_gt = "\\\\\\\\gt:"; 189my $local_gt = "\\\\\\\\gt:";
183my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>" 190my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>"
184 191
192# html version 5
193my %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>" );
198my $blankline_html5 = $local_lt . "br /" . $local_gt;
199
185# XML, docbook format 200# XML, docbook format
186my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>", 201my %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
355sub usage { 374sub 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
484sub output_section_html(%) { 510sub 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
670sub 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
685sub 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
729sub 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>";