kernel-doc (d38c8cfb057183f619dc8534030bb64b63f78043) | kernel-doc (efa44475b8f5c692be4c5822a659e1a96f16dacb) |
---|---|
1#!/usr/bin/env perl 2# SPDX-License-Identifier: GPL-2.0 3 4use warnings; 5use strict; 6 7## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## 8## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## --- 257 unchanged lines hidden (view full) --- 266my $blankline_rst = "\n"; 267 268# read arguments 269if ($#ARGV == -1) { 270 usage(); 271} 272 273my $kernelversion; | 1#!/usr/bin/env perl 2# SPDX-License-Identifier: GPL-2.0 3 4use warnings; 5use strict; 6 7## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## 8## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## --- 257 unchanged lines hidden (view full) --- 266my $blankline_rst = "\n"; 267 268# read arguments 269if ($#ARGV == -1) { 270 usage(); 271} 272 273my $kernelversion; |
274my $sphinx_major; 275 |
|
274my $dohighlight = ""; 275 276my $verbose = 0; 277my $Werror = 0; 278my $output_mode = "rst"; 279my $output_preformatted = 0; 280my $no_doc_sections = 0; 281my $enable_lineno = 0; --- 178 unchanged lines hidden (view full) --- 460 } else { 461 # Unknown argument 462 usage(); 463 } 464} 465 466# continue execution near EOF; 467 | 276my $dohighlight = ""; 277 278my $verbose = 0; 279my $Werror = 0; 280my $output_mode = "rst"; 281my $output_preformatted = 0; 282my $no_doc_sections = 0; 283my $enable_lineno = 0; --- 178 unchanged lines hidden (view full) --- 462 } else { 463 # Unknown argument 464 usage(); 465 } 466} 467 468# continue execution near EOF; 469 |
470# The C domain dialect changed on Sphinx 3. So, we need to check the 471# version in order to produce the right tags. 472sub findprog($) 473{ 474 foreach(split(/:/, $ENV{PATH})) { 475 return "$_/$_[0]" if(-x "$_/$_[0]"); 476 } 477} 478 479sub get_sphinx_version() 480{ 481 my $ver; 482 my $major = 1; 483 484 my $cmd = "sphinx-build"; 485 if (!findprog($cmd)) { 486 my $cmd = "sphinx-build3"; 487 return $major if (!findprog($cmd)); 488 } 489 490 open IN, "$cmd --version 2>&1 |"; 491 while (<IN>) { 492 if (m/^\s*sphinx-build\s+([\d]+)\.([\d\.]+)(\+\/[\da-f]+)?$/) { 493 $major=$1; 494 last; 495 } 496 # Sphinx 1.2.x uses a different format 497 if (m/^\s*Sphinx.*\s+([\d]+)\.([\d\.]+)$/) { 498 $major=$1; 499 last; 500 } 501 } 502 close IN; 503 504 return $major; 505} 506 |
|
468# get kernel version from env 469sub get_kernel_version() { 470 my $version = 'unknown kernel version'; 471 472 if (defined($ENV{'KERNELVERSION'})) { 473 $version = $ENV{'KERNELVERSION'}; 474 } 475 return $version; --- 367 unchanged lines hidden (view full) --- 843 844sub output_function_rst(%) { 845 my %args = %{$_[0]}; 846 my ($parameter, $section); 847 my $oldprefix = $lineprefix; 848 my $start = ""; 849 850 if ($args{'typedef'}) { | 507# get kernel version from env 508sub get_kernel_version() { 509 my $version = 'unknown kernel version'; 510 511 if (defined($ENV{'KERNELVERSION'})) { 512 $version = $ENV{'KERNELVERSION'}; 513 } 514 return $version; --- 367 unchanged lines hidden (view full) --- 882 883sub output_function_rst(%) { 884 my %args = %{$_[0]}; 885 my ($parameter, $section); 886 my $oldprefix = $lineprefix; 887 my $start = ""; 888 889 if ($args{'typedef'}) { |
851 print ".. c:type:: ". $args{'function'} . "\n\n"; | 890 if ($sphinx_major < 3) { 891 print ".. c:type:: ". $args{'function'} . "\n\n"; 892 } else { 893 print ".. c:function:: ". $args{'function'} . "\n\n"; 894 } |
852 print_lineno($declaration_start_line); 853 print " **Typedef**: "; 854 $lineprefix = ""; 855 output_highlight_rst($args{'purpose'}); 856 $start = "\n\n**Syntax**\n\n ``"; 857 } else { 858 print ".. c:function:: "; 859 } --- 73 unchanged lines hidden (view full) --- 933 $lineprefix = $oldprefix; 934} 935 936sub output_enum_rst(%) { 937 my %args = %{$_[0]}; 938 my ($parameter); 939 my $oldprefix = $lineprefix; 940 my $count; | 895 print_lineno($declaration_start_line); 896 print " **Typedef**: "; 897 $lineprefix = ""; 898 output_highlight_rst($args{'purpose'}); 899 $start = "\n\n**Syntax**\n\n ``"; 900 } else { 901 print ".. c:function:: "; 902 } --- 73 unchanged lines hidden (view full) --- 976 $lineprefix = $oldprefix; 977} 978 979sub output_enum_rst(%) { 980 my %args = %{$_[0]}; 981 my ($parameter); 982 my $oldprefix = $lineprefix; 983 my $count; |
941 my $name = "enum " . $args{'enum'}; | |
942 | 984 |
943 print "\n\n.. c:type:: " . $name . "\n\n"; | 985 if ($sphinx_major < 3) { 986 my $name = "enum " . $args{'enum'}; 987 print "\n\n.. c:type:: " . $name . "\n\n"; 988 } else { 989 my $name = $args{'enum'}; 990 print "\n\n.. c:enum:: " . $name . "\n\n"; 991 } |
944 print_lineno($declaration_start_line); 945 $lineprefix = " "; 946 output_highlight_rst($args{'purpose'}); 947 print "\n"; 948 949 print "**Constants**\n\n"; 950 $lineprefix = " "; 951 foreach $parameter (@{$args{'parameterlist'}}) { --- 9 unchanged lines hidden (view full) --- 961 $lineprefix = $oldprefix; 962 output_section_rst(@_); 963} 964 965sub output_typedef_rst(%) { 966 my %args = %{$_[0]}; 967 my ($parameter); 968 my $oldprefix = $lineprefix; | 992 print_lineno($declaration_start_line); 993 $lineprefix = " "; 994 output_highlight_rst($args{'purpose'}); 995 print "\n"; 996 997 print "**Constants**\n\n"; 998 $lineprefix = " "; 999 foreach $parameter (@{$args{'parameterlist'}}) { --- 9 unchanged lines hidden (view full) --- 1009 $lineprefix = $oldprefix; 1010 output_section_rst(@_); 1011} 1012 1013sub output_typedef_rst(%) { 1014 my %args = %{$_[0]}; 1015 my ($parameter); 1016 my $oldprefix = $lineprefix; |
969 my $name = "typedef " . $args{'typedef'}; | 1017 my $name; |
970 | 1018 |
1019 if ($sphinx_major < 3) { 1020 $name = "typedef " . $args{'typedef'}; 1021 } else { 1022 $name = $args{'typedef'}; 1023 } |
|
971 print "\n\n.. c:type:: " . $name . "\n\n"; 972 print_lineno($declaration_start_line); 973 $lineprefix = " "; 974 output_highlight_rst($args{'purpose'}); 975 print "\n"; 976 977 $lineprefix = $oldprefix; 978 output_section_rst(@_); 979} 980 981sub output_struct_rst(%) { 982 my %args = %{$_[0]}; 983 my ($parameter); 984 my $oldprefix = $lineprefix; | 1024 print "\n\n.. c:type:: " . $name . "\n\n"; 1025 print_lineno($declaration_start_line); 1026 $lineprefix = " "; 1027 output_highlight_rst($args{'purpose'}); 1028 print "\n"; 1029 1030 $lineprefix = $oldprefix; 1031 output_section_rst(@_); 1032} 1033 1034sub output_struct_rst(%) { 1035 my %args = %{$_[0]}; 1036 my ($parameter); 1037 my $oldprefix = $lineprefix; |
985 my $name = $args{'type'} . " " . $args{'struct'}; | |
986 | 1038 |
987 print "\n\n.. c:type:: " . $name . "\n\n"; | 1039 if ($sphinx_major < 3) { 1040 my $name = $args{'type'} . " " . $args{'struct'}; 1041 print "\n\n.. c:type:: " . $name . "\n\n"; 1042 } else { 1043 my $name = $args{'struct'}; 1044 print "\n\n.. c:struct:: " . $name . "\n\n"; 1045 } |
988 print_lineno($declaration_start_line); 989 $lineprefix = " "; 990 output_highlight_rst($args{'purpose'}); 991 print "\n"; 992 993 print "**Definition**\n\n"; 994 print "::\n\n"; 995 my $declaration = $args{'definition'}; --- 1241 unchanged lines hidden (view full) --- 2237 } 2238 else { 2239 print STDERR "${file}:1: warning: no structured comments found\n"; 2240 } 2241 } 2242} 2243 2244 | 1046 print_lineno($declaration_start_line); 1047 $lineprefix = " "; 1048 output_highlight_rst($args{'purpose'}); 1049 print "\n"; 1050 1051 print "**Definition**\n\n"; 1052 print "::\n\n"; 1053 my $declaration = $args{'definition'}; --- 1241 unchanged lines hidden (view full) --- 2295 } 2296 else { 2297 print STDERR "${file}:1: warning: no structured comments found\n"; 2298 } 2299 } 2300} 2301 2302 |
2303$sphinx_major = get_sphinx_version(); |
|
2245$kernelversion = get_kernel_version(); 2246 2247# generate a sequence of code that will splice in highlighting information 2248# using the s// operator. 2249for (my $k = 0; $k < @highlights; $k++) { 2250 my $pattern = $highlights[$k][0]; 2251 my $result = $highlights[$k][1]; 2252# print STDERR "scanning pattern:$pattern, highlight:($result)\n"; --- 44 unchanged lines hidden --- | 2304$kernelversion = get_kernel_version(); 2305 2306# generate a sequence of code that will splice in highlighting information 2307# using the s// operator. 2308for (my $k = 0; $k < @highlights; $k++) { 2309 my $pattern = $highlights[$k][0]; 2310 my $result = $highlights[$k][1]; 2311# print STDERR "scanning pattern:$pattern, highlight:($result)\n"; --- 44 unchanged lines hidden --- |