Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #677 from nebiros/master
Browse files Browse the repository at this point in the history
new script, phpdoc.coffee
  • Loading branch information
Tom Bell committed Jan 10, 2013
2 parents 9c4271a + c6d74a8 commit e627342
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/scripts/phpdoc.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Description:
# PHP's functions reference.
#
# Dependencies:
# "jsdom": ""
# "jquery": ""
#
# Configuration:
# None
#
# Commands:
# hubot phpdoc for <function> - Shows PHP function information.
#
# Author:
# nebiros

jsdom = require("jsdom").jsdom

module.exports = (robot) ->
robot.respond /phpdoc for (.+)$/i, (msg) ->
msg
.http("http://www.php.net/manual/en/function." + msg.match[1].replace(/[_-]+/, "-") + ".php")
.get() (err, res, body) ->
window = (jsdom body, null,
features:
FetchExternalResources: false
ProcessExternalResources: false
MutationEvents: false
QuerySelector: false
).createWindow()

$ = require("jquery").create(window)
ver = $.trim $(".refnamediv p.verinfo").text()
desc = $.trim $(".refnamediv span.dc-title").text()
syn = $.trim $(".methodsynopsis").text().replace(/\s+/g, " ").replace(/(\r\n|\n|\r)/gm, " ")

if ver and desc and syn
msg.send "#{ver} - #{desc}"
msg.send syn
else
msg.send "Not found."

0 comments on commit e627342

Please sign in to comment.