from getopt import getopt
from string import *
from nesdoc.utils import *
+from nesdoc.graph import generate_graph
+from nesdoc.html import *
import os
def check(x):
return check(xml_tagfind(x, tag))
def usage():
- print "Usage: %s [-t dir] [--topdir dir] [--preserve] repository" % argv[0]
+ 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."
# Return package name for elem, or None if no valid name is found
return dirname
# option processing. See usage string for details.
-(opts, args) = getopt(argv[1:], "t:", [ "topdir=", "preserve" ])
-topopts = filter(lambda (x): x[0] != "--preserve", opts)
+(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:
usage()
for x in dom.getElementsByTagName("component-ref"):
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
nmkdir(repository)
ht.pln(line)
cmap.close()
ht.popln()
- ht.tag("img", 'src="%s.gif"' % nicename, 'usemap="#comp"', 'id=imgwiring')
+ ht.tag("img", 'src="%s.png"' % nicename, 'usemap="#comp"', 'id=imgwiring')
ht.close()
from nesdoc.utils import *
from nesdoc.interfaces import generate_interface
from nesdoc.components import generate_component
-from nesdoc.graph import generate_graph
+from nesdoc.graph import generate_component_graph
from nesdoc.index import generate_indices
from sys import *
from re import search, compile
if search("\\.xml$", comp):
stderr.write("component " + comp + "\n")
ixml = parse("components/" + comp)
- generate_graph(ixml.documentElement)
+ generate_component_graph(ixml.documentElement)
generate_component(ixml.documentElement)
ixml.unlink()
from sys import *
from os import system
-def generate_graph(comp):
- name = comp.getAttribute("qname")
- nicename = comp.getAttribute("nicename")
- wiring = xml_tag(comp, "wiring")
+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):
elemref = xml_tagset(endpoint, [ "interface-ref", "function-ref" ])
styles.append('label="%s"' % instanceof_name)
else:
styles.append('label="%s\\n(%s)"' % (instanceof_name, iname))
- styles.append('URL="%s.html"' % instanceof.getAttribute("nicename"))
+ styles.append('URL="%s/chtml/%s.html"' % (repository, instanceof.getAttribute("nicename")))
else:
# Just a regular component
- styles.append('URL="%s.html"' % ncomp.getAttribute("nicename"))
+ styles.append('URL="%s/chtml/%s.html"' % (repository, ncomp.getAttribute("nicename")))
if styles != []:
gf.write("[%s]" % join(styles, ", "))
gf.write(";\n")
styles = [ 'label="%s"' % sig ]
if xml_tag(elem, "interface-parameters"):
styles.append('style=bold')
- styles.append('URL="../ihtml/%s.html"' % idef.getAttribute("nicename"))
+ styles.append('URL="%s/ihtml/%s.html"' % (repository, idef.getAttribute("nicename")))
styles.append("fontsize=10")
return styles
# build indices from ref attribute values to the corresponding elements
refidx = {}
compidx = {}
- for intf in comp.getElementsByTagName("interface"):
+ for intf in xml.getElementsByTagName("interface"):
refidx[intf.getAttribute("ref")] = intf
- for fn in comp.getElementsByTagName("function"):
+ for fn in xml.getElementsByTagName("function"):
refidx[fn.getAttribute("ref")] = fn
- for ncomp in comp.getElementsByTagName("component"):
+ for ncomp in xml.getElementsByTagName("component"):
compidx[ncomp.getAttribute("qname")] = ncomp
# create the dot graph specification
- gf = file("chtml/%s.dot" % nicename, "w")
+ gf = file("%s/%s.dot" % (dir, nicename), "w")
gf.write('digraph "%s" {\n' % nicename)
endpoints = {}
gf.close()
# 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))
+ 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))
$preserve = 1;
$strip = 1;
}
+ elsif (/^-app$/) {
+ $app = 1;
+ $strip = 1;
+ }
}
push @ncc_args, $_ if !$strip;
}
# nesdoc-archive
unshift @ncc_args, "-fsyntax-only";
+unshift @ncc_args, "-fnesc-dump=wiring" if $app;
unshift @ncc_args, "-fnesc-dump=interfacedefs";
unshift @ncc_args, "-fnesc-dump=components(wiring)";
unshift @ncc_args, "-fnesc-dump=interfaces";
chomp $toscontainer;
push @archive_args, "--topdir=$toscontainer";
push @archive_args, "--preserve" if $preserve;
+push @archive_args, "--app" if $app;
push @archive_args, "$docdir";
unshift @archive_args, "$libprogs/nesdoc/archive.py";
unshift @archive_args, $python;
nesdoc -o <documentation directory> -html
Generate nesdoc html pages from archived nesdoc information.
+
+ nesdoc -o <documentation directory> -app <ncc options and nesC file>
+ Compile specified nesC application and generate a wiring graph
+ for the whole program in the current directory.
EOM
)
}