aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristopher Harvey <chris@basementcode.com>2010-06-06 14:21:02 -0400
committerChristopher Harvey <chris@basementcode.com>2010-06-06 14:21:02 -0400
commit93571ec2f131ab54ffb118227dec0fed28b2b46f (patch)
treeddcbb975b72d716bed3d5dbfcb694014ecf70d5f /src
parentStarted modprobe module (diff)
downloadventoo-93571ec2f131ab54ffb118227dec0fed28b2b46f.tar.gz
ventoo-93571ec2f131ab54ffb118227dec0fed28b2b46f.tar.bz2
ventoo-93571ec2f131ab54ffb118227dec0fed28b2b46f.zip
Comment blocks are displayed as individual nodes and the rest of the docs are put into the html documentation viewer. This is a nice balance between showing all doc nodes and showing none.
Diffstat (limited to 'src')
-rw-r--r--src/frontend/main.py58
1 files changed, 53 insertions, 5 deletions
diff --git a/src/frontend/main.py b/src/frontend/main.py
index d12d8db..4383dc3 100644
--- a/src/frontend/main.py
+++ b/src/frontend/main.py
@@ -126,9 +126,22 @@ class MainWindow(gtk.Window):
"""
def nodeChanged(self, treeview, user_param1):
p = self.edit_tv.getSelectedEntryPath()
- p = augeas_utils.removeNumbers(p)
- xmlPath = osp.join("/VentooModule/root", p)
- docPath = self.currentModule.getDocURLOf(xmlPath)
+ docPath = None
+ #if this is a comment node display all surround docs/comments
+ if osp.split(p)[1].startswith("#comment["):
+ toDisplay = self.getDocsStartingAt(osp.join("/files", augeas_utils.stripBothSlashes(self.currentConfigFilePath), p), "<br>")
+ docPath = "/tmp/commentsDoc.html"
+ outFile = open("/tmp/commentsDoc.html", 'w')
+ outFile.write("<html>\n")
+ outFile.write(toDisplay)
+ outFile.write("</html>\n")
+ outFile.close()
+ else:
+ #this is a normal node, normal display
+ p = augeas_utils.removeNumbers(p)
+ xmlPath = osp.join("/VentooModule/root", p)
+ docPath = self.currentModule.getDocURLOf(xmlPath)
+
if docPath == None:
self.docWindow.load_url("about:blank")
else:
@@ -250,14 +263,25 @@ class MainWindow(gtk.Window):
maxIndex = 0
#matches <anything>/<number> and stores <number> as group 1
indexProg = re.compile('^.+/([0-9]+)/?$')
+ commentProg = re.compile('"^#comment\[(.*)]$"')
+ lastLineWasDoc = False
for match in matches: #add all existing entries
indexResult = indexProg.match(match)
+ commentResult = commentProg.match(match)
if indexResult != None: #sometimes there are entries on these levels we don't care about.
have += 1
thisIndex = int(indexResult.group(1))
maxIndex = max(maxIndex, thisIndex)
created = model.append(modelPathIter, [True, indexResult.group(1), '-------'])
self.__buildEditModel(model, match, created, xmlRoot)
+ lastLineWasDoc = False
+ elif commentProg != None: #got a comment
+ #only display the first line, the rest can be displayed in the doc frame when requested.
+ if not lastLineWasDoc:
+ docText = self.a.get(match)
+ created = model.append(modelPathIter, [True, osp.split(match)[1], docText])
+ lastLineWasDoc = True
+
#add the missing entries
numNeeded = augeas_utils.matchDiff(thisMult, have)
#add the required ones.
@@ -320,14 +344,38 @@ class MainWindow(gtk.Window):
break
#now search for and add nodes that haven't been added yet, and may not be in the VentooModule specifically.
allInAugeas = self.a.match(osp.join(augeasFileRoot, '*'))
+ lastLineWasDoc = False
for a in allInAugeas:
if not a in listedNodes:
#found that 'a' is not in listedNodes, but is in augeasTree, add it, if it is not supposed to be ignored.
- if not osp.split(a)[1].startswith('#'): #always ignore comments
+ if not osp.split(a)[1].startswith('#'): #always ignore comments (delt with later)
userData = self.a.get(a)
created = model.append(modelPathIter, [True, osp.split(a)[1], userData])
self.__buildEditModel(model, a, created, osp.join(xmlRoot, 'ventoo_dynamic'))
-
+ lastLineWasDoc = False
+ else:
+ #Add docs inline here
+ if not lastLineWasDoc:
+ docText = self.a.get(a)
+ created = model.append(modelPathIter, [True, osp.split(a)[1], docText])
+ lastLineWasDoc = True
+
+ """
+ Get doc text starting at the augeas path p, until another non-comment is found
+ nl stands for new line and is a string to be added after each comment node.
+ """
+ def getDocsStartingAt(self, p, nl = "\n"):
+ docStr = ""
+ commentProg = re.compile('^.*#comment\[(.*)\]$')
+ thisNodes = self.a.match(osp.join(osp.split(p)[0], "*"))
+ try:
+ idx = thisNodes.index(p)
+ while commentProg.match(thisNodes[idx])!=None:
+ docStr = docStr + nl + self.a.get(thisNodes[idx])
+ idx += 1
+ except IndexError:
+ pass
+ return docStr
"""
Called when the user picks a new file to view.