Skip to content

Commit e91f946

Browse files
service-repl: elaborate portal page and add further examples
1 parent cc4d705 commit e91f946

File tree

1 file changed

+67
-14
lines changed

1 file changed

+67
-14
lines changed
Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,76 @@
11
# Portal
22

3-
Start Portal and capture all evaluation results over nrepl when portal middleware included, via `:repl/reloaded` or `:dev/reloaded` aliases from [Practicalli Clojure CLI Config](https://practical.li/clojure/clojure-cli/practicalli-config/).
3+
Start Portal and capture all evaluation results over nrepl when portal middleware included in the REPL startup.
44

5-
Optionally supply a [portal theme](https://cljdoc.org/d/djblue/portal/0.37.1/doc/ui-concepts/themes).
5+
All evaluation carried out over nREPL, i.e. between the connected editor and the Clojure REPL, will be sent to Portal.
6+
7+
Use [:fontawesome-solid-book-open: Practicalli Clojure CLI Config]() aliases or define your own alias in the project or user `deps.edn` file.
8+
9+
10+
=== "Practicalli Clojure CLI Config"
11+
`:repl/reloaded` aliases from [:fontawesome-solid-book-open: Practicalli Clojure CLI Config](https://practical.li/clojure/clojure-cli/practicalli-config/) starts a REPL process with Portal and nrepl middleware
12+
13+
Connect an editor to the REPL via the nREPL server port created during the REPL startup
14+
15+
!!! NOTE ""
16+
```shell
17+
clojure -M:repl/reloaded
18+
```
19+
20+
> `make repl` also launches Portal listening over nREPL in projects created with [:fontawesome-solid-book-open: Practicalli Project Templates](https://practical.li/clojure/clojure-cli/projects/templates/practicalli/)
21+
22+
23+
=== "Alias definition"
24+
25+
Define an alias that includes the portal library in the `:extra-deps` section and `portal.nrepl/wrap-portal` nrepl middleware in the `:main-opts` section with the `--middleware` flag.
26+
27+
!!! EXAMPLE "Clojure CLI alias including Portal & nREPL middleware"
28+
```clojure
29+
:repl/reloaded
30+
{:extra-paths ["dev" "test"]
31+
:extra-deps {nrepl/nrepl {:mvn/version "1.0.0"}
32+
cider/cider-nrepl {:mvn/version "0.37.0"}
33+
com.bhauman/rebel-readline {:mvn/version "0.1.4"}
34+
djblue/portal {:mvn/version "0.46.0"}
35+
clj-commons/clj-yaml {:mvn/version "1.0.27"}
36+
org.clojure/tools.namespace {:mvn/version "1.4.4"}
37+
org.clojure/tools.trace {:mvn/version "0.7.11"}
38+
org.slf4j/slf4j-nop {:mvn/version "2.0.9"}
39+
com.brunobonacci/mulog {:mvn/version "0.9.0"}
40+
lambdaisland/kaocha {:mvn/version "1.86.1355"}
41+
org.clojure/test.check {:mvn/version "1.1.1"}
42+
ring/ring-mock {:mvn/version "0.4.0"}
43+
criterium/criterium {:mvn/version "0.4.6"}}
44+
:main-opts ["-e" "(apply require clojure.main/repl-requires)"
45+
"--main" "nrepl.cmdline"
46+
"--middleware" "[cider.nrepl/cider-middleware,portal.nrepl/wrap-portal]"
47+
"--interactive"
48+
"-f" "rebel-readline.main/-main"]}
49+
```
50+
51+
## Launching Portal
652

753
!!! EXAMPLE "Start Portal listening to all evaluations"
8-
```clojure title="dev/portal.clj"
9-
(ns portal
10-
(:require
11-
[portal.api :as inspect]))
54+
```clojure title="dev/portal.clj"
55+
(ns portal
56+
(:require
57+
[portal.api :as inspect]))
58+
59+
(def instance
60+
"Open portal window if no portal sessions have been created.
61+
A portal session is created when opening a portal window"
62+
(or (seq (inspect/sessions))
63+
(inspect/open {:portal.colors/theme :portal.colors/gruvbox})))
64+
65+
;; Add portal as tapsource (add to clojure.core/tapset)
66+
(add-tap #'portal.api/submit)
67+
```
68+
69+
## Themes
1270

13-
(def instance
14-
"Open portal window if no portal sessions have been created.
15-
A portal session is created when opening a portal window"
16-
(or (seq (inspect/sessions))
17-
(inspect/open {:portal.colors/theme :portal.colors/gruvbox})))
71+
A [portal theme](https://cljdoc.org/d/djblue/portal/0.37.1/doc/ui-concepts/themes) can be specified when starting portal, e.g. `:portal.colors/gruvbox`.
1872

19-
;; Add portal as tapsource (add to clojure.core/tapset)
20-
(add-tap #'portal.api/submit)
21-
```
2273

74+
## Reference Docs
2375

76+
[Portal nREPL connection documentation](https://cljdoc.org/d/djblue/portal/0.46.0/doc/guides/nrepl){target=_blank .md-button}

0 commit comments

Comments
 (0)