DORMANTno replies

[PATCH] Add Makefile target glossary.html

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:42:04
Subsystem: documentation, the rest · Maintainers: Jonathan Corbet, Linus Torvalds

This also includes a script which does the sorting, and introduces
hyperlinks for every described term.

Signed-off-by: Johannes Schindelin <redacted>
---

 Documentation/Makefile         |    7 +++-
 Documentation/sort_glossary.pl |   70 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/sort_glossary.pl

a080898e91dce96c5bac6f0527236e37aeedd156
diff --git a/Documentation/Makefile b/Documentation/Makefile
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1,7 +1,7 @@
 MAN1_TXT=$(wildcard git-*.txt)
 MAN7_TXT=git.txt
 
-DOC_HTML=$(patsubst %.txt,%.html,$(MAN1_TXT) $(MAN7_TXT))
+DOC_HTML=$(patsubst %.txt,%.html,$(MAN1_TXT) $(MAN7_TXT)) glossary.html
 
 DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
 DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
@@ -54,3 +54,8 @@ clean:
 %.xml : %.txt
 	asciidoc -b docbook -d manpage $<
 
+glossary.html : glossary.txt sort_glossary.pl
+	cat $< | \
+	perl sort_glossary.pl | \
+	asciidoc -b xhtml11 - > glossary.html
+
diff --git a/Documentation/sort_glossary.pl b/Documentation/sort_glossary.pl
new file mode 100644
--- /dev/null
+++ b/Documentation/sort_glossary.pl
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+
+%terms=();
+
+while(<>) {
+	if(/^(\S.*)::$/) {
+		my $term=$1;
+		if(defined($terms{$term})) {
+			die "$1 defined twice\n";
+		}
+		$terms{$term}="";
+		LOOP: while(<>) {
+			if(/^$/) {
+				last LOOP;
+			}
+			if(/^	\S/) {
+				$terms{$term}.=$_;
+			} else {
+				die "Error 1: $_";
+			}
+		}
+	}
+}
+
+sub format_tab_80 ($) {
+	my $text=$_[0];
+	my $result="";
+	$text=~s/\s+/ /g;
+	$text=~s/^\s+//;
+	while($text=~/^(.{1,72})(|\s+(\S.*)?)$/) {
+		$result.="	".$1."\n";
+		$text=$3;
+	}
+	return $result;
+}
+
+sub no_spaces ($) {
+	my $result=$_[0];
+	$result=~tr/ /_/;
+	return $result;
+}
+
+print 'GIT Glossary
+============
+Aug 2005
+
+This list is sorted alphabetically:
+
+';
+
+@keys=sort {uc($a) cmp uc($b)} keys %terms;
+$pattern='(\b'.join('\b|\b',reverse @keys).'\b)';
+foreach $key (@keys) {
+	$terms{$key}=~s/$pattern/sprintf "<<ref_".no_spaces($1).",$1>>";/eg;
+	print '[[ref_'.no_spaces($key).']]'.$key."::\n"
+		.format_tab_80($terms{$key})."\n";
+}
+
+print '
+
+Author
+------
+Written by Johannes Schindelin <Johannes.Schindelin@gmx.de> and
+the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+';
+
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help