[Tinyos-2-commits] CVS: tinyos-2.x/tools/tinyos/ncc/nesdoc-py archive.py, 1.2, 1.3 components.py, 1.2, 1.3 genhtml.py, 1.2, 1.3 graph.py, 1.2, 1.3

David Gay idgay at users.sourceforge.net
Fri Jun 1 16:07:22 PDT 2007


Update of /cvsroot/tinyos/tinyos-2.x/tools/tinyos/ncc/nesdoc-py
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv26597/nesdoc-py

Modified Files:
	archive.py components.py genhtml.py graph.py 
Log Message:
add -app option to nesdoc to generate app-level graphs


Index: archive.py
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tools/tinyos/ncc/nesdoc-py/archive.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** archive.py	12 Jul 2006 17:00:56 -0000	1.2
--- archive.py	1 Jun 2007 23:07:20 -0000	1.3
***************
*** 41,44 ****
--- 41,46 ----
  from string import *
  from nesdoc.utils import *
+ from nesdoc.graph import generate_graph
+ from nesdoc.html import *
  import os
  
***************
*** 53,61 ****
  
  def usage():
!   print "Usage: %s [-t dir] [--topdir dir] [--preserve] repository" % argv[0]
    print "  where -t/--topdir specify prefixes to remove from file names"
    print "  to create nice, package-like names for interface and components"
    print "  (based on their full filename)."
    print "  If --preserve is specified, existing XML files are preserved."
    print "  The XML input is read from stdin."
  
--- 55,65 ----
  
  def usage():
!   print "Usage: %s [-t dir] [--topdir dir] [--preserve] [--app] repository" % argv[0]
    print "  where -t/--topdir specify prefixes to remove from file names"
    print "  to create nice, package-like names for interface and components"
    print "  (based on their full filename)."
    print "  If --preserve is specified, existing XML files are preserved."
+   print "  If --app is specified, a page for this application is created in the"
+   print "  current directory."
    print "  The XML input is read from stdin."
  
***************
*** 100,106 ****
  
  # option processing. See usage string for details.
! (opts, args) = getopt(argv[1:], "t:", [ "topdir=", "preserve" ])
! topopts = filter(lambda (x): x[0] != "--preserve", opts)
  preserve = filter(lambda(x): x[0] == "--preserve", opts) != []
  topdirs = map(lambda (x): canonicalisedir(x[1]), topopts)
  if len(args) != 1:
--- 104,111 ----
  
  # option processing. See usage string for details.
! (opts, args) = getopt(argv[1:], "t:", [ "topdir=", "preserve", "app" ])
! topopts = filter(lambda (x): x[0] != "--preserve" and x[0] != "--app", opts)
  preserve = filter(lambda(x): x[0] == "--preserve", opts) != []
+ app = filter(lambda(x): x[0] == "--app", opts) != []
  topdirs = map(lambda (x): canonicalisedir(x[1]), topopts)
  if len(args) != 1:
***************
*** 173,176 ****
--- 178,205 ----
    set_nicename(x)
  
+ # Do the app stuff if requested
+ if app:
+   # The firt component is the main application component.
+   toplevel = xml_idx(components, 0)
+   name = toplevel.getAttribute("qname")
+   nicename = toplevel.getAttribute("nicename")
+   wiring = xml_tag(xml_tag(dom, "nesc"), "wiring")
+   generate_graph(".", repository, dom, wiring, name, nicename)
+ 
+   ht = Html("%s.html" % nicename)
+   ht.title("Application: " + nicename)
+   ht.body()
+   ht.push("h2");
+   ht.p("Application: " + nicename)
+   ht.popln();
+   ht.pushln("map", 'name="comp"')
+   cmap = file("%s.cmap" % nicename)
+   for line in cmap.readlines():
+     ht.pln(line)
+   cmap.close()
+   ht.popln()
+   ht.tag("img", 'src="%s.png"' % nicename, 'usemap="#comp"', 'id=imgwiring')
+   ht.close()
+ 
  # save xml information per-interface and per-component in the specified
  # repository

Index: components.py
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tools/tinyos/ncc/nesdoc-py/components.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** components.py	12 Jul 2006 17:00:56 -0000	1.2
--- components.py	1 Jun 2007 23:07:20 -0000	1.3
***************
*** 117,120 ****
      cmap.close()
      ht.popln()
!     ht.tag("img", 'src="%s.gif"' % nicename, 'usemap="#comp"', 'id=imgwiring')
    ht.close()
--- 117,120 ----
      cmap.close()
      ht.popln()
!     ht.tag("img", 'src="%s.png"' % nicename, 'usemap="#comp"', 'id=imgwiring')
    ht.close()

Index: genhtml.py
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tools/tinyos/ncc/nesdoc-py/genhtml.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** genhtml.py	12 Jul 2006 17:00:56 -0000	1.2
--- genhtml.py	1 Jun 2007 23:07:20 -0000	1.3
***************
*** 26,30 ****
  from nesdoc.interfaces import generate_interface
  from nesdoc.components import generate_component
