summaryrefslogtreecommitdiffstats
path: root/doc/Tapset_Reference_Guide/publicanize.sh
blob: a97ae873856a8dafe0034e67a17323218977ca5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
INFILE="../SystemTap_Tapset_Reference/tapsets.xml"
OUTFILE="en-US/Tapset_Reference_Guide.xml"
TMPFILE=`mktemp` || exit 1
TMPFILE2=`mktemp` || exit 1

do_help()
{ 
   echo "publicanize.sh: usage:
   -?/--help        this message
   -i/--input=file  input file name
   -o/--output=file output file name
" >&2
}


#process optional arguments -i -o
while [ "$#" -ne 0 ]
do
	arg=`printf %s $1 | awk -F= '{print $1}'`
	val=`printf %s $1 | awk -F= '{print $2}'`
	shift
	if test -z "$val"; then
		local possibleval=$1
		printf %s $1 "$possibleval" | grep ^- >/dev/null 2>&1
		if test "$?" != "0"; then
			val=$possibleval
			if [ "$#" -ge 1 ]; then 
				shift
			fi
		fi
	fi

	case "$arg" in
	        -i|--input)
		   INFILE=$val
		   ;;
	        -o|--output)
		   OUTFILE=$val
		   ;;
		-\?|--help)
		   do_help
		   exit 0
		   ;;
		*)
		   echo "Unknown option \"$arg\". See opcontrol --help" >&2
		   exit 1
		   ;;
	esac
done


#copy the generated tapsets.xml 
cp $INFILE $TMPFILE || exit 1

#remove all excess whitespace
sed -i -e 's/^\s*//g' $TMPFILE

#remove marked Intro (starthere to endhere)
sed -i -e '/starthere/,/endhere/d' $TMPFILE

#re-convert programlisting tags
sed -i  -e 's/&lt;programlisting&gt;/<programlisting>/g' $TMPFILE
sed -i  -e 's/&lt;\/programlisting&gt;/<\/programlisting>/g' $TMPFILE

#replace header

cat $TMPFILE | 
perl -p -e 'undef $/;s|<bookinfo>\n<title>SystemTap Tapset Reference Manual</title>|<xi:include href="Book_Info.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />\n<xi:include href="Preface.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />|msg' | 
#perl -p -e 'undef $/;s|<authorgroup>\n<author>\n<othername>SystemTap</othername>\n<contrib>Hackers</contrib>\n</author>\n</authorgroup>||msg' |
#perl -p -e 'undef $/;s|<copyright>\n<year>2008-2009</year>\n<holder>Red Hat, Inc. and others</holder>\n</copyright>||msg' |
#perl -p -e 'undef $/;s|<legalnotice>\n<para>\nThis documentation is free software\; you can redistribute\nit and/or modify it under the terms of the GNU General Public\nLicense version 2 as published by the Free Software Foundation.\n</para>||msg' | 
#perl -p -e 'undef $/;s|<para>\nThis program is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied\nwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\n</para>||msg' | 
#perl -p -e 'undef $/;s|<para>\nYou should have received a copy of the GNU General Public\nLicense along with this program; if not, write to the Free\nSoftware Foundation, Inc., 59 Temple Place, Suite 330, Boston,\nMA 02111-1307 USA\n</para>||msg' | 
#perl -p -e 'undef $/;s|<para>\nFor more details see the file COPYING in the source\ndistribution of Linux.\n</para>\n</legalnotice>\n</bookinfo>||msg' | 
#perl -p -e 'undef $/;s|<toc></toc>||msg' | 
perl -p -e 'undef $/;s|\n\n\n\n\n\n\n\n\n\n\n\n\n\n||msg' | 
perl -p -e 'undef $/;s|\n\n\n\n\n\n\n\n\n\n\n||msg' |
perl -p -e 'undef $/;s|<programlisting>\n|<programlisting>\n<emphasis>function <\/emphasis>|msg' | 
perl -p -e 'undef $/;s|<para>\n</para>||msg' | 
perl -p -e 'undef $/;s|<para>\n\n</para>||msg' | 
perl -p -e 'undef $/;s|<para>\n<programlisting>|<programlisting>|msg' |
perl -p -e 'undef $/;s|</programlisting>\n</para>|</programlisting>|msg' > $TMPFILE2

#replace Intro with my own
perl -p -i -e 's|<!--markerforxi-->|<xi:include href="Introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />\n<xi:include href="Tapset_Dev_Guide.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />|g' $TMPFILE2

#for tapset name format section
#perl -p -i -e 'undef $/;s|<screen>\nname:return \(parameters\)\ndefinition\n</screen>|<screen>\n<replaceable>function/probe</replaceable> tapset_name:return \(parameters\)\n</screen>|msg' $TMPFILE2
#perl -p -i -e 's|<para>In this guide, tapset definitions appear in the following format:</para>|<para>In this guide, the synopsis of each tapset appears in the following format:</para>|g' $TMPFILE2
#perl -p -i -e 's|<!-- markerforxi pls dont remove -->|<xi:include href="tapsetnameformat-lastpara.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />\n<xi:include href="refentry-example.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />|g' $TMPFILE2

# statements change synopsis tags, as they are still currently unfixed in publican-redhat 
sed -i -e 's/refsynopsisdiv>/refsect1>/g' $TMPFILE2
sed -i -e 's/refsect1>/refsection>/g' $TMPFILE2
sed -i -e 's/synopsis>/programlisting>\n/g' $TMPFILE2

# re-convert tags 

sed -i  -e 's/&lt;emphasis&gt;/<emphasis>/g' $TMPFILE2
sed -i  -e 's/&lt;\/emphasis&gt;/<\/emphasis>/g' $TMPFILE2

sed -i  -e 's/&lt;remark&gt;/<remark>/g' $TMPFILE2
sed -i  -e 's/&lt;\/remark&gt;/<\/remark>/g' $TMPFILE2

sed -i  -e 's/&lt;command&gt;/<command>/g' $TMPFILE2
sed -i  -e 's/&lt;\/command&gt;/<\/command>/g' $TMPFILE2

#useful marker script; moves content between starthere and endhere to file target
#sed -n '/starthere/,/endhere/ s/.*/&/w target'  $TMPFILE2

mv $TMPFILE2 $OUTFILE
='n501' href='#n501'>501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844