This repository was archived by the owner on Jun 8, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-17
lines changed Expand file tree Collapse file tree 1 file changed +8
-17
lines changed Original file line number Diff line number Diff line change 2
2
# PHP's functions reference.
3
3
#
4
4
# Dependencies:
5
- # "jsdom": ""
6
- # "jquery": ""
5
+ # "cheerio": ""
7
6
#
8
7
# Configuration:
9
8
# None
10
9
#
11
10
# Commands:
12
11
# hubot phpdoc for <function> - Shows PHP function information.
13
12
#
14
- # Author :
13
+ # Authors :
15
14
# nebiros
16
-
17
- jsdom = require (" jsdom" ).jsdom
15
+ # Carter McKendry
18
16
19
17
module .exports = (robot ) ->
20
18
robot .respond / phpdoc for (. + )$ / i , (msg ) ->
21
19
msg
22
20
.http (" http://www.php.net/manual/en/function." + msg .match [1 ].replace (/ [_-] + / , " -" ) + " .php" )
23
21
.get () (err , res , body ) ->
24
- window = (jsdom body, null ,
25
- features :
26
- FetchExternalResources : false
27
- ProcessExternalResources : false
28
- MutationEvents : false
29
- QuerySelector : false
30
- ).createWindow ()
31
22
32
- $ = require (" jquery " ).create ( window )
33
- ver = $ . trim $ (" .refnamediv p.verinfo" ).text ()
34
- desc = $ . trim $ (" .refnamediv span.dc-title" ).text ()
35
- syn = $ . trim $ (" .methodsynopsis" ).text ().replace (/ \s + / g , " " ).replace (/ (\r\n | \n | \r )/ gm , " " )
23
+ $ = require (" cheerio " ).load (body )
24
+ ver = $ (" .refnamediv p.verinfo" ).text ()
25
+ desc = $ (" .refnamediv span.dc-title" ).text ()
26
+ syn = $ (" .methodsynopsis" ).text ().replace (/ \s + / g , " " ).replace (/ (\r\n | \n | \r )/ gm , " " )
36
27
37
28
if ver and desc and syn
38
29
msg .send " #{ ver} - #{ desc} "
39
30
msg .send syn
40
31
else
41
- msg .send " Not found."
32
+ msg .send " Not found."
You can’t perform that action at this time.
0 commit comments