Python API search

(ideasman42) #1

Every so often Id like to search the python API for a keyword rather then fossik about and find it myself.

Heres a nifty python script that gets you to type in a search and then opens the google search results for the BPython api - google will only look at the 1 api doc so you wont get double results.
I tried to get this happening in firefox’s search box but the “Roll your own” creator couldent define a URL sibdir to search.
Access this script from the help menu. - any additions welcome.

#!BPY 
""" 
Name: 'Search BPY API' 
Blender: 240
Group: 'Help' 
Tooltip: 'Search the BPython API' 
"""
import Blender, webbrowser
search_but= Blender.Draw.Create('')
pup_list= [('', search_but, 0, 255, 'Search String')]
if Blender.Draw.PupBlock('Search BPython API', pup_list):
    text= '+'.join(search_but.val.split()) # replace white spaces for +'s 
    webbrowser.open('http://www.google.com.au/search?filter=0&num=100&q=inurl:~cpbarton+inurl:BPY_API+' + text)
0 Likes

(narven) #2

it works nice :slight_smile: thanks :slight_smile:

0 Likes

(Heavily Tessellated) #3

Not to rain on your effort, but how is this better (or even different) than just running epydoc --pdf $( ls [A-Z]*.py ) in the api2_2x/doc directory? I looked for added functions that weren’t present in the API tree, but couldn’t find any.

At least this is a portable PDF and doesn’t require an internet connection to search your website docs (while being nicely formatted, anyone can do it using epydoc… w/o requiring both your server and Google being available.)

epydoc -o “Blender Python API Reference” --url “http://www.blender.org” --name “Blender Python API Reference” --css=mycoolstylesheet $( ls [A-Z]*.py )

Did I miss something?

0 Likes

(ideasman42) #4

The epydoc PDF, that was my first choice- but the resulting PDF wasnt that usefull- the fromatting was not very good (overlaping text, no color) and more importantly there was no PDF linking.

In short- a PDF would be better, but the current PDF export needs improving.

0 Likes

(IamInnocent) #5

Hello Campbell.

This script would be useful for me but it doesn’t presently point to an useful url. I have no idea how to correct this. Would you kindly update your script. :slight_smile: pretty please?

Regards,
Jean

0 Likes