Skip to content

Commit b8920e8

Browse files
authored
docs: readme: update contributors (#22)
Switch to using etaoin for generating contributor badges (mostly borrowed from work I did on cljdoc).
1 parent 88e139a commit b8920e8

16 files changed

Lines changed: 302 additions & 140 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{:linters
2+
{:etaoin/with-x-action {:level :error}
3+
:etaoin/binding-sym {:level :error}
4+
:etaoin/opts-map-type {:level :error}
5+
:etaoin/opts-map-pos {:level :error}
6+
:etaoin/empty-opts {:level :warning}}
7+
:hooks
8+
{:analyze-call
9+
{etaoin.api/with-chrome etaoin.api/with-browser
10+
etaoin.api/with-chrome-headless etaoin.api/with-browser
11+
etaoin.api/with-firefox etaoin.api/with-browser
12+
etaoin.api/with-firefox-headless etaoin.api/with-browser
13+
etaoin.api/with-edge etaoin.api/with-browser
14+
etaoin.api/with-edge-headless etaoin.api/with-browser
15+
etaoin.api/with-phantom etaoin.api/with-browser
16+
etaoin.api/with-safari etaoin.api/with-browser
17+
18+
etaoin.api/with-driver etaoin.api/with-driver
19+
etaoin.api/with-key-down etaoin.api/with-key-down
20+
etaoin.api/with-pointer-btn-down etaoin.api/with-pointer-btn-down
21+
22+
;; api2 moves to a more conventional let-ish vector syntax
23+
etaoin.api2/with-chrome etaoin.api2/with-browser
24+
etaoin.api2/with-chrome-headless etaoin.api2/with-browser
25+
etaoin.api2/with-edge etaoin.api2/with-browser
26+
etaoin.api2/with-edge-headless etaoin.api2/with-browser
27+
etaoin.api2/with-firefox etaoin.api2/with-browser
28+
etaoin.api2/with-firefox-headless etaoin.api2/with-browser
29+
etaoin.api2/with-phantom etaoin.api2/with-browser
30+
etaoin.api2/with-safari etaoin.api2/with-browser}}
31+
:lint-as
32+
{etaoin.api/with-pointer-left-btn-down clojure.core/->}}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
(ns etaoin.api
2+
(:require [clj-kondo.hooks-api :as api]
3+
[etaoin.hooks-util :as h]))
4+
5+
(defn- nil-node? [n]
6+
(and (api/token-node? n) (nil? (api/sexpr n))))
7+
8+
(defn- with-bound-arg [node arg-offset]
9+
(let [macro-args (rest (:children node))
10+
leading-args (take arg-offset macro-args)
11+
interesting-args (drop arg-offset macro-args)
12+
[opts binding-sym & body] (if (h/symbol-node? (second interesting-args))
13+
interesting-args
14+
(cons nil interesting-args))]
15+
;; if the user has specified nil or {} for options we can suggest that is not necessary
16+
(when (and opts
17+
(or (and (api/map-node? opts) (not (seq (:children opts))))
18+
(nil-node? opts)))
19+
(api/reg-finding! (assoc (meta opts)
20+
:message "Empty or nil driver options can be omitted"
21+
:type :etaoin/empty-opts)))
22+
23+
(cond
24+
(not (h/symbol-node? binding-sym))
25+
;; it makes more sense here to report on the incoming node position instead of what we expect to be the binding-sym
26+
(api/reg-finding! (assoc (meta node)
27+
:message "Expected binding symbol for driver"
28+
:type :etaoin/binding-sym))
29+
30+
;; we don't want to explicitly expect a map because the map might come from
31+
;; an evalution, but we can do some checks
32+
(and opts ;; we'll assume a list-node is a function call (eval)
33+
(not (nil-node? opts)) ;; nil is actually old-v1 syntax acceptable
34+
(not (api/list-node? opts)) ;; some fn call
35+
(not (h/symbol-node? opts)) ;; from a binding maybe
36+
;; there are other eval node types... @(something) for example... maybe we'll add them in if folks ask
37+
(not (api/map-node? opts)))
38+
;; we can report directly on the opts node, because at this point we know we expect
39+
;; this arg position to be an opts map
40+
(api/reg-finding! (assoc (meta opts)
41+
:message "When specified, opts should be a map"
42+
:type :etaoin/opts-map-type))
43+
44+
;; one last nicety, if the first form in body is a map, the user has accidentally swapped
45+
;; binding and opt args
46+
(api/map-node? (first body))
47+
(api/reg-finding! (assoc (meta (first body))
48+
:message "When specified, opts must appear before binding symbol"
49+
:type :etaoin/opts-map-pos))
50+
51+
:else
52+
{:node (api/list-node
53+
(list*
54+
(api/token-node 'let)
55+
;; simulate the effect, macro is creating a new thing (driver for example)
56+
;; via binding it. I don't think the bound value matters for the linting process
57+
(api/vector-node [binding-sym (api/map-node [])])
58+
;; reference the other args so that they are not linted as unused
59+
(api/vector-node leading-args)
60+
opts ;; might be a binding, so ref it too
61+
body))})))
62+
63+
(defn- with-x-down
64+
"This is somewhat of a maybe an odd duck.
65+
I think it is assumed to be used within a threading macro.
66+
And itself employs a threadfirst macro.
67+
So each body form need to have an action (dummy or not) threaded into it."
68+
[node]
69+
(let [macro-args (rest (:children node))
70+
[input x & body] macro-args
71+
dummy-action (api/map-node [])]
72+
{:node (api/list-node
73+
(apply list*
74+
(api/token-node 'do)
75+
;; reference x and input just in case they contain something lint-relevant
76+
x input
77+
;; dump the body, threading a dummy action in as first arg
78+
(map (fn [body-form]
79+
(cond
80+
;; not certain this is absolutely what we want, but maybe close enough
81+
(h/symbol-node? body-form) (api/list-node (list* body-form dummy-action))
82+
(api/list-node? body-form) (let [children (:children body-form)]
83+
(assoc body-form :children (apply list*
84+
(first children)
85+
dummy-action
86+
(rest children))))
87+
:else
88+
(api/reg-finding! (assoc (meta body-form)
89+
:message "expected to be threaded through an action"
90+
:type :etaoin/with-x-action))))
91+
body)))}))
92+
93+
(defn with-browser
94+
"Covers etaoin.api/with-chrome and all its variants
95+
[opt? bind & body]"
96+
[{:keys [node]}]
97+
(with-bound-arg node 0))
98+
99+
(defn with-driver
100+
"Very similar to with-browser but bound arg is 1 deeper
101+
[type opt? bind & body]"
102+
[{:keys [node]}]
103+
(with-bound-arg node 1))
104+
105+
(defn with-key-down
106+
"[input key & body]"
107+
[{:keys [node]}]
108+
(with-x-down node))
109+
110+
(defn with-pointer-btn-down
111+
"[input button & body]"
112+
[{:keys [node]}]
113+
(with-x-down node))
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(ns etaoin.api2
2+
(:require [clj-kondo.hooks-api :as api]
3+
[etaoin.hooks-util :as h]))
4+
5+
(defn with-browser
6+
"Newer variants for api2
7+
[[bind & [options]] & body]"
8+
[{:keys [node]}]
9+
(let [macro-args (rest (:children node))
10+
binding-like-vector (first macro-args)]
11+
(if-not (api/vector-node? binding-like-vector)
12+
;; could use clj-kondo findings, but I think this is good for now
13+
(throw (ex-info "Expected vector for first arg" {}))
14+
(let [binding-sym (-> binding-like-vector :children first)]
15+
(if-not (h/symbol-node? binding-sym)
16+
(throw (ex-info "Expected binding symbol for first arg in vector" {}))
17+
(let [other-args (rest binding-like-vector)
18+
body (rest macro-args)]
19+
{:node (api/list-node
20+
(list*
21+
(api/token-node 'let)
22+
;; simulate the effect, macro is creating a new thing (driver for example)
23+
;; via binding it. I don't think the bound value matters for the linting process
24+
(api/vector-node [binding-sym (api/map-node [])])
25+
;; reference the other args so that they are not linted as unused
26+
(api/vector-node other-args)
27+
body))}))))))
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(ns etaoin.hooks-util
2+
(:require [clj-kondo.hooks-api :as api]))
3+
4+
(defn symbol-node? [node]
5+
(and (api/token-node? node)
6+
(symbol? (api/sexpr node))))

README.adoc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,26 @@ Test-doc-block versioning scheme is: `major`.`minor`.`patch`-`test-qualifier`
6262
// Contributors updated by script, do not edit
6363
// AUTO-GENERATED:CONTRIBUTORS-START
6464
:imagesdir: ./doc/generated/contributors
65-
[.float-group]
65+
[]
6666
--
67-
image:seancorfield.png[seancorfield,role="left",width=310,link="https://github.com/seancorfield"]
68-
image:MIJOTHY.png[MIJOTHY,role="left",width=310,link="https://github.com/MIJOTHY"]
69-
image:borkdude.png[borkdude,role="left",width=310,link="https://github.com/borkdude"]
70-
image:holyjak.png[holyjak,role="left",width=310,link="https://github.com/holyjak"]
71-
image:PEZ.png[PEZ,role="left",width=310,link="https://github.com/PEZ"]
72-
image:SevereOverfl0w.png[SevereOverfl0w,role="left",width=310,link="https://github.com/SevereOverfl0w"]
73-
image:sogaiu.png[sogaiu,role="left",width=310,link="https://github.com/sogaiu"]
74-
image:uochan.png[uochan,role="left",width=310,link="https://github.com/uochan"]
67+
image:seancorfield.png[seancorfield,width=273,link="https://github.com/seancorfield"]
68+
image:MIJOTHY.png[MIJOTHY,width=273,link="https://github.com/MIJOTHY"]
69+
image:borkdude.png[borkdude,width=273,link="https://github.com/borkdude"]
70+
image:holyjak.png[holyjak,width=273,link="https://github.com/holyjak"]
71+
image:PEZ.png[PEZ,width=273,link="https://github.com/PEZ"]
72+
image:SevereOverfl0w.png[SevereOverfl0w,width=273,link="https://github.com/SevereOverfl0w"]
73+
image:sogaiu.png[sogaiu,width=273,link="https://github.com/sogaiu"]
74+
image:uochan.png[uochan,width=273,link="https://github.com/uochan"]
7575
--
7676
// AUTO-GENERATED:CONTRIBUTORS-END
7777

7878
=== Current Maintainers
7979
// Maintainers updated by script, do not edit
8080
// AUTO-GENERATED:MAINTAINERS-START
8181
:imagesdir: ./doc/generated/contributors
82-
[.float-group]
82+
[]
8383
--
84-
image:lread.png[lread,role="left",width=310,link="https://github.com/lread"]
84+
image:lread.png[lread,width=273,link="https://github.com/lread"]
8585
--
8686
// AUTO-GENERATED:MAINTAINERS-END
8787

bb.edn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
:deps {lread/status-line {:git/url "https://github.com/lread/status-line.git"
44
:sha "cf44c15f30ea3867227fa61ceb823e5e942c707f"}
55
dev.nubank/docopt {:mvn/version "0.6.1-fix7"}
6-
version-clj/version-clj {:mvn/version "2.0.2"}}
6+
version-clj/version-clj {:mvn/version "2.0.2"}
7+
etaoin/etaoin {:mvn/version "1.0.40"}}
78

89
:tasks {;; setup
910
:requires ([babashka.fs :as fs]
1014 Bytes
Loading

doc/generated/contributors/PEZ.png

-1.91 KB
Loading
-285 Bytes
Loading
-158 Bytes
Loading

0 commit comments

Comments
 (0)