Skip to content

Commit 96d7fa6

Browse files
committed
Merge branch 'release/2.1.0'
2 parents 1c3c41c + 6e0d81b commit 96d7fa6

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

php-extras-gen-eldoc.el

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
(require 'php-mode)
3333
(require 'php-extras)
3434
(require 'json)
35+
(require 'shr)
3536

3637

3738

@@ -59,15 +60,28 @@
5960
:size length
6061
:rehash-threshold 1.0
6162
:rehash-size 100
62-
:test 'equal)))
63+
:test 'equal))
64+
doc)
6365
(dolist (elem data)
6466
(setq count (+ count 1))
6567
;; Skip methods for now: is there anything more intelligent we
6668
;; could do with them?
6769
(unless (string-match-p "::" (symbol-name (car elem)))
6870
(setq progress (* 100 (/ (float count) length)))
6971
(message "[%2d%%] Adding function: %s..." progress (car elem))
70-
(puthash (symbol-name (car elem)) (cdr elem) function-arguments-temp)))
72+
(setq doc (concat
73+
(cdr (assoc 'purpose (cdr elem)))
74+
"\n\n"
75+
(cdr (assoc 'prototype (cdr elem)))
76+
"\n\n"
77+
;; The return element is HTML - use `shr' to
78+
;; render it back to plain text.
79+
(save-window-excursion
80+
(with-temp-buffer
81+
(insert (cdr (assoc 'return (cdr elem))))
82+
(shr-render-buffer (current-buffer))
83+
(buffer-string)))))
84+
(puthash (symbol-name (car elem)) (cons `(documentation . ,doc) (cdr elem)) function-arguments-temp)))
7185
;; PHP control structures are not present in JSON list. We add
7286
;; them here (hard coded - there are not so many of them).
7387
(let ((php-control-structures '("if" "else" "elseif" "while" "do.while" "for" "foreach" "break" "continue" "switch" "declare" "return" "require" "include" "require_once" "include_once" "goto")))

php-extras.el

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
;; Author: Arne Jørgensen <arne@arnested.dk>
66
;; URL: https://github.com/arnested/php-extras
77
;; Created: June 28, 2012
8-
;; Version: 2.0.0
8+
;; Version: 2.1.0
99
;; Package-Requires: ((php-mode "1.5.0"))
1010
;; Keywords: programming, php
1111

@@ -138,11 +138,17 @@ documentation for the inserted selection."
138138
(fboundp 'eldoc-message))
139139
(eldoc-message (funcall eldoc-documentation-function)))))
140140

141+
(defun php-extras-function-documentation (symbol)
142+
"Documentation for PHP function."
143+
(php-extras-get-function-property symbol 'documentation))
144+
141145
(defvar ac-source-php-extras
142146
'((candidates . php-extras-autocomplete-candidates)
143147
(candidate-face . php-extras-autocomplete-candidate-face)
144148
(selection-face . php-extras-autocomplete-selection-face)
149+
(document . php-extras-function-documentation)
145150
(action . php-extras-ac-insert-action)
151+
(symbol . "f")
146152
(cache))
147153
"Auto complete source for PHP functions.")
148154

0 commit comments

Comments
 (0)