PDA

View Full Version : Here's a script for Library Info


schdeffan
2004-04-08, 20:49
hi,

as there's little library info on what methods the modules xbmc and xbmcgui export i wrote a little script that creates a (atm ugly html-file) with at least some info:


import xbmcgui, xbmc


def startfile():
* *f = open('q:\\lib.html', 'w')
* *f.write('<html><body>')
* *f.close()

def stopfile():
* *f = open('q:\\lib.html', 'a')
* *f.write('</body></html>')
* *f.close()

def addmodule(module, d):
* *str = '['
* *for t in d:
* * * *if t[:2] != '§§':
* * * * * str = str + t + ', '
* *str = str + ']'
*
* *dmodule = module + '.§§doc§§'

* *docs = eval(dmodule)

* *f = open('q:\\lib.html', 'a')
* *f.write('<p><b>%s =</b> %s <br>%s</p>' % (module, str, docs))
* *f.close()


def dodir(module, depth, max):
* *if depth <= max:
* * * *print module
* * * *try:
* * * * * *d = dir(eval(module))
* * * * * *addmodule(module, d)
* * * * * *for t in d:
* * * * * * * *if t[:2] != '§§':
* * * * * * * * * p = module + '.' + t
* * * * * * * * * dodir(p, depth + 1, max)
* * * *except:
* * * * * *pass * * * * * * * * *
* * * *
* * * *
startfile()
dodir('xbmc', 0, 2)
dodir('xbmcgui', 0, 2)
stopfile()

please replace the § with underscores, cause otherwise this won't display correctly in this board
the file will obviously be q:\lib.html

@darkie: if you could fill in the doc strings a bit more, e.g. what does it, which arguments, how to call, etc., we could improve this script a bit and have automatically create a good library info on the modules xbmc is exporting.

with this, on every new release of xbmc script coders could run the script and see what's new / possible

-stephan

ent
2004-04-09, 14:20
there's a python_readme.txt in the cvs.

darkie
2004-04-09, 16:00
@darkie: if you could fill in the doc strings a bit more, e.g. what does it, which arguments, how to call, etc., we could improve this script a bit and have automatically create a good library info on the modules xbmc is exporting. ok, seeing now that it is possible to create such a file automaticly and that the 'python / xbmc' object structure seems ok now , i'll start adding those doc strings.

edit: btw, iirc python has already a module (pydoc?) that can generate a nice document of it

schdeffan
2004-04-09, 16:01
oh, haven't seen that. thanks for the hint.

maybe the script is still useful as it could automate the process of creating such a file.

- stephan