This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-05
Channels
- # announcements (7)
- # babashka (61)
- # beginners (146)
- # cider (4)
- # clj-kondo (25)
- # cljsrn (29)
- # clojars (30)
- # clojure (30)
- # clojure-australia (17)
- # clojure-europe (43)
- # clojure-italy (16)
- # clojure-nl (2)
- # clojure-spec (13)
- # clojure-sweden (7)
- # clojure-uk (8)
- # clojurescript (38)
- # cursive (12)
- # datomic (42)
- # defnpodcast (2)
- # dirac (1)
- # events (5)
- # fulcro (5)
- # graalvm (43)
- # graphql (11)
- # helix (6)
- # jackdaw (13)
- # jobs (4)
- # lambdaisland (8)
- # malli (12)
- # off-topic (83)
- # pathom (9)
- # podcasts-discuss (2)
- # re-frame (6)
- # reagent (3)
- # reitit (8)
- # remote-jobs (1)
- # shadow-cljs (40)
- # vim (21)
What kind of CSS framework/design system/principles would you recommend to help build a simple CSS based presentation?
Hi, I was wondering what mechanism(s) are available for documenting individual namespaced keywords. If there is no such approach in the language, how do you go about this? thx.
@thomasmoerman that question is totally on-topic 🙂 , which is off-topic in the off-topic room
you could always make a little table (a map) of keyword -> information about the keyword
it's slower and it makes two things that need to be synced
it's the moral equivalent of creating a set of "getFoo()" methods for the foo field on a Java class
I find it useful sometimes when I want to have like a global singleton I can use as data, e.g. in re-frame:
(def user-sub ::user-sub)
(rf/reg-sub user-sub ,,,)
(rf/subscribe [user-sub])
this is due to the fact that re-frame doesn't return a reified thing, of course; a little quirky
I don't see what value that provides over just using ::user-sub
@thomasmoerman if you use spec, you can make your own spec/def
wrapper that accepts an extra docstring argument
when you "jump to keyword" (cider does that) you would reach that definition
additionally, your wrapper can push the docstring to a registry that you would query with rebl or such
I've done exactly this, worked well
jump-to-def for keywords was implemented circa 2017 the compiler-check part is true but can also be tackled otherwise (e.g. intentful spec usage)
clojure-lsp now also has jump to keyword definition which works out of the box with clojure.spec and re-frame
@emccue that's not idiomatic so it won't work with typical code, and has been discussed already here: https://clojurians.slack.com/archives/C03RZGPG3/p1620220712458300
we aren't using spec, so having all the options listed out in the source code is beneficial
and autocompletion with ns/pr -> ns/process-state:a, ns/process-state:b, ...
is also helpful
I can heartily recommend use clojure-lsp. It works with the most widely used editors for clojure and provides this kind of navigation without introducing such a major workaround.
cursive lets me search for usages of a keyword and jump to definition if its being used in a specific set of forms like re-frame/reg-*
(ns a)
(defn record-transaction [source transaction-info]
(jdbc/execute ....)
(tracking/track {:event :recorded-transaction
:came-through source}))
(ns b)
(record-transaction ::a/email-blast { ... })
(record-transaction ::a/phone-call { ... })
so you mean, custom macros or functions that "register" something using a fully qualified keyword. and you want to navigate to those. yes, you can customize this using clj-kondo hooks in clojure-lsp.
(ns a)
(def source:email-blast ::email-blast)
(def source:phone-call ::phone-call)
(defn record-transaction [source transaction-info]
(jdbc/execute ....)
(tracking/track {:event :recorded-transaction
:came-through source}))
(ns b)
(record-transaction a/source:email-blast { ... })
(record-transaction a/source:phone-call { ... })
^ in debugging :some.ns/email-blast is still straightforward to track down. say if these are put into re-frame state or something
previous codebase would use (declare foo)
above macros that def'd things to get around static limitations like that. one benefit of nrepl for sure
I think the spec or malli way of doing that might be to define an "enum" of keywords, like (s/def const #{::email-blast})
Given the tools available currently (cider, paredit-functionality, LSP, clj-kondo, RDD) what language feedback features is Clojure lacking? e.g I feel like project wide refactors (e.g rename) are now reliable with LSP, a big missing piece. I'm left curious what else is out there?
is a good word for get-or-create
@alexmiller is "docstrings for keywords" a thing? I mean, it will be implemented in the future? Or it's not implemented because it's not a good idea? If this is implemented, it will be a "clojure" feature or a "spec" feature?
it's not a thing, and will not be implemented in the future
keywords are shared (interned) and may be used for more than one thing
that's a narrower context (I would not expect those to be stored on the keyword, but rather available via some api)
you can vote on docstring (https://ask.clojure.org/index.php/731/clojure-spec-def-should-support-an-optional-doc-string) and more general metadata for specs https://ask.clojure.org/index.php/9414/how-could-i-add-metadata-to-specs