summaryrefslogtreecommitdiff
path: root/rtems_waf/docs.py
blob: afa251035f594e51b7258db8f11bec64a315fd71 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from bsp import list_bsp
from rtems_waf.config.base import config_list


def header():
	return """
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">

  <title>List of RTEMS BSP Options</title>
  <meta name="Description" content="List of options for RTEMS BSPs">
  <meta name="Keywords" content="RTEMS, BSP, sparc, intel, mips"/>
  <meta name="Author" content="http://www.rtems.org/"/>
  <style>
#download table {
	border-spacing: 3px;
	border-style: outset outset outset outset;
	border-width: 1px 1px 1px 1px;
	background-color: #dcfdc4;
	border-color: black black black black;
	border-collapse: collapse;
}

#download table th {
	background-color: 6c945a;
}

h1, h2, h3, h4 {
	font: bold 1.5em/1.5em sans serif;
	color: #444;
}

  </style>
  <meta name="Copyright" content="Copyright (C) 2015 RTEMS Project"/>
</head>

<body>
<div id='download'>
	"""


def footer():
	return """
</div>
</body>
</html>
	"""


TABLE_START = """
<table style='round' border='1' cellpadding='5'>
<tr align='center'><th>Option</th><th nowrap='nowrap'>Default Value</th><th>Description</th></tr>
"""

TABLE_END = """
</table>
"""

TABLE_ROW ="""
<tr valign='top'>
  <td align='left'>%s</td>
  <td align='left' valign='top'>%s</td>
  <td align='left' align='top'>%s</td>
</tr>
"""

BSP_HEADING = """
<br/>
<hr size='1'>
<h2>%s</h2>
"""

TABLE_HEADING = """
<br/>
<b>%s</b>
"""


def rtems_cmd_docs(ctx):
	fp = open(ctx.options.file_out, "w")
	fp.write(header())

	full = []
	for arch in list_bsp:
		full.append(arch)
		for bsp in list_bsp[arch]:
			full.append("%s/%s" % (arch, bsp))

	all = ["general", "host"] + sorted(full)

	def cfg_get(entry):
		for config in config_list:
			if config.name == entry:
				return config
#		raise Exception("Not found %s" % entry) # XXX: Because not all BSPs are added.

	for entry in all:
		cfg = cfg_get(entry)

		if cfg == None:
			continue # XXX: Hack because not all BSPs are added.
#		print cfg.name, cfg

		c = cfg()

		fp.write(BSP_HEADING % c.name)
		def print_opt(name, values):
			if not list(values):
				return

			fp.write(TABLE_HEADING % "%s Options" % name)
			fp.write(TABLE_START)
			for option in values:
				opt = values[option]
				if type(opt.value) is list:
					value = " ".join(opt.value)
				else:
					value = opt.value
				fp.write(TABLE_ROW % (opt.name, value or "&nbsp", opt.descr))

			fp.write(TABLE_END)

		print_opt("Build", c.option_build)
		print_opt("Header", c.option_header)


	fp.write(footer())