index.adoc: auto generate tables with gen-index-includes.pl
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 20 Oct 2016 11:10:07 +0000 (13:10 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 20 Oct 2016 11:21:56 +0000 (13:21 +0200)
Makefile
gen-index-includes.pl [new file with mode: 0755]
index.adoc

index 59df401..37726b8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -66,6 +66,10 @@ pve-docs-mediawiki-import: pve-docs-mediawiki-import.in link-refs.json
 INDEX_INCLUDES=                                                                \
        pve-admin-guide.pdf                                             \
        pve-admin-guide.epub                                            \
+       chapter-index-table.adoc                                        \
+       man1-index-table.adoc                                           \
+       man5-index-table.adoc                                           \
+       man8-index-table.adoc                                           \
        $(sort $(addsuffix .html, ${MANUAL_PAGES}) ${CHAPTER_LIST})
 
 ADOC_STDARG= -b html5 -a icons -a data-uri -a "date=$(shell date)" -a "revnumber=${DOCRELEASE}"
@@ -83,7 +87,23 @@ README.html: README.adoc
 index: index.html
        $(BROWSER) index.html &
 
-index.html: index.adoc ${API_VIEWER_SOURCES} ${INDEX_INCLUDES} 
+chapter-index-table.adoc: gen-index-includes.pl
+       ./gen-index-includes.pl chapter-table >$@.tmp
+       mv $@.tmp $@
+
+man1-index-table.adoc: gen-index-includes.pl
+       ./gen-index-includes.pl man1page-table >$@.tmp
+       mv $@.tmp $@
+
+man5-index-table.adoc: gen-index-includes.pl
+       ./gen-index-includes.pl man5page-table >$@.tmp
+       mv $@.tmp $@
+
+man8-index-table.adoc: link-refs.json gen-index-includes.pl
+       ./gen-index-includes.pl man8page-table >$@.tmp
+       mv $@.tmp $@
+
+index.html: index.adoc ${API_VIEWER_SOURCES} ${INDEX_INCLUDES}
        asciidoc ${ADOC_STDARG} -o $@ index.adoc
 
 pve-admin-guide.html: ${PVE_ADMIN_GUIDE_ADOCDEPENDS}
@@ -158,5 +178,5 @@ update: clean
        make all
 
 clean: 
-       rm -rf *.html *.pdf *.epub *.tmp *.1 *.5 *.8 *.deb *.changes build api-viewer/apidoc.js chapter-*.html *-plain.html chapter-*.html pve-admin-guide.chunked asciidoc-pve link-refs.json .asciidoc-pve-tmp_* pve-docs-mediawiki-import .pve-doc-depends pve-doc-generator.mk
+       rm -rf *.html *.pdf *.epub *.tmp *.1 *.5 *.8 *.deb *.changes build api-viewer/apidoc.js chapter-*.html *-plain.html chapter-*.html pve-admin-guide.chunked asciidoc-pve link-refs.json .asciidoc-pve-tmp_* pve-docs-mediawiki-import .pve-doc-depends pve-doc-generator.mk chapter-index-table.adoc man1-index-table.adoc man5-index-table.adoc man8-index-table.adoc
        find . -name '*~' -exec rm {} ';'
diff --git a/gen-index-includes.pl b/gen-index-includes.pl
new file mode 100755 (executable)
index 0000000..d693536
--- /dev/null
@@ -0,0 +1,60 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use JSON;
+use IO::File;
+use Data::Dumper;
+
+my $fh = IO::File->new("link-refs.json", "r") ||
+    die "unable to open 'link-refs.json' - $!\n";
+
+my $data_str = "";
+while (<$fh>) { $data_str .= $_; }
+my $fileinfo = decode_json($data_str);
+
+my $cmd = shift;
+
+die "missing command name" if !$cmd;
+die "too many arguments" if scalar(@ARGV);
+
+
+#print Dumper($fileinfo);
+
+if ($cmd eq 'chapter-table') {
+    print '[width="100%",options="header"]' . "\n";
+    print "|====\n";
+    print "|Title|Link\n";
+    my $filelist = $fileinfo->{outfile}->{default};
+    foreach my $sourcefile (sort keys %$filelist) {
+       my $target = $filelist->{$sourcefile};
+       next if $target eq 'pve-admin-guide.html';
+       my $title = $fileinfo->{titles}->{default}->{$sourcefile} ||
+           die "not title for '$sourcefile'";
+       print "|$title|link:$target\[\]\n";
+    }
+    print "|====\n";
+
+} elsif ($cmd =~ m/^man([158])page-table$/) {
+    my $section = $1;
+    print '[width="100%",cols="5*d",options="header"]' . "\n";
+    print "|====\n";
+    print "|Name 3+|Title|Link\n";
+    my $filelist = $fileinfo->{outfile}->{manvolnum};
+    foreach my $manpage (sort keys %$filelist) {
+       next if $section ne $fileinfo->{mansection}->{manvolnum}->{$manpage};
+       my $mantitle = $fileinfo->{titles}->{manvolnum}->{$manpage} ||
+           die "not manual title for '$manpage'";
+       my $title = $fileinfo->{titles}->{default}->{$manpage} ||
+           die "not title for '$manpage'";
+
+       # hack - remove command name prefix from titles
+       $title =~ s/^[a-z]+\s*-\s*//;
+       
+       my $target = $filelist->{$manpage};
+       print "|$mantitle 3+|$title|link:$target.html\[$target\]\n\n";
+    }  
+    print "|====\n";
+} else {
+    die "unknown command '$cmd'\n";
+}
index 27e3486..65feec0 100644 (file)
@@ -20,23 +20,8 @@ include::attributes.txt[]
 
 Individual Chapters
 -------------------
-[width="100%",options="header"]
-|===========================================================
-|Title                                |Link
-|Installation                        |link:chapter-pve-installation.html[]
-|Host System Administration           |link:chapter-sysadmin.html[]
-|Cluster Manager                      |link:chapter-pvecm.html[]
-|Proxmox Cluster File System (pmxcfs) |link:chapter-pmxcfs.html[]
-|{pve} Storage                        |link:chapter-pvesm.html[]
-|Qemu/KVM Virtual Machines            |link:chapter-qm.html[]
-|Proxmox Container Toolkit            |link:chapter-pct.html[]
-|{pve} Firewall                       |link:chapter-pve-firewall.html[]
-|User Management                      |link:chapter-pveum.html[]
-|High Availability                    |link:chapter-ha-manager.html[]
-|Backup and Restore                   |link:chapter-vzdump.html[]
-|Frequently Asked Questions           |link:chapter-pve-faq.html[]
-|Bibliography                         |link:chapter-pve-bibliography.html[]
-|===========================================================
+
+include::chapter-index-table.adoc[]
 
 
 {pve} Manual Pages
@@ -45,51 +30,19 @@ Individual Chapters
 Command Line Interface
 ~~~~~~~~~~~~~~~~~~~~~~
 
-[width="100%",options="header"]
-|===========================================================
-| Command name    | Link
-| qm              | link:qm.1.html[qm.1]
-| qmrestore       | link:qmrestore.1.html[qmrestore.1]
-| pct             | link:pct.1.html[pct.1]
-| pveam           | link:pveam.1.html[pveam.1]
-| pveceph         | link:pveceph.1.html[pveceph.1]
-| pvecm           | link:pvecm.1.html[pvecm.1]
-| pveum           | link:pveum.1.html[pveum.1]
-| pvesm           | link:pvesm.1.html[pvesm.1]
-| pvesubscription | link:pvesubscription.1.html[pvesubscription.1]
-| pveperf         | link:pveperf.1.html[pveperf.1]
-| vzdump          | link:vzdump.1.html[vzdump.1]
-| ha-manager      | link:ha-manager.1.html[ha-manager.1]
-|===========================================================
+include::man1-index-table.adoc[]
 
 
 Service Daemons
 ~~~~~~~~~~~~~~~
 
-[width="100%",options="header"]
-|===========================================================
-| Command name |'systemd' Service     | Link
-| pvedaemon    | pvedaemon.service    |link:pvedaemon.8.html[pvedaemon.8]
-| pveproxy     | pveproxy.service     |link:pveproxy.8.html[pveproxy.8]
-| pvestatd     | pvestatd.service     |link:pvestatd.8.html[pvestatd.8]
-| spiceproxy   | spiceproxy.service   |link:spiceproxy.8.html[spiceproxy.8]
-| pve-ha-crm   | pve-ha-crm.service   |link:pve-ha-crm.8.html[pve-ha-crm.8]
-| pve-ha-lrm   | pve-ha-lrm.service   |link:pve-ha-lrm.8.html[pve-ha-lrm.8]
-| pve-firewall | pve-firewall.service |link:pve-firewall.8.html[pve-firewall.8]
-| pmxcfs       | pve-cluster.service  |link:pmxcfs.8.html[pmxcfs.8]
-|===========================================================
+include::man8-index-table.adoc[]
 
 
 Configuration Options
 ~~~~~~~~~~~~~~~~~~~~~
 
-[width="100%",options="header"]
-|===========================================================
-| File name |Link
-| `/etc/pve/datacenter.cfg`          | link:datacenter.cfg.5.html[datacenter.cfg.5]
-| `/etc/pve/qemu-server/<VMID>.conf` | link:qm.conf.5.html[qm.conf.5]
-| `/etc/pve/lxc/<CTID>.conf`         | link:pct.conf.5.html[pct.conf.5]
-|===========================================================
+include::man5-index-table.adoc[]
 
 
 API Viewer