diff --git a/php-extras-gen-eldoc.el b/php-extras-gen-eldoc.el index edbfd81..273d2d2 100644 --- a/php-extras-gen-eldoc.el +++ b/php-extras-gen-eldoc.el @@ -32,6 +32,7 @@ (require 'php-mode) (require 'php-extras) (require 'json) +(require 'shr) @@ -59,7 +60,8 @@ :size length :rehash-threshold 1.0 :rehash-size 100 - :test 'equal))) + :test 'equal)) + doc) (dolist (elem data) (setq count (+ count 1)) ;; Skip methods for now: is there anything more intelligent we @@ -67,7 +69,19 @@ (unless (string-match-p "::" (symbol-name (car elem))) (setq progress (* 100 (/ (float count) length))) (message "[%2d%%] Adding function: %s..." progress (car elem)) - (puthash (symbol-name (car elem)) (cdr elem) function-arguments-temp))) + (setq doc (concat + (cdr (assoc 'purpose (cdr elem))) + "\n\n" + (cdr (assoc 'prototype (cdr elem))) + "\n\n" + ;; The return element is HTML - use `shr' to + ;; render it back to plain text. + (save-window-excursion + (with-temp-buffer + (insert (cdr (assoc 'return (cdr elem)))) + (shr-render-buffer (current-buffer)) + (buffer-string))))) + (puthash (symbol-name (car elem)) (cons `(documentation . ,doc) (cdr elem)) function-arguments-temp))) ;; PHP control structures are not present in JSON list. We add ;; them here (hard coded - there are not so many of them). (let ((php-control-structures '("if" "else" "elseif" "while" "do.while" "for" "foreach" "break" "continue" "switch" "declare" "return" "require" "include" "require_once" "include_once" "goto"))) diff --git a/php-extras.el b/php-extras.el index ee8988b..5302aa9 100644 --- a/php-extras.el +++ b/php-extras.el @@ -5,7 +5,7 @@ ;; Author: Arne Jørgensen ;; URL: https://github.com/arnested/php-extras ;; Created: June 28, 2012 -;; Version: 2.0.0 +;; Version: 2.1.0 ;; Package-Requires: ((php-mode "1.5.0")) ;; Keywords: programming, php @@ -138,11 +138,17 @@ documentation for the inserted selection." (fboundp 'eldoc-message)) (eldoc-message (funcall eldoc-documentation-function))))) +(defun php-extras-function-documentation (symbol) + "Documentation for PHP function." + (php-extras-get-function-property symbol 'documentation)) + (defvar ac-source-php-extras '((candidates . php-extras-autocomplete-candidates) (candidate-face . php-extras-autocomplete-candidate-face) (selection-face . php-extras-autocomplete-selection-face) + (document . php-extras-function-documentation) (action . php-extras-ac-insert-action) + (symbol . "f") (cache)) "Auto complete source for PHP functions.")