Skip to content

Commit

Permalink
Rustic-doc report error, better way to find number of cores on macos (#…
Browse files Browse the repository at this point in the history
…228)

* Do not finish setup if script exited abnormally

* Do not use nproc if on macos

* Better name for buffer

* Update README

* Remove gif (might make a nicer one later)

* Remove double * in process name

* Add rustic-doc image to readme

* update readme. formatting
  • Loading branch information
samhedin authored Mar 8, 2021
1 parent 4e757e3 commit 270bc5a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,18 +463,19 @@ In case you want to use a different spinner type you can modify `rustic-spinner-
## inline-documentation

With some setup, it is possible to read rust documentation inside Emacs! This currently requires LSP-mode.
![Rustic-doc example](img/rustic-doc.png)

### Prequisites

* Install Pandoc https://pandoc.org/installing.html
* Install cargo https://doc.rust-lang.org/cargo/getting-started/installation.html
* Install helm-ag https://github.com/emacsorphanage/helm-ag (Optional, but highly recommended)
If you do not have them, you will be prompted to install `fd-find`, `ripgrep` and `cargo-makedocs` when you run `rustic-doc-setup`.
`ripgrep` is optional but highly recommended.
If helm-ag and ripgrep is installed, those will be used by default.
If only ripgrep is installed, it will be used with the emacs `grep` command.
If neither is installed, the emacs `grep` command will use `grep`, like in the good old days.
You can change this by providing your own search function by changing `rustic-doc-search-function`.
* If you do not have them, you will be prompted to install `fd-find`, `ripgrep` and `cargo-makedocs` when you run `rustic-doc-setup`.
* `ripgrep` is optional but highly recommended.
* If helm-ag and ripgrep is installed, those will be used by default.
* If only ripgrep is installed, it will be used with the emacs `grep` command.
* If neither is installed, the emacs `grep` command will use `grep`, like in the good old days.
* You can change this by providing your own search function by changing `rustic-doc-search-function`.

### Usage

Expand Down
Binary file added img/rustic-doc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 10 additions & 6 deletions rustic-doc.el
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ If the user has not visited a project, returns the main doc directory."
;; strings out of cargo, or just parse the Cargo.toml file, but
;; then we'd have to review different parsing solutions.
(finish-func (lambda (_p)

(message (format "Finished converting docs for %s"
rustic-doc-current-project)))))
(rustic-doc-create-project-dir)
Expand Down Expand Up @@ -276,7 +277,7 @@ If the user has not visited a project, returns the main doc directory."
(message "Setup is converting the standard library")
(delete-directory (concat rustic-doc-save-loc "/std")
t)
(rustic-doc--start-process "*rustic-doc-std-conversion*"
(rustic-doc--start-process "rustic-doc-std-conversion"
rustic-doc-convert-prog
(lambda (_p)
(message "Finished converting docs for std"))
Expand All @@ -287,14 +288,17 @@ If the user has not visited a project, returns the main doc directory."
(proc (let ((process-connection-type nil))
(apply #'start-process name buf program program-args))))
(set-process-sentinel
proc (lambda (proc _event)
proc (lambda (proc event)
(let ((buf (process-buffer proc)))
(when finish-func
(funcall finish-func proc))
(when (buffer-live-p buf)
(kill-buffer buf)))))
(if (string-match-p (regexp-quote "abnormally") event)
(message "Could not finish process: %s. See the *Messages* buffer or %s for more info." event (concat "*" name "*"))
(when finish-func
(funcall finish-func proc))
(when (buffer-live-p buf)
(kill-buffer buf))))))
proc))


(defun rustic-doc--thing-at-point ()
"Return info about `thing-at-point'. If `thing-at-point' is nil, return defaults."
(if-let ((active lsp-mode)
Expand Down
7 changes: 6 additions & 1 deletion rustic-doc/convert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ BEGIN { m = length(PRE)
' \
> "$ignore_file"

if [[ "$OSTYPE" == "darwin"* ]]; then
cores=$(eval "$sysctl -n hw.logicalcpu")
else
cores=$(nproc)
fi
## Convert files
fd . \
-ehtml \
--ignore-file "$ignore_file" \
-j"$(nproc)" \
-j"$cores" \
-x pandoc '{}' \
--lua-filter "$LUA_FILTER" \
-o "$DEST_DIR/{.}.org"

0 comments on commit 270bc5a

Please sign in to comment.