diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2009-12-23 20:22:25 -0500 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2009-12-23 20:22:25 -0500 |
commit | 76e669e4b683831532e83e01ef684cbdaaa40800 (patch) | |
tree | 4f2c3d7a492cf562cf33bf5cd9cf2df195136167 | |
parent | 5633f2dec75c5518da7082695877e76863c08ad5 (diff) |
Get section content from the xhp files if available.
For now, only the scale help contents are fetched.
-rw-r--r-- | source/docbook.py | 16 | ||||
-rw-r--r-- | source/node.py | 1 | ||||
-rw-r--r-- | source/tree.py | 7 |
3 files changed, 22 insertions, 2 deletions
diff --git a/source/docbook.py b/source/docbook.py index 2d69c33..328f0cc 100644 --- a/source/docbook.py +++ b/source/docbook.py @@ -143,8 +143,20 @@ class DocBookConverter: elif src.name == 'content': # this element has 'title' and 'path' attributes, and has no more child nodes. title = src.getAttr('title') - elem = appendDocBookElement(dest) - elem.appendElement('title').appendContent(title) + sect = appendDocBookElement(dest) + sect.appendElement('title').appendContent(title) + xhppath = src.getAttr('path') + if self.xhproots.has_key(xhppath): + self.__getContentFromXHP(xhppath, sect) + else: + sect.appendElement('para').appendContent('get content from ' + src.getAttr('path')) + + def __getContentFromXHP (self, xhppath, dest): + xhproot = self.xhproots[xhppath] + xhpbody = xhproot.firstChild().firstChildByName('body') + for xhppara in xhpbody.getChildByName('paragraph'): + para = dest.appendElement('para') + para.appendContent(xhppara.getContent()) def prettyPrint (self, fd): diff --git a/source/node.py b/source/node.py index 8dcbb27..2feb0a3 100644 --- a/source/node.py +++ b/source/node.py @@ -149,5 +149,6 @@ def printNode (fd, node, level): elif node.nodeType == NodeType.Content: content = node.content.strip() + content = encodeString(content) if len(content) > 0: fd.write (indent + content + "\n") diff --git a/source/tree.py b/source/tree.py index 2d91637..8e3b646 100644 --- a/source/tree.py +++ b/source/tree.py @@ -26,6 +26,7 @@ class TreeBuilder: self.__walkNode(child, elem) def __walkNode (self, src, dest): + if src.nodeType != node.NodeType.Element: return @@ -34,6 +35,12 @@ class TreeBuilder: # the 'id' attribute contains the corresponding xhp file path, while # the content of this element is the title of this section. xhppath = src.getAttr('id') + + # It seems that the first directory name in the xhp path should be dropped. + pos = xhppath.find('/') + if pos >= 0: + xhppath = xhppath[pos+1:] + title = src.getContent() title = node.encodeString(title) elem = dest.appendElement('content') |