Is there an api to programmatically access to the Java documentation? Something similar to what editors/IDEs like Eclipse do for IntelliSense. Surely, the javadoc generated html can be parsed and indexed, but would be great to know if something already exists as a standalone package.
Update:
To be clear, I am trying to get a programmatic access to the documentation for the java language implementation. However, there isn't an easy way out, but you have to get the openjdk from Oracle's site and then do make docs
and supply some doclet to get the output in non-html form. This is what I was trying to avoid from the beginning. So I'm reading all the Makefiles now trying to figure out why $PLATFORM isn't being resolved and source build is failing!
What I finally settled with:
Scraping html docs. Yep. Realized that'd get my job done.
import urllib2
import pymongo
mongo = pymongo.Connection('localhost')
mongo_db = mongo['api_db']
mongo_collection = mongo_db['api_collection']
URL='''http://docs.oracle.com/javase/6/docs/api/index-files/index-'''
URL_range = 27+1
def getPageElements(url):
content=urllib2.urlopen(url).read()
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(content)
elements = soup('dl')
return elements
def savePageElements(elements):
for i in elements[0]:
try:
entry={'type_description':str(i.findNext('dt')).split('-')[1].split('<')[0]\
+i.findNext('a').findNext('a').renderContents(),\
'signature':i.findNext('a').findNext('a').renderContents()+i.findNext('b').renderContents(),\
'description': i.findNext('dd').renderContents()\
}
print entry
insert_id = mongo_collection.save(entry)
except:
pass
def retrieve(str):
mongo_documents = mongo_collection.find({
'signature': str,
#'type_description':"Method of java.io.PrintStream"
})
for this_document in mongo_documents:
print this_document
if __name__=="__main__":
for i in range(1,URL_range):
#url=URL+str(i)+".html"
#print "Processing:", url
#elements=getPageElements(url)
#print elements[0]
#savePageElements(elements)
retrieve("println(String)")
But take a look at dexy. If I could have managed to build OpenJDK on Ubuntu without issue - it would have generated nice JSON to play with.
Whether you are working on a new cutting edge app or simply ramping up on new technology, Java documentation has all the information you need to make your project a smashing success.
This tool is used to create a standard documentation of Java code in HTML file format. In fact, Java officially uses this tool to create its own library API documentation.
To locate the Javadoc, browse to your User folder (on Windows 7 this is C:\Users\*Username*), then browse to sunspotfrcsdk/doc/javadoc. Double click on the index. html file to open it in your default webbrowser.
As you write Eclipse does parse javadoc and does pretty good job of it. It seems it was introduced in 3.2M4. You may be able to extract the functionality from Eclipse sources, checking with Eclipse community for entry point may be a good place to start.
If that does not work, I guess your starting point would be a plain vanilla HTML parser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With