lkml.org 
[lkml]   [2012]   [Jul]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/3] scripts/kernel-doc: added ids to articles for reference
Date
An id has been added to block-level elements "article". This allows
jumping to a particular article via url. E.g. doc.html#func:foo
would sroll down to the documentation of function foo.

Signed-off-by: Dan Luedtke <mail@danrl.de>
---
scripts/kernel-doc | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 1d3c779..97e037a 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -499,7 +499,7 @@ sub output_highlight {
}
}

-#output sections in html
+# output sections in html
sub output_section_html(%) {
my %args = %{$_[0]};
my $section;
@@ -659,7 +659,7 @@ sub output_blockhead_html(%) {
print "<hr>\n";
}

-#output sections in html5
+# output sections in html5
sub output_section_html5(%) {
my %args = %{$_[0]};
my $section;
@@ -679,7 +679,11 @@ sub output_enum_html5(%) {
my %args = %{$_[0]};
my ($parameter);
my $count;
- print "<article class=\"enum\">\n";
+ my $html5id;
+
+ $html5id = $args{'enum'};
+ $html5id =~ s/[^a-zA-Z0-9\-]+/_/g;
+ print "<article class=\"enum\" id=\"enum:". $html5id . "\">";
print "<h1>enum " . $args{'enum'} . "</h1>\n";
print "<ol class=\"code\">\n";
print "<li>";
@@ -719,8 +723,11 @@ sub output_typedef_html5(%) {
my %args = %{$_[0]};
my ($parameter);
my $count;
+ my $html5id;

- print "<article class=\"typedef\">\n";
+ $html5id = $args{'typedef'};
+ $html5id =~ s/[^a-zA-Z0-9\-]+/_/g;
+ print "<article class=\"typedef\" id=\"typedef:" . $html5id . "\">\n";
print "<h1>typedef " . $args{'typedef'} . "</h1>\n";

print "<ol class=\"code\">\n";
@@ -737,8 +744,11 @@ sub output_typedef_html5(%) {
sub output_struct_html5(%) {
my %args = %{$_[0]};
my ($parameter);
+ my $html5id;

- print "<article class=\"struct\">\n";
+ $html5id = $args{'struct'};
+ $html5id =~ s/[^a-zA-Z0-9\-]+/_/g;
+ print "<article class=\"struct\" id=\"struct:" . $html5id . "\">\n";
print "<hgroup>\n";
print "<h1>" . $args{'type'} . " " . $args{'struct'} . "</h1>";
print "<h2>". $args{'purpose'} . "</h2>\n";
@@ -806,8 +816,11 @@ sub output_function_html5(%) {
my %args = %{$_[0]};
my ($parameter, $section);
my $count;
+ my $html5id;

- print "<article class=\"function\">\n";
+ $html5id = $args{'function'};
+ $html5id =~ s/[^a-zA-Z0-9\-]+/_/g;
+ print "<article class=\"function\" id=\"func:". $html5id . "\">\n";
print "<hgroup>\n";
print "<h1>" . $args{'function'} . "</h1>";
print "<h2>" . $args{'purpose'} . "</h2>\n";
@@ -865,9 +878,12 @@ sub output_blockhead_html5(%) {
my %args = %{$_[0]};
my ($parameter, $section);
my $count;
+ my $html5id;

foreach $section (@{$args{'sectionlist'}}) {
- print "<article class=\"doc\">\n";
+ $html5id = $section;
+ $html5id =~ s/[^a-zA-Z0-9\-]+/_/g;
+ print "<article class=\"doc\" id=\"doc:". $html5id . "\">\n";
print "<h1>$section</h1>\n";
print "<p>\n";
output_highlight($args{'sections'}{$section});
--
1.7.10


\
 
 \ /
  Last update: 2012-07-26 09:41    [W:0.067 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site