changeset 26:3c78854053e3

A script to convert menuconfig to html. Have make.sh call it for all $ARCH. (Need to create an index.html, and improve the conversion...)
author Rob Landley <rob@landley.net>
date Wed, 15 Aug 2007 01:17:23 -0500
parents fe01baf8e2a0
children ba26365cf74f
files make/make.sh make/menuconfig2html.py
diffstat 2 files changed, 80 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/make/make.sh	Mon Aug 13 16:25:58 2007 -0500
+++ b/make/make.sh	Wed Aug 15 01:17:23 2007 -0500
@@ -1,18 +1,29 @@
 #!/bin/bash
 
 echo Update linux kernel from kernel.org Mercurial repository
-# mkdir -p ~/linux/hg
-# hg clone http://kernel.org/hg/linux-2.6
-cd ~/linux/hg/linux-2.6
+# mkdir -p ~/linux
+# cd ~/linux
+# hg clone http://kernel.org/hg/linux-2.6 hg
+cd ~/linux/hg
 hg pull -u
 
+echo Convert kconfig to html for all architectures
+mkdir -p ~/www/kdocs/menuconfig
+for i in $(find arch -maxdepth 2 -name Kconfig)
+do
+  echo Converting "$i"
+  ARCH=$(echo $i | sed -r 's@.*/(.*)/.*@\1@')
+  
+  ~/www/kdocs/make/menuconfig2html.py $i > ~/www/kdocs/menuconfig/$(echo $i | sed -r 's@.*/(.*)/.*@\1@').html
+done
+
 echo Install updated Documentation
 rm -rf ~/www/kdocs/Documentation/
-cp -a ~/linux/hg/linux-2.6/Documentation ~/www/kdocs/Documentation
+cp -a ~/linux/hg/Documentation ~/www/kdocs/Documentation
 
 echo Build htmldocs and xhtml-nochunks
 rm -rf ~/linux/temp
-cd ~/linux/hg/linux-2.6
+cd ~/linux/hg
 mkdir ~/linux/temp
 make allnoconfig O=~/linux/temp
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/menuconfig2html.py	Wed Aug 15 01:17:23 2007 -0500
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+
+# "boolean" not documented type in kconfig-language.txt line 51
+
+import os,sys
+
+def zapquotes(str):
+  if str[0]=='"': str = str[1:str.rfind('"')]
+  return str
+
+def htmlescape(str):
+  return str.strip().replace("&","&amp;").replace("<","&lt;").replace(">","&gt;")
+
+helplen = 0
+out = sys.stdout
+
+def readfile(filename):
+  global helplen
+  #sys.stderr.write("Reading %s\n" % filename)
+  try:
+    lines = open(filename).read().split("\n")
+  except IOError:
+    sys.stderr.write("File %s missing\n" % filename)
+    return
+  config = None
+  description = None
+  for i in lines:
+    if helplen:
+      i = i.expandtabs()
+      if not len(i) or i[:helplen].isspace():
+        out.write("%s\n" % htmlescape(i))
+        continue
+      else:
+        helplen = 0
+        out.write("</pre></blockquote>\n")
+
+    words = i.strip().split(None,1)
+    if not len(words): continue
+
+    if words[0] in ("config", "menuconfig"):
+      config = words[1]
+      description = ""
+    elif words[0] in ("bool", "boolean", "tristate", "string", "hex", "int"):
+       if len(words)>1: description = htmlescape(zapquotes(words[1]))
+    elif words[0]=="prompt":
+      description = htmlescape(zapquotes(words[1]))
+    elif words[0] in ("help", "---help---"):
+      out.write('<a name="%s"><h2>%s</h2>\n<h3>%s</h3>\n<blockquote><pre>' % (config,config,description))
+      helplen = len(i[:i.find(words[0])].expandtabs())
+    elif words[0] == "comment":
+      out.write("<h3>%s</h3\n" % htmlescape(zapquotes(words[1])))
+    elif words[0]=="menu":
+      out.write("<hr>\n")
+      if len(words)>1: out.write("<h1>Menu: %s</h1>\n" % htmlescape(zapquotes(words[1])))
+    elif words[0] == "endmenu":
+      out.write("<hr>\n")  # Probably something better to do here
+    elif words[0] == "source": readfile(zapquotes(words[1]))
+    elif words[0] in ("default","depends", "select", "if", "endif", "#"): pass
+    #else: sys.stderr.write("unknown: %s\n" % i)
+
+out.write("<html>\n")
+readfile(sys.argv[1])
+if helplen: out.write("</pre></blockquote>\n")
+out.write("</html>\n")