File: html.awk

package info (click to toggle)
pcb-rnd 3.1.7b-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,108 kB
  • sloc: ansic: 213,400; yacc: 6,241; sh: 4,698; awk: 3,016; makefile: 2,254; lex: 1,166; python: 519; xml: 261; lisp: 154; tcl: 67; perl: 34; javascript: 6; ruby: 5
file content (117 lines) | stat: -rw-r--r-- 3,153 bytes parent folder | download | duplicates (5)
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
113
114
115
116
117
BEGIN {
	print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"
	print "<html>"
	print "<head>"
	print "<title> pcb-rnd developer manual - lihata file formats</title>"
	print "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=us-ascii\">"
	print "</head>"
	print "<body>"
}

function tbl_hdr(node, level)
{
	print "<tr><th align=left> type:name <th align=left> value <th align=left> <a href=\"#ver\">ver</a> <th align=left> description"
}

function get_valtype(node,    vt)
{
	vt = DATA[node "/valtype"]
	if (vt != "")
		vt = "<a href=" q "#valtype:" vt q ">" vt "</a>"
	else
		vt = "&nbsp;"
	return vt
}

function tbl_entry(node, level, parent     ,nm,vt,dsc,ty,vr)
{
	if (!(node in NAME)) {
		print "Error: path not found: " node > "/dev/stderr"
		return
	}
	ty = DATA[node "/type"]
	nm = get_name(node, ty, level)
	vt = get_valtype(node)
	vr = DATA[node "/ver"]
	if (vr == "") vr = "&nbsp;"
	dsc = qstrip(DATA[node "/desc"])
	print "<tr id=" q node q "><td> " nm " <td> " vt " <td> " vr " <td> " dsc
}

function tbl_entry_link(node, dst, level, parent     ,nm,vt,dsc,ty,vr)
{
	if (!(node in NAME)) {
		print "Error: path not found: " node > "/dev/stderr"
		return
	}
	if (!(dst in NAME)) {
		print "Error: path not found: " dst > "/dev/stderr"
		return
	}

	ty = DATA[dst "/type"]
	nm = get_name(node, ty, level)
	vt = get_valtype(dst)
	vr = DATA[dst "/ver"]
	if (vr == "") vr = "&nbsp;"
	dsc = qstrip(DATA[dst "/desc"])
	print "<tr id=" q node q "><td> " nm " <td> " vt " <td> " vr " <td> <a href=" q sy_href(dst) q ">" dsc " -&gt; </a>"
}

function gen_main(path,    v, n, N)
{
	print "<h3 id=" q path q ">"  DATA[path "/type"] ":" NAME[path] "</h3>"
#	print "<p>"
#	print qstrip(DATA[path "/desc"])
	print "<p>"
	print "<table border=0 cellspacing=0>"
	tbl_hdr()
	tbl_entry(path, 0)
	gen_sub(path, 1)
	print "</table>"
}

function gen_roots(rpath,    v, n, N)
{
	v = children(N, rpath)
	for(n = 1; n <= v; n++) {
		if (N[n] "/hide" in NAME)
			continue
		gen_main(N[n])
	}
}

function gen_types(path,    v, n, N, node)
{
	print "<table border=1 width=700>"
	print "<tr><th> type <th> description"

	v = children(N, path)
	for(n = 1; n <= v; n++) {
		node = N[n]
		print "<tr id=" q "valtype:" NAME[node] q ">"
		print "	<td>" NAME[node]
		print "	<td>" qstripnl(DATA[node])
	}
	print "</table>"
}


END {
	print "<h2> File format root nodes </h2>"
	print "<p>Each table below describes the full tree of one of the pcb-rnd file formats, from the root."
	gen_roots("/lht_tree_doc/roots")

	print "<h2> Common subtrees </h2>"
	print "<p>Each table below describes a subtree that usually does not specify a whole tree (thus they are usually not a valid file on their own). These subtrees are described in a separate table because they are used from multiple other trees."
	gen_roots("/lht_tree_doc/comm")

	print "<h2 id=\"types\"> Types </h2>"
	print "<p>"
	gen_types("/lht_tree_doc/types")

	print "<h2> Comments </h2>"
	print "<p id=\"ver\">ver column: <a href=\"../io_lihata_ver.html\">Format version</a> range the subtree may appear in."
	print "</body>"
	print "</html>"
}