! from nesdoc.graph import generate_graph
  from nesdoc.index import generate_indices
  from sys import *
--- 26,30 ----
  from nesdoc.interfaces import generate_interface
  from nesdoc.components import generate_component
! from nesdoc.graph import generate_component_graph
  from nesdoc.index import generate_indices
  from sys import *
***************
*** 85,89 ****
      stderr.write("component " + comp + "\n")
      ixml = parse("components/" + comp)
!     generate_graph(ixml.documentElement)
      generate_component(ixml.documentElement)
      ixml.unlink()
--- 85,89 ----
      stderr.write("component " + comp + "\n")
      ixml = parse("components/" + comp)
!     generate_component_graph(ixml.documentElement)
      generate_component(ixml.documentElement)
      ixml.unlink()

Index: graph.py
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tools/tinyos/ncc/nesdoc-py/graph.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** graph.py	12 Jul 2006 17:00:56 -0000	1.2
--- graph.py	1 Jun 2007 23:07:20 -0000	1.3
***************
*** 15,25 ****
  from os import system
  
! def generate_graph(comp):
!   name = comp.getAttribute("qname")
!   nicename = comp.getAttribute("nicename")
!   wiring = xml_tag(comp, "wiring")
    if not wiring:
      return
!   
    # Return the element definition for a given wiring endpoint
    def lookup_elem(endpoint):
--- 15,26 ----
  from os import system
  
! def generate_component_graph(comp):
!   generate_graph("chtml", "..", comp, xml_tag(comp, "wiring"),
!                  comp.getAttribute("qname"), comp.getAttribute("nicename"))
!   
! def generate_graph(dir, repository, xml, wiring, name, nicename):
    if not wiring:
      return
! 
    # Return the element definition for a given wiring endpoint
    def lookup_elem(endpoint):
***************
*** 80,87 ****
          else:
            styles.append('label="%s\\n(%s)"' % (instanceof_name, iname))
!         styles.append('URL="%s.html"' % instanceof.getAttribute("nicename"))
        else:
          # Just a regular component
!         styles.append('URL="%s.html"' % ncomp.getAttribute("nicename"))
        if styles != []:
          gf.write("[%s]" % join(styles, ", "))
--- 81,88 ----
          else:
            styles.append('label="%s\\n(%s)"' % (instanceof_name, iname))
!         styles.append('URL="%s/chtml/%s.html"' % (repository, instanceof.getAttribute("nicename")))
        else:
          # Just a regular component
!         styles.append('URL="%s/chtml/%s.html"' % (repository, ncomp.getAttribute("nicename")))
        if styles != []:
          gf.write("[%s]" % join(styles, ", "))
***************
*** 117,121 ****
        if xml_tag(elem, "interface-parameters"):
          styles.append('style=bold')
!       styles.append('URL="../ihtml/%s.html"' % idef.getAttribute("nicename"))
      styles.append("fontsize=10")
      return styles
--- 118,122 ----
        if xml_tag(elem, "interface-parameters"):
          styles.append('style=bold')
!       styles.append('URL="%s/ihtml/%s.html"' % (repository, idef.getAttribute("nicename")))
      styles.append("fontsize=10")
      return styles
***************
*** 125,137 ****
    refidx = {}
    compidx = {}
!   for intf in comp.getElementsByTagName("interface"):
      refidx[intf.getAttribute("ref")] = intf
!   for fn in comp.getElementsByTagName("function"):
      refidx[fn.getAttribute("ref")] = fn
!   for ncomp in comp.getElementsByTagName("component"):
      compidx[ncomp.getAttribute("qname")] = ncomp
    
    # create the dot graph specification
!   gf = file("chtml/%s.dot" % nicename, "w")
    gf.write('digraph "%s" {\n' % nicename)
    
--- 126,138 ----
    refidx = {}
    compidx = {}
!   for intf in xml.getElementsByTagName("interface"):
      refidx[intf.getAttribute("ref")] = intf
!   for fn in xml.getElementsByTagName("function"):
      refidx[fn.getAttribute("ref")] = fn
!   for ncomp in xml.getElementsByTagName("component"):
      compidx[ncomp.getAttribute("qname")] = ncomp
    
    # create the dot graph specification
!   gf = file("%s/%s.dot" % (dir, nicename), "w")
    gf.write('digraph "%s" {\n' % nicename)
    
***************
*** 150,153 ****
  
    # Run dot twice to get a picture and cmap
!   system("dot -Tgif -ochtml/%s.gif chtml/%s.dot" % (nicename, nicename))
!   system("dot -Tcmap -ochtml/%s.cmap chtml/%s.dot" % (nicename, nicename))
--- 151,154 ----
  
    # Run dot twice to get a picture and cmap
!   system("dot -Tpng -o%s/%s.png %s/%s.dot" % (dir, nicename, dir, nicename))
!   system("dot -Tcmap -o%s/%s.cmap %s/%s.dot" % (dir, nicename, dir, nicename))



More information about the Tinyos-2-commits mailing list