Index: PyTeXdoc.py =================================================================== --- PyTeXdoc.py (revision 8405) +++ PyTeXdoc.py (working copy) @@ -10,7 +10,7 @@ # 3/4/2007 -- removed colours from stylesheet (and added underlines) to # avoid problems with dark themes # This script is a hacked together set of heuristics to try and bring some -# order out of the various bits and pieces of documentation that are strewn +# order out of the various bits and pieces of documentation that are strewn # around any given LaTeX distro. # texdoctk provides a nice list of packages, along with paths to the documents # that are relative to one or more roots. The root for these documents varies. @@ -26,7 +26,7 @@ # attempt to find the best match for that word as a package and open the documentaiton for that # package immediately. # -# because good dvi viewers are quite rare on OS X, I also provide a simple viewDoc.sh script. +# because good dvi viewers are quite rare on OS X, I also provide a simple viewDoc.sh script. # viewDoc.sh converts a dvi file (using dvipdfm) and opens it in Previewer. #TODO make the viewing command configurable @@ -77,15 +77,19 @@ docDict[key] = doc[:-1] return docDict -def openIncludedFile(fname): - fname = os.path.expanduser(fname) # Added +def openIncludedFile(orgname): + fname = os.path.expanduser(orgname) # Added if os.path.exists(fname): return open(fname,'r') elif os.path.exists(fname+'.tex'): return open(fname+'.tex','r') else: - print "Error: Cannot open included file " + fname - return None + kpsePut, kpseGet = os.popen4("kpsewhich " + orgname) + for result in kpseGet.readlines(): + if os.path.exists(result.rstrip()): + return open(result.rstrip(),'r') + print "Error: Cannot open included file " + fname + return None ## Part 1 ## Find all the packages included in this file or its inputs @@ -156,7 +160,7 @@ path = lineFields[2] except: print "Error parsing line: ", line - + headings[currentHeading].append(key) if path.rfind('.sty') >= 0: path = docBase + "tex/" + path @@ -171,7 +175,7 @@ else: if key in myDict: path = findBestDoc(myDict[key]) - + pathDict[key] = path.strip() descDict[key] = desc.strip() @@ -219,10 +223,10 @@ display:none; text-decoration:none; font-family: "Bitstream Vera Sans Mono", "Monaco", monospace; - margin: 0px 20px 0px 20px;} + margin: 0px 20px 0px 20px;} .dspcont a{ text-decoration: none; -} +} .dspcont a:hover{ text-decoration:underline; } @@ -247,11 +251,11 @@ foc=loc.parentNode.nextSibling.style? loc.parentNode.nextSibling: loc.parentNode.nextSibling.nextSibling; - foc.style.display=foc.style.display=='block'?'none':'block';}} + foc.style.display=foc.style.display=='block'?'none':'block';}} //--> -""" +""" print "