Skip to content

Commit

Permalink
pr
Browse files Browse the repository at this point in the history
  • Loading branch information
samhedin committed Jan 30, 2022
1 parent 0df1ad8 commit f8500e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 29 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ jobs:
- name: rustic-doc prerequisites
run: |
wget https://github.com/jgm/pandoc/releases/download/2.17.0.1/pandoc-2.17.0.1-1-amd64.deb
sudo dpkg -i pandoc-2.17.0.1-1-amd64.deb
mkdir -p ~/.local/bin
mkdir -p ~/.local/share/emacs/rustic-doc/std/
cargo install fd-find
Expand Down
49 changes: 22 additions & 27 deletions rustic-doc.el
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,12 @@ Search for SEARCH-TERM inside SEARCH-DIR"
(t
(grep (format "grep -RPIni '%s' %s" search-term search-dir)))))


(defcustom rustic-doc-search-function 'rustic-doc-default-search-function
"Function to use for searching documentation.
The function should take search-dir and search-term as arguments."
:type 'function
:group 'rustic-doc)



(defun rustic-doc--install-resources ()
"Install or update the rustic-doc resources."
(dolist (resource rustic-doc-resources)
Expand Down Expand Up @@ -265,7 +262,8 @@ If the user has not visited a project, returns the main doc directory."
(message "Converting documentation for %s "
rustic-doc-current-project)
;; Spawn a new shell that cd's into `rustic-doc-current-project' and converts the packages.
(message (format "cargo makedocs: %s" (shell-command-to-string (format "sh -c \"cd %s; %s makedocs\"" rustic-doc-current-project (rustic-cargo-bin)))))
(message (format "cargo makedocs: %s" (shell-command-to-string
(format "sh -c \"cd %s; %s makedocs\"" rustic-doc-current-project (rustic-cargo-bin)))))
(let* ((docs-src
(concat (file-name-as-directory rustic-doc-current-project)
"target/doc"))
Expand All @@ -280,34 +278,30 @@ If the user has not visited a project, returns the main doc directory."
(rustic-doc--project-doc-dest))))
(message "Activate rustic-doc-mode to run `rustic-doc-convert-current-package")))


(defun rustic-doc--confirm-dep-versions (missing-fd)
"Verify that dependencies are not too old."
(when (not missing-fd)
(when (> 8 (string-to-number
(substring (shell-command-to-string "fd --version") 3 4)))
(message "Your version of fd is too old, please install a recent version, maybe through cargo."))))


(defun rustic-doc-install-deps (&optional noconfirm)
"Install dependencies with Cargo.
If NOCONFIRM is non-nil, install all dependencies without prompting user."
(if (not (executable-find "cargo"))
(message "You need to have cargo installed to use rustic-doc")
(rustic-doc--install-pandoc)
(let ((missing-rg (not (executable-find "rg")))
(missing-fd (and (not (executable-find "fd") )))
(missing-makedocs (not (executable-find "cargo-makedocs"))))
(rustic-doc--confirm-dep-versions missing-fd)
(when (and (or missing-fd missing-makedocs missing-rg)
(or noconfirm (y-or-n-p "Missing some dependencies for rustic doc, install them? ")))
(when missing-fd
(rustic-doc--start-process "install-fd" "cargo" nil "install" "fd-find"))
(when missing-rg
(rustic-doc--start-process "install-rg" "cargo" nil "install" "ripgrep"))
(when missing-makedocs
(rustic-doc--start-process "install-makedocs" "cargo" nil
"install" "cargo-makedocs"))))))
(rustic-doc--install-pandoc)
(let ((missing-rg (not (executable-find "rg")))
(missing-fd (and (not (executable-find "fd") )))
(missing-makedocs (not (executable-find "cargo-makedocs"))))
(rustic-doc--confirm-dep-versions missing-fd)
(when (and (or missing-fd missing-makedocs missing-rg)
(or noconfirm (y-or-n-p "Missing some dependencies for rustic doc, install them? ")))
(when missing-fd
(rustic-doc--start-process "install-fd" "cargo" nil "install" "fd-find"))
(when missing-rg
(rustic-doc--start-process "install-rg" "cargo" nil "install" "ripgrep"))
(when missing-makedocs
(rustic-doc--start-process "install-makedocs" "cargo" nil
"install" "cargo-makedocs")))))

;;;###autoload
(defun rustic-doc-setup (&optional no-dl noconfirm)
Expand All @@ -318,6 +312,7 @@ NO-DL is primarily used for development of the filters.
If NOCONFIRM is non-nil, install all dependencies without prompting user."
(interactive)
(rustic-doc-mode)
(print "HELLO WORLD FROM SETUP" #'external-debugging-output)
(unless no-dl
(rustic-doc--install-resources)
(rustic-doc-install-deps noconfirm))
Expand All @@ -328,7 +323,7 @@ If NOCONFIRM is non-nil, install all dependencies without prompting user."
(lambda (_p)
(message "Finished converting docs for std"))
"std")
(if rustic-doc-current-project
(if rustic-doc-current-project
(rustic-doc-convert-current-package)
(message "Setup is converting std. If you want to convert local dependencies, activate rustic-doc-mode when you are in a rust project and run `rustic-doc-convert-current-package")))

Expand All @@ -344,10 +339,10 @@ If NOCONFIRM is non-nil, install all dependencies without prompting user."
See the *Messages* buffer or %s for more info." event (concat "*" name "*"))
(when finish-func
(funcall finish-func proc))
(when (buffer-live-p buf)
(print (with-temp-buffer buf
(buffer-string )))
(kill-buffer buf))))))
;; (when (buffer-live-p buf)
;; (kill-buffer buf))
(print )
))))
proc))

(defun rustic-doc--thing-at-point ()
Expand Down

0 comments on commit f8500e6

Please sign in to comment.