[FFmpeg-devel] [PATCH 1/2] Use makeinfo to generate html doc for the new website
Timothy Gu
timothygu99 at gmail.com
Sat Jul 19 19:58:12 CEST 2014
texi2html is deprecated by upstream in favor of makeinfo/texi2any. See:
- https://www.gnu.org/software/texinfo/manual/texinfo/html_node/texi2html.html
- https://wiki.debian.org/Texi2htmlTransition
- https://lists.debian.org/debian-devel/2013/05/msg01516.html
This is actually two separate changes. But as makeinfo and texi2html
adopt 2 (very) different init file syntaxes, it is easier to do the two
transitions at once.
Based on a patch by Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>.
Fixes Trac ticket #3232.
Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
---
configure | 3 +-
doc/Makefile | 8 +--
doc/platform.texi | 2 +-
doc/t2h.init | 115 --------------------------------
doc/t2h.pm | 193 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 199 insertions(+), 122 deletions(-)
delete mode 100644 doc/t2h.init
create mode 100644 doc/t2h.pm
diff --git a/configure b/configure
index 742dfe1..3f635ad 100755
--- a/configure
+++ b/configure
@@ -2607,7 +2607,7 @@ ffserver_select="ffm_muxer rtp_protocol rtsp_demuxer"
# documentation
podpages_deps="perl"
manpages_deps="perl pod2man"
-htmlpages_deps="perl texi2html"
+htmlpages_deps="perl makeinfo"
txtpages_deps="perl makeinfo"
doc_deps_any="manpages htmlpages podpages txtpages"
@@ -4844,7 +4844,6 @@ else
fi
enabled sdl && add_cflags $sdl_cflags && add_extralibs $sdl_libs
-texi2html --help 2> /dev/null | grep -q 'init-file' && enable texi2html || disable texi2html
makeinfo --version > /dev/null 2>&1 && enable makeinfo || disable makeinfo
perl -v > /dev/null 2>&1 && enable perl || disable perl
pod2man --help > /dev/null 2>&1 && enable pod2man || disable pod2man
diff --git a/doc/Makefile b/doc/Makefile
index 99f588a..8eb1d5d 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -80,14 +80,14 @@ $(GENTEXI): doc/avoptions_%.texi: doc/print_options$(HOSTEXESUF)
$(M)doc/print_options $* > $@
doc/%.html: TAG = HTML
-doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.init $(GENTEXI)
+doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.pm $(GENTEXI)
$(Q)$(TEXIDEP)
- $(M)texi2html -I doc -monolithic --D=config-not-all --init-file $(SRC_PATH)/doc/t2h.init --output $@ $<
+ $(M)makeinfo --html -I doc --no-split -D config-not-all --init-file=$(SRC_PATH)/doc/t2h.pm --output $@ $<
doc/%-all.html: TAG = HTML
-doc/%-all.html: doc/%.texi $(SRC_PATH)/doc/t2h.init $(GENTEXI)
+doc/%-all.html: doc/%.texi $(SRC_PATH)/doc/t2h.pm $(GENTEXI)
$(Q)$(TEXIDEP)
- $(M)texi2html -I doc -monolithic --D=config-all --init-file $(SRC_PATH)/doc/t2h.init --output $@ $<
+ $(M)makeinfo --html -I doc --no-split -D config-all --init-file=$(SRC_PATH)/doc/t2h.pm --output $@ $<
doc/%.pod: TAG = POD
doc/%.pod: doc/%.texi $(SRC_PATH)/doc/texi2pod.pl $(GENTEXI)
diff --git a/doc/platform.texi b/doc/platform.texi
index c71121f..b529500 100644
--- a/doc/platform.texi
+++ b/doc/platform.texi
@@ -275,7 +275,7 @@ llrint() in its C library.
Install your Cygwin with all the "Base" packages, plus the
following "Devel" ones:
@example
-binutils, gcc4-core, make, git, mingw-runtime, texi2html
+binutils, gcc4-core, make, git, mingw-runtime, texinfo
@end example
In order to run FATE you will also need the following "Utils" packages:
diff --git a/doc/t2h.init b/doc/t2h.init
deleted file mode 100644
index e7760f4..0000000
--- a/doc/t2h.init
+++ /dev/null
@@ -1,115 +0,0 @@
-# no horiz rules between sections
-$end_section = \&FFmpeg_end_section;
-sub FFmpeg_end_section($$)
-{
-}
-
-$EXTRA_HEAD =
-'<link rel="icon" href="favicon.png" type="image/png" />
-';
-
-$CSS_LINES = $ENV{"FFMPEG_CSS"} || <<EOT;
-<link rel="stylesheet" type="text/css" href="default.css" />
-EOT
-
-my $TEMPLATE_HEADER = $ENV{"FFMPEG_HEADER"} || <<EOT;
-<link rel="icon" href="favicon.png" type="image/png" />
-</head>
-<body>
-<div id="container">
-<div id="body">
-EOT
-
-$PRE_BODY_CLOSE = '</div></div>';
-
-$SMALL_RULE = '';
-$BODYTEXT = '';
-
-$print_page_foot = \&FFmpeg_print_page_foot;
-sub FFmpeg_print_page_foot($$)
-{
- my $fh = shift;
- my $program_string = defined &T2H_DEFAULT_program_string ?
- T2H_DEFAULT_program_string() : program_string();
- print $fh '<footer class="footer pagination-right">' . "\n";
- print $fh '<span class="label label-info">' . $program_string;
- print $fh "</span></footer></div></div></body>\n";
-}
-
-$float = \&FFmpeg_float;
-
-sub FFmpeg_float($$$$)
-{
- my $text = shift;
- my $float = shift;
- my $caption = shift;
- my $shortcaption = shift;
-
- my $label = '';
- if (exists($float->{'id'}))
- {
- $label = &$anchor($float->{'id'});
- }
- my $class = '';
- my $subject = '';
-
- if ($caption =~ /NOTE/)
- {
- $class = "alert alert-info";
- }
- elsif ($caption =~ /IMPORTANT/)
- {
- $class = "alert alert-warning";
- }
-
- return '<div class="float ' . $class . '">' . "$label\n" . $text . '</div>';
-}
-
-$print_page_head = \&FFmpeg_print_page_head;
-sub FFmpeg_print_page_head($$)
-{
- my $fh = shift;
- my $longtitle = "$Texi2HTML::THISDOC{'fulltitle_no_texi'}";
- $longtitle .= ": $Texi2HTML::NO_TEXI{'This'}" if exists $Texi2HTML::NO_TEXI{'This'};
- my $description = $DOCUMENT_DESCRIPTION;
- $description = $longtitle if (!defined($description));
- $description = "<meta name=\"description\" content=\"$description\">" if
- ($description ne '');
- $description = $Texi2HTML::THISDOC{'documentdescription'} if (defined($Texi2HTML::THISDOC{'documentdescription'}));
- my $encoding = '';
- $encoding = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$ENCODING\">" if (defined($ENCODING) and ($ENCODING ne ''));
- $longtitle =~ s/Documentation.*//g;
- $longtitle = "FFmpeg documentation : " . $longtitle;
-
- print $fh <<EOT;
-<!DOCTYPE html>
-<html>
-$Texi2HTML::THISDOC{'copying'}<!-- Created on $Texi2HTML::THISDOC{today} by $Texi2HTML::THISDOC{program} -->
-<!--
-$Texi2HTML::THISDOC{program_authors}
--->
-<head>
-<title>$longtitle</title>
-
-$description
-<meta name="keywords" content="$longtitle">
-<meta name="Generator" content="$Texi2HTML::THISDOC{program}">
-$encoding
-$CSS_LINES
-$TEMPLATE_HEADER
-EOT
-}
-
-# declare encoding in header
-$IN_ENCODING = $ENCODING = "utf-8";
-
-# no navigation elements
-$SECTION_NAVIGATION = 0;
-# the same for texi2html 5.0
-$HEADERS = 0;
-
-# TOC and Chapter headings link
-$TOC_LINKS = 1;
-
-# print the TOC where @contents is used
-$INLINE_CONTENTS = 1;
diff --git a/doc/t2h.pm b/doc/t2h.pm
new file mode 100644
index 0000000..c2fc263
--- /dev/null
+++ b/doc/t2h.pm
@@ -0,0 +1,193 @@
+# makeinfo HTML output init file
+#
+# Copyright (c) 2014 Andreas Cadhalpun
+# Copyright (c) 2014 Tiancheng "Timothy" Gu
+#
+# This file is part of FFmpeg.
+#
+# FFmpeg is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# FFmpeg is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with FFmpeg; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# Add an icon and stylesheet. We don't use 'CSS_LINES' in addition to
+# EXTRA_HEAD because it's easier to maintain this way.
+set_from_init_file('EXTRA_HEAD',
+ $ENV{"FFMPEG_EXTRA_HEAD"} || '
+ <link rel="icon" href="favicon.png" type="image/png">
+ <link rel="stylesheet" type="text/css" href="style.min.css">
+ ');
+set_from_init_file('CSS_LINES', undef);
+
+# Add additional div's at the beginning of the body and close them before the end.
+set_from_init_file('AFTER_BODY_OPEN',
+ $ENV{"FFMPEG_AFTER_BODY_OPEN"} || '
+ <div style="width: 95%; margin: auto">
+ ');
+
+set_from_init_file('PRE_BODY_CLOSE',
+ $ENV{"FFMPEG_PRE_BODY_CLOSE"} ||
+ '</div>');
+
+# empty body text
+set_from_init_file('BODYTEXT', '');
+
+# Write the creation time in the footer.
+set_from_init_file('PROGRAM_NAME_IN_FOOTER', "+");
+
+# no navigation elements
+set_from_init_file('HEADERS', 0);
+
+# TOC and Chapter headings link
+set_from_init_file('TOC_LINKS', 1);
+
+# print the TOC where @contents is used
+set_from_init_file('INLINE_CONTENTS', 1);
+
+# make chapters <h2>
+set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
+
+# Do not add <hr>
+set_from_init_file('DEFAULT_RULE', '');
+set_from_init_file('BIG_RULE', '');
+
+# Customized title command
+set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
+sub ffmpeg_title ($$$$)
+{
+ my $self = shift;
+ my $cmdname = shift;
+ my $command = shift;
+ my $args = shift;
+ my $result = "
+ <header class=\"content-header\">
+ <h1>";
+ $result .= $ENV{"FFMPEG_BEFORE_TITLE"} if $ENV{"FFMPEG_BEFORE_TITLE"};
+ $result .= "
+ $$args[0]->{'normal'}
+ </h1>
+ </header>";
+
+ # Extra </div> and <div> needed to counter the <div> automatically added
+ # by makeinfo
+ $result .= '</div>' . $ENV{"FFMPEG_AFTER_HEADER"} . '<div>'
+ if $ENV{"FFMPEG_AFTER_HEADER"};
+ return $result;
+}
+
+texinfo_register_command_formatting('titlefont',
+ \&ffmpeg_title);
+
+# Customized float command. Part of code borrowed from GNU Texinfo.
+sub ffmpeg_float($$$$$)
+{
+ my $self = shift;
+ my $cmdname = shift;
+ my $command = shift;
+ my $args = shift;
+ my $content = shift;
+
+ my ($caption, $prepended) = Texinfo::Common::float_name_caption($self,
+ $command);
+ my $caption_text = '';
+ my $prepended_text;
+ my $prepended_save = '';
+
+ if ($self->in_string()) {
+ if ($prepended) {
+ $prepended_text = $self->convert_tree_new_formatting_context(
+ $prepended, 'float prepended');
+ } else {
+ $prepended_text = '';
+ }
+ if ($caption) {
+ $caption_text = $self->convert_tree_new_formatting_context(
+ {'contents' => $caption->{'args'}->[0]->{'contents'}},
+ 'float caption');
+ }
+ return $prepended.$content.$caption_text;
+ }
+
+ my $id = $self->command_id($command);
+ my $label;
+ if (defined($id) and $id ne '') {
+ $label = "<a name=\"$id\"></a>";
+ } else {
+ $label = '';
+ }
+
+ if ($prepended) {
+ if ($caption) {
+ # prepend the prepended tree to the first paragraph
+ my @caption_original_contents = @{$caption->{'args'}->[0]->{'contents'}};
+ my @caption_contents;
+ my $new_paragraph;
+ while (@caption_original_contents) {
+ my $content = shift @caption_original_contents;
+ if ($content->{'type'} and $content->{'type'} eq 'paragraph') {
+ %{$new_paragraph} = %{$content};
+ $new_paragraph->{'contents'} = [@{$content->{'contents'}}];
+ unshift (@{$new_paragraph->{'contents'}}, {'cmdname' => 'strong',
+ 'args' => [{'type' => 'brace_command_arg',
+ 'contents' => [$prepended]}]});
+ push @caption_contents, $new_paragraph;
+ last;
+ } else {
+ push @caption_contents, $content;
+ }
+ }
+ push @caption_contents, @caption_original_contents;
+ if ($new_paragraph) {
+ $caption_text = $self->convert_tree_new_formatting_context(
+ {'contents' => \@caption_contents}, 'float caption');
+ $prepended_text = '';
+ }
+ }
+ if ($caption_text eq '') {
+ $prepended_text = $self->convert_tree_new_formatting_context(
+ $prepended, 'float prepended');
+ if ($prepended_text ne '') {
+ $prepended_save = $prepended_text;
+ $prepended_text = '<p><strong>'.$prepended_text.'</strong></p>';
+ }
+ }
+ } else {
+ $prepended_text = '';
+ }
+
+ if ($caption and $caption_text eq '') {
+ $caption_text = $self->convert_tree_new_formatting_context(
+ $caption->{'args'}->[0], 'float caption');
+ }
+ if ($prepended_text.$caption_text ne '') {
+ $prepended_text = $self->_attribute_class('div','float-caption'). '>'
+ . $prepended_text;
+ $caption_text .= '</div>';
+ }
+ my $html_class = '';
+ if ($prepended_save =~ /NOTE/) {
+ $html_class = 'info';
+ $prepended_text = '';
+ $caption_text = '';
+ } elsif ($prepended_save =~ /IMPORTANT/) {
+ $html_class = 'warning';
+ $prepended_text = '';
+ $caption_text = '';
+ }
+ return $self->_attribute_class('div', $html_class). '>' . "\n" .
+ $prepended_text . $caption_text . $content . '</div>';
+}
+
+texinfo_register_command_formatting('float',
+ \&ffmpeg_float);
+
+1;
\ No newline at end of file
--
1.9.1
More information about the ffmpeg-devel
mailing list