From 5bea7cb7df2f1ca41c6b803a44f7c3a1e5a2ea39 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 10 Sep 2012 12:03:14 +0200 Subject: [PATCH] docs: generate HTML from testsuite POD documentation --- DEPENDS | 3 ++ common.mk | 1 + debian/control | 3 +- docs/docs.mk | 15 ++++++-- docs/i3-pod2html | 90 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 109 insertions(+), 3 deletions(-) create mode 100755 docs/i3-pod2html diff --git a/DEPENDS b/DEPENDS index 35a03f25..fe9ba17f 100644 --- a/DEPENDS +++ b/DEPENDS @@ -16,6 +16,7 @@ │ yajl │ 1.0.8 │ 2.0.1 │ http://lloyd.github.com/yajl/ │ │ asciidoc │ 8.3.0 │ 8.6.4 │ http://www.methods.co.nz/asciidoc/ │ │ xmlto │ 0.0.23 │ 0.0.23 │ http://www.methods.co.nz/asciidoc/ │ +│ Pod::Simple²│ 3.22 │ 3.22 │ http://search.cpan.org/~dwheeler/Pod-Simple-3.23/ │ docbook-xml │ 4.5 │ 4.5 │ http://www.methods.co.nz/asciidoc/ │ │ libxcursor │ 1.1.11 │ 1.1.11 │ http://ftp.x.org/pub/current/src/lib/ │ │ Xlib │ 1.3.3 │ 1.4.3 │ http://ftp.x.org/pub/current/src/lib/ │ @@ -25,6 +26,8 @@ │ cairo │ 1.12.2 │ 1.12.2 │ http://cairographics.org/ │ └─────────────┴────────┴────────┴────────────────────────────────────────┘ ¹ libsn = libstartup-notification + ² Pod::Simple is a Perl module required for converting the testsuite + documentation to HTML. See http://michael.stapelberg.de/cpan/#Pod::Simple i3bar, i3-msg, i3-input, i3-nagbar and i3-config-wizard do not introduce any new dependencies. diff --git a/common.mk b/common.mk index 8de425d0..bb5cf793 100644 --- a/common.mk +++ b/common.mk @@ -194,6 +194,7 @@ ifeq ($(V),0) # echo-ing vars V_ASCIIDOC = echo ASCIIDOC $@; +V_POD2HTML = echo POD2HTML $@; V_A2X = echo A2X $@; endif diff --git a/debian/control b/debian/control index 4ec5cbc8..02f00de2 100644 --- a/debian/control +++ b/debian/control @@ -21,7 +21,8 @@ Build-Depends: debhelper (>= 7.0.50~), libpcre3-dev, libstartup-notification0-dev (>= 0.10), libcairo2-dev, - libpango1.0-dev + libpango1.0-dev, + libpod-simple-perl Standards-Version: 3.9.3 Homepage: http://i3wm.org/ diff --git a/docs/docs.mk b/docs/docs.mk index 773c8322..c0daed64 100644 --- a/docs/docs.mk +++ b/docs/docs.mk @@ -2,6 +2,7 @@ DISTCLEAN_TARGETS += clean-docs # To pass additional parameters for asciidoc ASCIIDOC = asciidoc +I3POD2HTML = ./docs/i3-pod2html ASCIIDOC_NOTOC_TARGETS = \ docs/debugging.html \ @@ -23,7 +24,17 @@ ASCIIDOC_TARGETS = \ ASCIIDOC_CALL = $(V_ASCIIDOC)$(ASCIIDOC) -n $(ASCIIDOC_FLAGS) -o $@ $< ASCIIDOC_TOC_CALL = $(V_ASCIIDOC)$(ASCIIDOC) -a toc -n $(ASCIIDOC_FLAGS) -o $@ $< -docs: $(ASCIIDOC_TARGETS) +POD2HTML_TARGETS = \ + docs/lib-i3test.html \ + docs/lib-i3test-test.html + +docs/lib-i3test.html: testcases/lib/i3test.pm + $(V_POD2HTML)$(I3POD2HTML) $< $@ + +docs/lib-i3test-test.html: testcases/lib/i3test/Test.pm + $(V_POD2HTML)$(I3POD2HTML) $< $@ + +docs: $(ASCIIDOC_TARGETS) $(POD2HTML_TARGETS) $(ASCIIDOC_TOC_TARGETS): docs/%.html: docs/% $(ASCIIDOC_TOC_CALL) @@ -32,4 +43,4 @@ $(ASCIIDOC_NOTOC_TARGETS): docs/%.html: docs/% $(ASCIIDOC_CALL) clean-docs: - rm -f $(ASCIIDOC_TARGETS) + rm -f $(ASCIIDOC_TARGETS) $(POD2HTML_TARGETS) diff --git a/docs/i3-pod2html b/docs/i3-pod2html new file mode 100755 index 00000000..56a769f8 --- /dev/null +++ b/docs/i3-pod2html @@ -0,0 +1,90 @@ +#!/usr/bin/env perl +# vim:ts=4:sw=4:expandtab + +use strict; +use warnings; +use Pod::Simple::HTML; +use v5.10; + +$Pod::Simple::HTML::Tagmap{'Verbatim'} = '
';
+$Pod::Simple::HTML::Tagmap{'VerbatimFormatted'} = '
';
+$Pod::Simple::HTML::Tagmap{'/Verbatim'} = '
'; +$Pod::Simple::HTML::Tagmap{'/VerbatimFormatted'} = '
'; + +if (@ARGV < 2) { + say STDERR "Syntax: i3-pod2html "; + exit 1; +} + +open(my $in, '<', $ARGV[0]) or die "Couldn’t open $ARGV[0] for reading: $!\n"; +open(my $out, '>', $ARGV[1]) or die "Couldn’t open $ARGV[1] for writing: $!\n"; + +my $parser = Pod::Simple::HTML->new(); + +$parser->index(1); +$parser->html_header_before_title( +<<'EOF' + + + + + + + + + + +EOF +); +$parser->html_header_after_title( +<<'EOF' + + + + +
+

i3 - improved tiling WM

+ +
+
+

i3 Perl documentation (testsuite)

+ +EOF +); + +$parser->output_fh($out); +$parser->parse_file($in); -- 2.39.5