Commit c9adf651 authored by Tom Barbette's avatar Tom Barbette

Merge remote-tracking branch 'kohler_click/master'

parents 63bc8da9 a4604141
...@@ -695,6 +695,7 @@ LIBOBJS ...@@ -695,6 +695,7 @@ LIBOBJS
freebsd_includedir freebsd_includedir
freebsd_srcdir freebsd_srcdir
FINDELEMFLAGS FINDELEMFLAGS
all_element_groups
element_groups element_groups
linux_srcdir linux_srcdir
linux_builddir linux_builddir
...@@ -7544,12 +7545,15 @@ else ...@@ -7544,12 +7545,15 @@ else
fi fi
for i in `(cd $srcdir/elements; ls | sed '/^CVS$/d;/^bsdmodule$/d;/^linuxmodule$/d;/^ns$/d;/^userlevel$/d;/^minios$/d')`; do all_element_groups=
for i in `(cd $srcdir/elements; ls | sed '/^CVS$/d;/^\.git/d;/^bsdmodule$/d;/^linuxmodule$/d;/^ns$/d;/^userlevel$/d;/^minios$/d')`; do
enableval=`eval 'echo $'"enable_$i"` enableval=`eval 'echo $'"enable_$i"`
test "x$enable_all_elements" = xyes -a "x$enableval" '!=' xno && enableval=yes test "x$enable_all_elements" = xyes -a "x$enableval" '!=' xno && enableval=yes
test -d "$srcdir/elements/$i" -a "$enableval" = "yes" && element_groups="$element_groups $i" test -d "$srcdir/elements/$i" -a "$enableval" = "yes" && element_groups="$element_groups $i"
test -d "$srcdir/elements/$i" && all_element_groups="$all_element_groups$i "
done done
FINDELEMFLAGS= FINDELEMFLAGS=
if test "x$enable_skip_elements" != xno -a "x$enable_skip_elements" != xyes; then if test "x$enable_skip_elements" != xno -a "x$enable_skip_elements" != xyes; then
FINDELEMFLAGS="-x '$enable_skip_elements'" FINDELEMFLAGS="-x '$enable_skip_elements'"
......
...@@ -617,11 +617,14 @@ ELEMENTS_ARG_ENABLE(wifi, [include wifi elements and support], NO) ...@@ -617,11 +617,14 @@ ELEMENTS_ARG_ENABLE(wifi, [include wifi elements and support], NO)
AC_ARG_ENABLE(experimental, [AS_HELP_STRING([--enable-experimental], [enable experimental elements in normal groups])], :, enable_experimental=no) AC_ARG_ENABLE(experimental, [AS_HELP_STRING([--enable-experimental], [enable experimental elements in normal groups])], :, enable_experimental=no)
AC_ARG_ENABLE(skip-elements, [AS_HELP_STRING([--enable-skip-elements=ELTS], [disable comma-separated elements])], :, enable_skip_elements=no) AC_ARG_ENABLE(skip-elements, [AS_HELP_STRING([--enable-skip-elements=ELTS], [disable comma-separated elements])], :, enable_skip_elements=no)
for i in `(cd $srcdir/elements; ls | sed '/^CVS$/d;/^bsdmodule$/d;/^linuxmodule$/d;/^ns$/d;/^userlevel$/d;/^minios$/d')`; do all_element_groups=
for i in `(cd $srcdir/elements; ls | sed '/^CVS$/d;/^\.git/d;/^bsdmodule$/d;/^linuxmodule$/d;/^ns$/d;/^userlevel$/d;/^minios$/d')`; do
enableval=`eval 'echo $'"enable_$i"` enableval=`eval 'echo $'"enable_$i"`
test "x$enable_all_elements" = xyes -a "x$enableval" '!=' xno && enableval=yes test "x$enable_all_elements" = xyes -a "x$enableval" '!=' xno && enableval=yes
test -d "$srcdir/elements/$i" -a "$enableval" = "yes" && element_groups="$element_groups $i" test -d "$srcdir/elements/$i" -a "$enableval" = "yes" && element_groups="$element_groups $i"
test -d "$srcdir/elements/$i" && all_element_groups="$all_element_groups$i "
done done
AC_SUBST([all_element_groups])
FINDELEMFLAGS= FINDELEMFLAGS=
if test "x$enable_skip_elements" != xno -a "x$enable_skip_elements" != xyes; then if test "x$enable_skip_elements" != xno -a "x$enable_skip_elements" != xyes; then
......
...@@ -89,6 +89,22 @@ doxygen: ...@@ -89,6 +89,22 @@ doxygen:
-e "s#^GENERATE_LATEX.*#GENERATE_LATEX = NO#" \ -e "s#^GENERATE_LATEX.*#GENERATE_LATEX = NO#" \
< $(srcdir)/Doxyfile | (cd $(top_srcdir); doxygen -) < $(srcdir)/Doxyfile | (cd $(top_srcdir); doxygen -)
MAN2MARKDOWN_ARGS = --xlink click.1=Userlevel --xlink click.o.8=Linuxmodule --xlink click.5=Language \
--xlink elements.n=Elements
MARKDOWN_PROVISIONS = userlevel linuxmodule ns @all_element_groups@ experimental \
smpclick int64 dpdk linux netmap pcap umultithread
install-man-markdown:
@if test -z "$(O)"; then echo 1>&2; echo "Run 'make install-man-markdown O=OUTPUTDIRECTORY'" 1>&2; echo 1>&2; false; fi
for i in click-align click-combine click-devirtualize click-fastclassifier click-flatten click-install click-mkmindriver click-pretty click-uncombine click-undead click-uninstall click-xform; do \
$(PERL) $(srcdir)/man2html --markdown -l $(MAN2MARKDOWN_ARGS) $(srcdir)/$$i.1 -d $(O) -o $(O)/$$i.md; \
done
$(PERL) $(srcdir)/man2html --markdown $(MAN2MARKDOWN_ARGS) -l $(srcdir)/click.1 -d $(O) -o $(O)/Userlevel.md
$(PERL) $(srcdir)/man2html --markdown $(MAN2MARKDOWN_ARGS) -l $(srcdir)/click.5 -d $(O) -o $(O)/Language.md
$(PERL) $(srcdir)/man2html --markdown $(MAN2MARKDOWN_ARGS) -l $(srcdir)/click.o.8 -d $(O) -o $(O)/Linuxmodule.md
$(PERL) $(srcdir)/man2html --markdown $(MAN2MARKDOWN_ARGS) -l $(srcdir)/elementdoc.7 -d $(O) -o $(O)/Elementdoc.md
echo $(MARKDOWN_PROVISIONS) | $(top_builddir)/bin/click-buildtool findelem -r "$(MARKDOWN_PROVISIONS)" -p $(top_srcdir) | $(PERL) $(top_srcdir)/click-mkelemmap -r "$(PROVISIONS)" -t "userlevel linuxmodule ns" -p "$(top_srcdir)" -Iinclude -s "`cd $(top_srcdir) && pwd`" | $(PERL) $(srcdir)/click-elem2man -d $(O) --markdown -l -p $(top_srcdir) -
always: always:
@: @:
...@@ -99,4 +115,4 @@ distclean: clean ...@@ -99,4 +115,4 @@ distclean: clean
.PHONY: all clean distclean always \ .PHONY: all clean distclean always \
install install-man uninstall uninstall-man \ install install-man uninstall uninstall-man \
doxygen doxygen install-man-markdown
...@@ -673,7 +673,7 @@ my(%markdown_podentities) = ...@@ -673,7 +673,7 @@ my(%markdown_podentities) =
'verbar' => '|', 'eq' => '=', 'star' => '*', 'lparen' => '(', 'verbar' => '|', 'eq' => '=', 'star' => '*', 'lparen' => '(',
'rparen' => ')', 'lbrack' => '[', 'rbrack' => ']', 'lbrace' => '{', 'rparen' => ')', 'lbrack' => '[', 'rbrack' => ']', 'lbrace' => '{',
'rbrace' => '}' ); 'rbrace' => '}' );
my($markdown_sensitive_char) = "[&\\[\\]#*_~&`]"; my($markdown_sensitive_char) = "[&\\[\\]#*_~`]";
my($markdown_was_short_item) = 0; my($markdown_was_short_item) = 0;
sub markdown_unentity ($) { sub markdown_unentity ($) {
...@@ -750,6 +750,10 @@ sub markdownize_text ($$) { ...@@ -750,6 +750,10 @@ sub markdownize_text ($$) {
# remove self references # remove self references
$t =~ s{\[$PrimaryElement\]\($PrimaryElement\)}{$PrimaryElement}g; $t =~ s{\[$PrimaryElement\]\($PrimaryElement\)}{$PrimaryElement}g;
# quote colons that look like emoji escapes, and numbers that look like lists
$t =~ s{:(?=[-+_a-z0-9]+:)}{\\:}ig;
$t =~ s{^(\d+)\. }{$1\\. }mg;
$t; $t;
} }
...@@ -763,9 +767,9 @@ sub markdownize ($$) { ...@@ -763,9 +767,9 @@ sub markdownize ($$) {
my(@x) = split(/(^ .*$)/m, $t); my(@x) = split(/(^ .*$)/m, $t);
my($o, $i) = ''; my($o, $i) = '';
for ($i = 0; $i < @x; $i += 2) { for ($i = 0; $i < @x; $i += 2) {
if ($x[$i]) { if ($x[$i] && $x[$i] ne "\n") {
$o .= markdownize_text($x[$i], $indent); $o .= markdownize_text($x[$i], $indent);
$o .= "\n" if $o !~ /\n\Z/; $o =~ s{\n*\z}{\n\n};
} }
if ($x[$i+1]) { if ($x[$i+1]) {
$o .= $indent . " " . $x[$i+1] . "\n"; $o .= $indent . " " . $x[$i+1] . "\n";
...@@ -804,9 +808,10 @@ sub markdown_do_section ($$$) { ...@@ -804,9 +808,10 @@ sub markdown_do_section ($$$) {
} }
if ($name eq 'head1') { if ($name eq 'head1') {
print OUT "\n## ", markdownize($args, ""), " ##\n\n"; $section_name = markdownize($args, "");
print OUT "\n", $section_name, "\n", ("-" x length($section_name)), "\n\n";
} elsif ($name eq 'head2') { } elsif ($name eq 'head2') {
print OUT "\n### ", markdownize($args, ""), " ###\n\n"; print OUT "\n### ", markdownize($args, ""), "\n\n";
} elsif ($name eq 'over') { } elsif ($name eq 'over') {
if ($args =~ /^\s*(\d+)\s*$/s) { if ($args =~ /^\s*(\d+)\s*$/s) {
push @Over, $1; push @Over, $1;
...@@ -815,18 +820,21 @@ sub markdown_do_section ($$$) { ...@@ -815,18 +820,21 @@ sub markdown_do_section ($$$) {
print STDERR "click-elem2man: $Filename: bad arguments to '=over'\n"; print STDERR "click-elem2man: $Filename: bad arguments to '=over'\n";
} }
} elsif ($name eq 'item') { } elsif ($name eq 'item') {
print OUT (" " x ($nover ? $nover - 1 : 0)), "* "; my($bullet) = (" " x ($nover ? $nover - 1 : 0)) . "* ";
my($itemtext) = markdownize($args, ""); my($itemtext) = markdownize($args, "");
if (length($itemtext) <= 40 && $text !~ /\S\n\n+\S/) { if (length($itemtext) <= 70) {
print OUT $itemtext, " — "; my($is_short_item) = $text !~ /\S\n\n+\S/;
print OUT "\n" if !$is_short_item && $markdown_was_short_item;
print OUT $bullet, $itemtext, " —\n";
$text =~ s{\A\n+}{}; $text =~ s{\A\n+}{};
$text =~ s{\n+\z}{}; if ($is_short_item) {
$closer = "\n"; $text =~ s{\n+\z}{};
$nover = 0; $closer = "\n";
$markdown_was_short_item = 1; $nover = 0;
$markdown_was_short_item = 1;
}
} else { } else {
print OUT "\n" if $markdown_was_short_item; print OUT $bullet, $itemtext, "\n\n";
print OUT $itemtext, "\n\n";
} }
} elsif ($name eq 'back') { } elsif ($name eq 'back') {
my($overarg); my($overarg);
...@@ -864,13 +872,9 @@ sub markdown_do_section ($$$) { ...@@ -864,13 +872,9 @@ sub markdown_do_section ($$$) {
$markdown_was_short_item = 0; $markdown_was_short_item = 0;
return; return;
} elsif ($name eq 'name!') { } elsif ($name eq 'name!') {
print OUT <<"EOD;"; $s = "$args Element Documentation";
# $args Element Documentation # print OUT $s, "\n", "=" x length($s), "\n\nNAME\n----\n\n",
"**$args** — $text\n";
## NAME ##
**$args** $text
EOD;
return; return;
} elsif ($name eq 'end!') { } elsif ($name eq 'end!') {
print OUT "\n\nGenerated by click-elem2man from <code>$Filename</code> on $today.\n"; print OUT "\n\nGenerated by click-elem2man from <code>$Filename</code> on $today.\n";
...@@ -886,9 +890,9 @@ sub markdown_elementlist ($@) { ...@@ -886,9 +890,9 @@ sub markdown_elementlist ($@) {
my($sec) = shift @_; my($sec) = shift @_;
my($t); my($t);
if ($sec eq "Alphabetical") { if ($sec eq "Alphabetical") {
$t = "## Alphabetically ##\n\n"; $t = "Alphabetical list\n-----------------\n\n";
} else { } else {
$t = "### $sec ###\n\n"; $t = "$sec\n" . ("-" x length($sec)) . "\n\n";
} }
foreach $_ (sort { lc($a) cmp lc($b) } @_) { foreach $_ (sort { lc($a) cmp lc($b) } @_) {
my($os) = $all_outsections{$_}; my($os) = $all_outsections{$_};
...@@ -1157,8 +1161,7 @@ sub process_comment ($$$) { ...@@ -1157,8 +1161,7 @@ sub process_comment ($$$) {
print STDERR "Uninstalled $main_outname\n" if $verbose; print STDERR "Uninstalled $main_outname\n" if $verbose;
unlink($main_outname); unlink($main_outname);
open(OUT, ">/dev/null"); open(OUT, ">/dev/null");
} elsif ($gzip ? open(OUT, "|gzip -9 >$main_outname") } elsif ($gzip ? open(OUT, "|-", "gzip -9 >'$main_outname~'") : open(OUT, ">", $main_outname . "~")) {
: open(OUT, ">$main_outname")) {
print STDERR "Writing to $main_outname\n" if $verbose; print STDERR "Writing to $main_outname\n" if $verbose;
} else { } else {
print STDERR "$main_outname: $!\n"; print STDERR "$main_outname: $!\n";
...@@ -1309,6 +1312,27 @@ sub process_comment ($$$) { ...@@ -1309,6 +1312,27 @@ sub process_comment ($$$) {
# close output file & make links if appropriate # close output file & make links if appropriate
if ($filename_func) { if ($filename_func) {
close OUT; close OUT;
if ($gzip ? open(INX, "-|", "gzcat", $main_outname) : open(INX, "<", $main_outname)) {
$gzip ? open(OUTX, "-|", "gzcat", $main_outname . "~") : open(OUTX, "<", $main_outname . "~");
local($/) = undef;
my($in) = <INX>;
my($out) = <OUTX>;
close INX;
close OUTX;
if (defined($in) && defined($out) && $in ne "" && $out ne "") {
$in =~ s{\nGenerated by click-elem2man[^\n]*\n+\z}{};
$out =~ s{\nGenerated by click-elem2man[^\n]*\n+\z}{};
if ($in eq $out) {
unlink($main_outname . "~");
print STDERR "No changes to $main_outname\n" if $verbose;
return;
}
}
}
rename("$main_outname~", $main_outname);
for ($i = 1; $i < @outfiles; $i++) { for ($i = 1; $i < @outfiles; $i++) {
my($outname) = &$filename_func($outfiles[$i], $outsections[$i], 0); my($outname) = &$filename_func($outfiles[$i], $outsections[$i], 0);
print STDERR "Unlinking $outname\n" if $verbose; print STDERR "Unlinking $outname\n" if $verbose;
...@@ -1335,7 +1359,10 @@ sub process_file ($;$) { ...@@ -1335,7 +1359,10 @@ sub process_file ($;$) {
if ($filename ne "<stdin>") { if ($filename ne "<stdin>") {
$filename = "include/$1" if !-e $filename && $filename =~ /^<(.*)>$/s; $filename = "include/$1" if !-e $filename && $filename =~ /^<(.*)>$/s;
$filename = "$PREFIX/$filename" if !-e $filename && defined($PREFIX); $filename = "$PREFIX/$filename" if !-e $filename && defined($PREFIX);
return if !-e $filename; if (!-e $filename) {
print STDERR "$filename: Not found\n";
return;
}
} }
print STDERR "Found $filename\n" if $verbose; print STDERR "Found $filename\n" if $verbose;
if (!defined($text)) { if (!defined($text)) {
...@@ -1685,9 +1712,15 @@ sub markdown_filename_func ($$$) { ...@@ -1685,9 +1712,15 @@ sub markdown_filename_func ($$$) {
if ($destroy) { if ($destroy) {
(); ();
} elsif ($sec eq $man_section) { } elsif ($sec eq $man_section) {
"$directory/" . lc($name) . ".md$gzip"; if ($name eq "elements") {
return "$directory/Elements.md$gzip";
} elsif ($name =~ /^elements-(.*)$/) {
return "$directory/" . ucfirst($1) . "-Elements.md$gzip";
} else {
return "$directory/" . $name . ".md$gzip";
}
} else { } else {
"$directory/" . lc($name) . "-$sec.md$gzip"; return "$directory/" . $name . "-$sec.md$gzip";
} }
} }
...@@ -1790,8 +1823,13 @@ sub one_summary ($@) { ...@@ -1790,8 +1823,13 @@ sub one_summary ($@) {
} }
} }
my($a) = $name; my($a) = $name;
$a =~ s{([+\&\#\"\000-\037\177-\377])}{sprintf("%%%02X", ord($1))}eg; if ($output_type eq "markdown") {
$a =~ tr/ /+/; $a =~ s{[^a-zA-Z0-9_]+}{-}g;
$a = lc($a);
} else {
$a =~ s{([+\&\#\"\000-\037\177-\377])}{sprintf("%%%02X", ord($1))}eg;
$a =~ tr/ /+/;
}
my($x) = $name; my($x) = $name;
$x =~ s{ }{&nbsp;}g; $x =~ s{ }{&nbsp;}g;
if (@elts) { if (@elts) {
...@@ -1822,7 +1860,21 @@ sub write_elementlist ($$) { ...@@ -1822,7 +1860,21 @@ sub write_elementlist ($$) {
return; return;
} }
print OUT <<"EOD;"; if ($output_type eq "markdown") {
my($title);
if ($enamebase eq "elements") {
$title = "Elements";
} elsif ($enamebase eq "elements-click") {
$title = "Click Elements";
} elsif ($enamebase =~ /^elements-(.*)$/) {
$title = ucfirst($1) . " Package Elements";
} else {
$title = ucfirst($title);
}
print OUT $title, "\n", ("=" x length($title)), "\n\n",
"This page lists Click element classes that have manual page documentation.\n\n";
} else {
print OUT <<"EOD;";
.\\" -*- mode: nroff -*- .\\" -*- mode: nroff -*-
.\\" Generated by 'click-elem2man' .\\" Generated by 'click-elem2man'
$nroff_prologue $nroff_prologue
...@@ -1832,6 +1884,7 @@ $enamebase \- documented Click element classes ...@@ -1832,6 +1884,7 @@ $enamebase \- documented Click element classes
.SH "DESCRIPTION" .SH "DESCRIPTION"
This page lists all Click element classes that have manual page documentation. This page lists all Click element classes that have manual page documentation.
EOD; EOD;
}
$Text = ""; $Text = "";
%el_generated = (); %el_generated = ();
...@@ -1848,13 +1901,18 @@ EOD; ...@@ -1848,13 +1901,18 @@ EOD;
one_summary('Miscellaneous', grep { !$el_generated{$_} } @all_outfiles); one_summary('Miscellaneous', grep { !$el_generated{$_} } @all_outfiles);
my($links) = join("&nbsp;- ", @Links); my($links) = join("&nbsp;- ", @Links);
print OUT <<"EOD;"; if ($output_type eq "markdown") {
print OUT "**By function:** ", $links, "\n\n";
print OUT "**[Alphabetical list](#alphabetical-list)**\n\n";
} else {
print OUT <<"EOD;";
.\\"html <p><a href="#BY+FUNCTION"><b>By Function</b></a>: .\\"html <p><a href="#BY+FUNCTION"><b>By Function</b></a>:
.\\"html $links<br> .\\"html $links<br>
.\\"html <a href="#ALPHABETICAL+LIST"><b>Alphabetical List</b></a></p> .\\"html <a href="#ALPHABETICAL+LIST"><b>Alphabetical List</b></a></p>
.SH \"BY FUNCTION\"
EOD; EOD;
}
print OUT ".SH \"BY FUNCTION\"\n";
print OUT $Text; print OUT $Text;
print OUT &$elementlist_func("Alphabetical", @all_outfiles); print OUT &$elementlist_func("Alphabetical", @all_outfiles);
......
This diff is collapsed.
...@@ -295,7 +295,7 @@ sub elist_file ($) { ...@@ -295,7 +295,7 @@ sub elist_file ($) {
print OUT eli($esubj[$i]); print OUT eli($esubj[$i]);
} }
} }
1 while (defined($_ = <IN>) && !/^<!-- \/clickdoc/); 1 while (defined($_ = <IN>) && !/^<!-- \/clickdoc/);
print OUT; print OUT;
} else { } else {
......
...@@ -554,5 +554,5 @@ FromDevice::add_handlers() ...@@ -554,5 +554,5 @@ FromDevice::add_handlers()
} }
#undef CLICK_FROMDEVICE_USE_BRIDGE #undef CLICK_FROMDEVICE_USE_BRIDGE
ELEMENT_REQUIRES(AnyDevice linuxmodule false) ELEMENT_REQUIRES(AnyDevice linuxmodule)
EXPORT_ELEMENT(FromDevice) EXPORT_ELEMENT(FromDevice)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment