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
freebsd_includedir
freebsd_srcdir
FINDELEMFLAGS
all_element_groups
element_groups
linux_srcdir
linux_builddir
......@@ -7544,12 +7545,15 @@ else
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"`
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" && all_element_groups="$all_element_groups$i "
done
FINDELEMFLAGS=
if test "x$enable_skip_elements" != xno -a "x$enable_skip_elements" != xyes; then
FINDELEMFLAGS="-x '$enable_skip_elements'"
......
......@@ -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(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"`
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" && all_element_groups="$all_element_groups$i "
done
AC_SUBST([all_element_groups])
FINDELEMFLAGS=
if test "x$enable_skip_elements" != xno -a "x$enable_skip_elements" != xyes; then
......
......@@ -89,6 +89,22 @@ doxygen:
-e "s#^GENERATE_LATEX.*#GENERATE_LATEX = NO#" \
< $(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:
@:
......@@ -99,4 +115,4 @@ distclean: clean
.PHONY: all clean distclean always \
install install-man uninstall uninstall-man \
doxygen
doxygen install-man-markdown
......@@ -673,7 +673,7 @@ my(%markdown_podentities) =
'verbar' => '|', 'eq' => '=', 'star' => '*', 'lparen' => '(',
'rparen' => ')', 'lbrack' => '[', 'rbrack' => ']', 'lbrace' => '{',
'rbrace' => '}' );
my($markdown_sensitive_char) = "[&\\[\\]#*_~&`]";
my($markdown_sensitive_char) = "[&\\[\\]#*_~`]";
my($markdown_was_short_item) = 0;
sub markdown_unentity ($) {
......@@ -750,6 +750,10 @@ sub markdownize_text ($$) {
# remove self references
$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;
}
......@@ -763,9 +767,9 @@ sub markdownize ($$) {
my(@x) = split(/(^ .*$)/m, $t);
my($o, $i) = '';
for ($i = 0; $i < @x; $i += 2) {
if ($x[$i]) {
if ($x[$i] && $x[$i] ne "\n") {
$o .= markdownize_text($x[$i], $indent);
$o .= "\n" if $o !~ /\n\Z/;
$o =~ s{\n*\z}{\n\n};
}
if ($x[$i+1]) {
$o .= $indent . " " . $x[$i+1] . "\n";
......@@ -804,9 +808,10 @@ sub markdown_do_section ($$$) {
}
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') {
print OUT "\n### ", markdownize($args, ""), " ###\n\n";
print OUT "\n### ", markdownize($args, ""), "\n\n";
} elsif ($name eq 'over') {
if ($args =~ /^\s*(\d+)\s*$/s) {
push @Over, $1;
......@@ -815,18 +820,21 @@ sub markdown_do_section ($$$) {
print STDERR "click-elem2man: $Filename: bad arguments to '=over'\n";
}
} elsif ($name eq 'item') {
print OUT (" " x ($nover ? $nover - 1 : 0)), "* ";
my($bullet) = (" " x ($nover ? $nover - 1 : 0)) . "* ";
my($itemtext) = markdownize($args, "");
if (length($itemtext) <= 40 && $text !~ /\S\n\n+\S/) {
print OUT $itemtext, " — ";
if (length($itemtext) <= 70) {
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+}{};
if ($is_short_item) {
$text =~ s{\n+\z}{};
$closer = "\n";
$nover = 0;
$markdown_was_short_item = 1;
}
} else {
print OUT "\n" if $markdown_was_short_item;
print OUT $itemtext, "\n\n";
print OUT $bullet, $itemtext, "\n\n";
}
} elsif ($name eq 'back') {
my($overarg);
......@@ -864,13 +872,9 @@ sub markdown_do_section ($$$) {
$markdown_was_short_item = 0;
return;
} elsif ($name eq 'name!') {
print OUT <<"EOD;";
# $args Element Documentation #
## NAME ##
**$args** $text
EOD;
$s = "$args Element Documentation";
print OUT $s, "\n", "=" x length($s), "\n\nNAME\n----\n\n",
"**$args** — $text\n";
return;
} elsif ($name eq 'end!') {
print OUT "\n\nGenerated by click-elem2man from <code>$Filename</code> on $today.\n";
......@@ -886,9 +890,9 @@ sub markdown_elementlist ($@) {
my($sec) = shift @_;
my($t);
if ($sec eq "Alphabetical") {
$t = "## Alphabetically ##\n\n";
$t = "Alphabetical list\n-----------------\n\n";
} else {
$t = "### $sec ###\n\n";
$t = "$sec\n" . ("-" x length($sec)) . "\n\n";
}
foreach $_ (sort { lc($a) cmp lc($b) } @_) {
my($os) = $all_outsections{$_};
......@@ -1157,8 +1161,7 @@ sub process_comment ($$$) {
print STDERR "Uninstalled $main_outname\n" if $verbose;
unlink($main_outname);
open(OUT, ">/dev/null");
} elsif ($gzip ? open(OUT, "|gzip -9 >$main_outname")
: open(OUT, ">$main_outname")) {
} elsif ($gzip ? open(OUT, "|-", "gzip -9 >'$main_outname~'") : open(OUT, ">", $main_outname . "~")) {
print STDERR "Writing to $main_outname\n" if $verbose;
} else {
print STDERR "$main_outname: $!\n";
......@@ -1309,6 +1312,27 @@ sub process_comment ($$$) {
# close output file & make links if appropriate
if ($filename_func) {
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++) {
my($outname) = &$filename_func($outfiles[$i], $outsections[$i], 0);
print STDERR "Unlinking $outname\n" if $verbose;
......@@ -1335,7 +1359,10 @@ sub process_file ($;$) {
if ($filename ne "<stdin>") {
$filename = "include/$1" if !-e $filename && $filename =~ /^<(.*)>$/s;
$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;
if (!defined($text)) {
......@@ -1685,9 +1712,15 @@ sub markdown_filename_func ($$$) {
if ($destroy) {
();
} 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 {
"$directory/" . lc($name) . "-$sec.md$gzip";
return "$directory/" . $name . ".md$gzip";
}
} else {
return "$directory/" . $name . "-$sec.md$gzip";
}
}
......@@ -1790,8 +1823,13 @@ sub one_summary ($@) {
}
}
my($a) = $name;
if ($output_type eq "markdown") {
$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;
$x =~ s{ }{&nbsp;}g;
if (@elts) {
......@@ -1822,6 +1860,20 @@ sub write_elementlist ($$) {
return;
}
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 -*-
.\\" Generated by 'click-elem2man'
......@@ -1832,6 +1884,7 @@ $enamebase \- documented Click element classes
.SH "DESCRIPTION"
This page lists all Click element classes that have manual page documentation.
EOD;
}
$Text = "";
%el_generated = ();
......@@ -1848,13 +1901,18 @@ EOD;
one_summary('Miscellaneous', grep { !$el_generated{$_} } @all_outfiles);
my($links) = join("&nbsp;- ", @Links);
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 $links<br>
.\\"html <a href="#ALPHABETICAL+LIST"><b>Alphabetical List</b></a></p>
.SH \"BY FUNCTION\"
EOD;
}
print OUT ".SH \"BY FUNCTION\"\n";
print OUT $Text;
print OUT &$elementlist_func("Alphabetical", @all_outfiles);
......
This diff is collapsed.
......@@ -554,5 +554,5 @@ FromDevice::add_handlers()
}
#undef CLICK_FROMDEVICE_USE_BRIDGE
ELEMENT_REQUIRES(AnyDevice linuxmodule false)
ELEMENT_REQUIRES(AnyDevice linuxmodule)
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