Skip to content

Commit

Permalink
Re #6897. MediaWiki now modifies qhp more directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Apr 23, 2013
1 parent f9abb74 commit 4c4a57b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
10 changes: 4 additions & 6 deletions Code/Mantid/docs/qtassistant/algorithm_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ def process_algorithm(name, versions, qhp, outputdir, **kwargs): # was (args, al

htmlfile.h3("Summary")
#htmlfile.p(alg.getWikiSummary())
wiki = MediaWiki(htmlfile)
wiki.parse(alg.getWikiSummary())
for img in wiki.images:
qhp.addFile(os.path.join(HTML_DIR, "img", img))
wiki = MediaWiki(htmlfile, HTML_DIR)
wiki.parse(alg.getWikiSummary(), qhp)

htmlfile.h3("Usage")
text = wiki_tools.create_function_signature(alg, name)
Expand All @@ -108,11 +106,11 @@ def process_algorithm(name, versions, qhp, outputdir, **kwargs): # was (args, al
htmlfile.writeRow(propToList(property, i))
htmlfile.closeTag(True)

wiki = MediaWiki(htmlfile)
wiki = MediaWiki(htmlfile, HTML_DIR)
text = wiki_tools.get_custom_wiki_section(name, version, "*WIKI*", True, False)
if len(text.strip()) > 0:
htmlfile.h3("Description")
wiki.parse(text)
wiki.parse(text, qhp)

htmlfile.closeTag(True)

Expand Down
6 changes: 2 additions & 4 deletions Code/Mantid/docs/qtassistant/fitfunctions_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@ def process_function(name, qhp, outputdir, **kwargs): # was (args, algo):
htmlfile.hr()

htmlfile.h3("Summary")
wiki = MediaWiki(htmlfile)
wiki.parse(wiki_tools.get_fitfunc_summary(name, False))
for img in wiki.images:
qhp.addFile(os.path.join(HTML_DIR, "img", img))
wiki = MediaWiki(htmlfile, HTML_DIR)
wiki.parse(wiki_tools.get_fitfunc_summary(name, False), qhp)

if func.numParams() <= 0:
htmlfile.h3("No Parameters")
Expand Down
15 changes: 12 additions & 3 deletions Code/Mantid/docs/qtassistant/mediawiki.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from assistant_common import WEB_BASE, HTML_DIR, addEle, addTxtEle
import os
import re

def formatImgHtml(raw):
Expand All @@ -17,7 +18,8 @@ def formatImgHtml(raw):
# chop tag into something more workable
components = raw.split('|')
img = components[0] # image filename is always first

#print "IMG:", img

# get the other bits of meta-data
alt = None
caption = None
Expand Down Expand Up @@ -47,8 +49,9 @@ def formatImgHtml(raw):
return (img, html)

class MediaWiki:
def __init__(self, htmlfile):
def __init__(self, htmlfile, direc):
self.__file = htmlfile
self.__direc = direc
self.__types = []
self.images = []

Expand All @@ -63,6 +66,7 @@ def __parseImgs(self, text):
for src in raw:
(imagefile, newtxt) = formatImgHtml(src)
self.images.append(imagefile)
#print "IM2:", imagefile, len(self.images)
html.append(newtxt)

for (orig, repl) in zip(raw, html):
Expand Down Expand Up @@ -162,12 +166,17 @@ def __annotate(self, text):
else:
self.__types.append(None)

def parse(self, text):
def parse(self, text, qhp):
#print "00>>>", text, "<<<"
text = text.strip()
if len(text) <= 0:
return # don't bother if it is empty
text = self.__parseImgs(text)
if len(self.images) > 0:
print "----->", self.images
for img in self.images:
img = os.path.join(self.__direc, "img", img)
qhp.addFile(img)
#print "01>>>", text, "<<<"
if text.startswith("== Deprecation notice =="):
stuff = "== Deprecation notice =="
Expand Down

0 comments on commit 4c4a57b

Please sign in to comment.