Documentation / sort_glossary.plon commit git-commit: document --amend (ae5d847)
   1#!/usr/bin/perl
   2
   3%terms=();
   4
   5while(<>) {
   6        if(/^(\S.*)::$/) {
   7                my $term=$1;
   8                if(defined($terms{$term})) {
   9                        die "$1 defined twice\n";
  10                }
  11                $terms{$term}="";
  12                LOOP: while(<>) {
  13                        if(/^$/) {
  14                                last LOOP;
  15                        }
  16                        if(/^   \S/) {
  17                                $terms{$term}.=$_;
  18                        } else {
  19                                die "Error 1: $_";
  20                        }
  21                }
  22        }
  23}
  24
  25sub format_tab_80 ($) {
  26        my $text=$_[0];
  27        my $result="";
  28        $text=~s/\s+/ /g;
  29        $text=~s/^\s+//;
  30        while($text=~/^(.{1,72})(|\s+(\S.*)?)$/) {
  31                $result.="      ".$1."\n";
  32                $text=$3;
  33        }
  34        return $result;
  35}
  36
  37sub no_spaces ($) {
  38        my $result=$_[0];
  39        $result=~tr/ /_/;
  40        return $result;
  41}
  42
  43print 'GIT Glossary
  44============
  45
  46This list is sorted alphabetically:
  47
  48';
  49
  50@keys=sort {uc($a) cmp uc($b)} keys %terms;
  51$pattern='(\b'.join('\b|\b',reverse @keys).'\b)';
  52foreach $key (@keys) {
  53        $terms{$key}=~s/$pattern/sprintf "<<ref_".no_spaces($1).",$1>>";/eg;
  54        print '[[ref_'.no_spaces($key).']]'.$key."::\n"
  55                .format_tab_80($terms{$key})."\n";
  56}
  57
  58print '
  59
  60Author
  61------
  62Written by Johannes Schindelin <Johannes.Schindelin@gmx.de> and
  63the git-list <git@vger.kernel.org>.
  64
  65GIT
  66---
  67Part of the link:git.html[git] suite
  68';
  69