Skip to content

Commit

Permalink
Re #6630. Moving the last bit of lxml to minidom.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Mar 6, 2013
1 parent 60a6e3d commit ee97d98
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
6 changes: 4 additions & 2 deletions Code/Mantid/docs/qtassistant/make_algorithms_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def processCategories(categories, qhp, outputdir):
for subcategory in subcategories:
anchor = subcategory.split('/')
anchor = '_'.join(anchor[1:])
addTxtEle(doc, "h2", subcategory, body, {"name":anchor})
addTxtEle(doc, "h2", subcategory, body)
addEle(doc, 'a', body, {"name":anchor})
ul = addEle(doc, "ul", body)
for (name, versions) in categories[subcategory]:
appendAlgoElement(doc, ul, name, versions)
Expand Down Expand Up @@ -142,7 +143,8 @@ def process(algos, qhp, outputdir):

# print the list of algorithms by name
for letter in letters:
addTxtEle(doc, 'h3', letter, div_alpha, {"name":'algo'+letter})
addTxtEle(doc, 'h3', letter, div_alpha)
addEle(doc, 'a', div_alpha, {"name":'algo'+letter})
ul = addEle(doc, "ul", div_alpha)
for (name, versions) in letter_groups[letter]:
appendAlgoElement(doc, ul, name, versions)
Expand Down
36 changes: 17 additions & 19 deletions Code/Mantid/docs/qtassistant/make_fitfunctions_help.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env python
from lxml import etree as le # python-lxml on rpm based systems
import lxml.html
from lxml.html import builder as lh
from xml.dom.minidom import Document
import os
from qhpfile import QHPFile
from string import split,join
Expand All @@ -16,9 +14,9 @@ def addWikiDir(helpsrcdir):
wikitoolsloc = os.path.abspath(wikitoolsloc)
sys.path.append(wikitoolsloc)

def genFuncElement(name):
text = '<a href="FitFunc_%s.html">%s</a>' % (name, name)
return lxml.html.fragment_fromstring(text)
def appendFuncElement(doc, div, name):
li = addEle(doc, "li", div)
addTxtEle(doc, "a", name, li, {"href":"FitFunc_%s.html" % name})

def process(functions, qhp, outputdir):
import mantid.api
Expand All @@ -36,27 +34,27 @@ def process(functions, qhp, outputdir):
categories_list.sort()

##### put together the top of the html document
root = le.Element("html")
head = le.SubElement(root, "head")
head.append(lh.META(lh.TITLE("Fit Functions Index")))
body = le.SubElement(root, "body")
body.append(lh.CENTER(lh.H1("Fit Functions Index")))
doc = Document()
root = addEle(doc, "html", doc)
head = addEle(doc, "head", root)
addTxtEle(doc, "title", "Fit Functions Index", head)
body = addEle(doc, "body", root)
temp = addEle(doc, "center", body)
addTxtEle(doc, "h1", "Fit Functions Index", temp)

##### section for categories
div_cat = le.SubElement(body, "div", **{"id":"function_cats"})
div_cat = addEle(doc, "div", body, {"id":"function_cats"})
for category in categories_list:
temp = le.SubElement(div_cat, "h2")
le.SubElement(temp, 'a', **{"name":category})
temp.text = category + " Category"
ul = le.SubElement(div_cat, "ul")
addTxtEle(doc, "h2", category + " Category", div_cat)
addEle(doc, "a", div_cat, {"name":category})
ul = addEle(doc, "ul", div_cat)
funcs = categories[category]
for func in funcs:
li = le.SubElement(ul, "li")
li.append(genFuncElement(func))
appendFuncElement(doc, ul, func)

filename = os.path.join(outputdir, "fitfunctions_index.html")
handle = open(filename, 'w')
handle.write(le.tostring(root, pretty_print=True, xml_declaration=False))
handle.write(doc.toprettyxml(indent=" ", encoding="utf-8"))

shortname = os.path.split(filename)[1]
qhp.addFile(os.path.join(HTML_DIR, shortname), "Fit Functions Index")
Expand Down

0 comments on commit ee97d98

Please sign in to comment.