Function: cider--render-docstring

cider--render-docstring is a byte-compiled function defined in cider-docstring.el.

Signature

(cider--render-docstring ELDOC-INFO)

Documentation

Renders the docstring from ELDOC-INFO based on its length and content.

Prioritize rendering as much as possible while staying within cider-docstring-max-lines.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-docstring.el
(defun cider--render-docstring (eldoc-info)
  "Renders the docstring from ELDOC-INFO based on its length and content.
Prioritize rendering as much as possible while staying within `cider-docstring-max-lines'."
  (let* ((first-sentence-fragments (cider-plist-get eldoc-info "doc-first-sentence-fragments"))
         (body-fragments (cider-plist-get eldoc-info "doc-fragments"))
         (block-tags-fragments (cider-plist-get eldoc-info "doc-block-tags-fragments"))
         (block-tags-fragments-rendered (cider--fragments-to-s block-tags-fragments))
         (first-sentence-fragments-rendered) ;; mutable, for performance
         (first-attempt (when body-fragments
                          (concat (cider--fragments-to-s body-fragments)
                                  (when block-tags-fragments
                                    "\n\n")
                                  block-tags-fragments-rendered)))
         (first-attempt-invalid? (cider--attempt-invalid? first-attempt))
         (second-attempt (when (and first-sentence-fragments
                                    first-attempt-invalid?)
                           (setq first-sentence-fragments-rendered (cider--fragments-to-s first-sentence-fragments))
                           (concat first-sentence-fragments-rendered
                                   (when block-tags-fragments-rendered
                                     "\n\n")
                                   block-tags-fragments-rendered)))
         (second-attempt-invalid? (cider--attempt-invalid? second-attempt))
         (third-attempt (when (and block-tags-fragments-rendered
                                   first-attempt-invalid?
                                   second-attempt-invalid?)
                          block-tags-fragments-rendered))
         (third-attempt-invalid? (cider--attempt-invalid? third-attempt))
         (last-attempt (when (and first-sentence-fragments-rendered
                                  first-attempt-invalid?
                                  second-attempt-invalid?
                                  third-attempt-invalid?)
                         first-sentence-fragments-rendered)))
    (or last-attempt ;; the last attempt has to go first - it takes priority over an attempt deemed invalid.
        third-attempt
        second-attempt
        first-attempt)))