Fork me on GitHub

@alexmiller i think you could get 90% of the way there with a smaller change than a custom stylesheet - Safari etc’s reader mode is broken on the current site b/c div#preamble doesn’t match div.sect1


i think that if you just make all the seconds have the same class, then reader modes will treat it all as body text and that’s a de facto print mode

Alex Miller (Clojure team)03:01:53

most of that did not actually mean anything to me :)


each page in the reference has multiple divs, but only the first div shows up if you use an article reading filter

Alex Miller (Clojure team)03:01:21

I’m like a monkey banging rocks together in web programming


you on a mac? go to any reference page in safari and you’ll see a little paragraph icon in the top left corner of the url bar


there’s various plugins for all the other browsers that do that too


but since the “preamble” in the generated pages have different structure and style classes applied, only that first section gets treated as body text

Alex Miller (Clojure team)03:01:45

so just some tweaks might fix that


yup, and then people can print that view just fine

Alex Miller (Clojure team)03:01:34

ok, if I get a chance I’ll see if I can muggle my way through it


an aria hint might do the trick super quick too


🙂 ARIA = accessible rich internet applications


it’s about accessibility


screen readers etc


the simplest thing to try:


wrap the entire content of the page in a <article> tag


specifically, change the div with class clj-content-container from div to article - and see if that does it


i bet that it does, no impact to styles at all


no problem. hopefully that helps 🙂


i abuse reader mode and use huge fonts for most stuff i read 🙂 i have good eye sight and hope to keep it that way!

Alex Miller (Clojure team)03:01:40

I match my font size to my age


heh, i like it


@alexmiller could you take a look at this and confirm if I'm using instrument correctly or if there might actually be an underlying issue with :gen

Alex Miller (Clojure team)04:01:37

I will take a look in the morning


Maybe this is silly but say I have a spec like this (s/def ::dog (s/keys ::req [::name ::type ::sound])) but I also want to include a key that's always something specific like :feet 4 - so if I generate that I'll get like {:name "red" :type "golden retriever" :sound "woofwoof" :feet 4}


I want to do something like this:

(defmulti dog-type :dog/type)
(defmethod dog-type :golden-retriever [_]
  (s/keys :req [::name ::sound]))
But also have in the keys a type key that is dog-type and the actual key.


Is it possible to use spec to validate maps that has keys that are not namespaced, like :name instead of :user/name?


@teng Yes, with :req-un and :opt-un. Although they require namespaced keys for the specs, the actual map keys are unqualified.


(see the guide for more details)


@nick Do you mean you'd want (s/def ::feet #{4}) as the spec for the :feet key?


(clojure.spec/explain string? 123)
val: 123 fails predicate: :clojure.spec/unknown
How can I get the predicate to show string?


@odinodin I think you need to do (s/def ::string? string) and then you can (s/explain ::string? 123)


@dominicm thanks, makes sense 🙂

Alex Miller (Clojure team)13:01:20

This unknown is a bug that has a pending patch btw

Alex Miller (Clojure team)13:01:36

So that will work eventually


@alexmiller that is awesome 🙂

Alex Miller (Clojure team)15:01:36

@luxbock I agree that I’d expect something like this to work. I did just notice this line in the instrument docs though: ":gen overrides are used only for :stub generation.” which honestly surprises me. it seems like they should be used also for instrumented :args gen too.

Alex Miller (Clojure team)15:01:13

although maybe you should really be passing those :gen overrides in your call to check

Alex Miller (Clojure team)15:01:41

yeah, you should move your gen overrides map from instrument into the check options map. also, in the :gen map, the values should be no-arg functions that return the generator, not the actual generator, so just prefix all of them with # to turn them into anonymous no-arg functions

Alex Miller (Clojure team)15:01:27

once I did that, it was running, but I started getting OOMEs

Alex Miller (Clojure team)15:01:12

to address that, I narrowed the collection generators which default to max size 20. I added :gen-max 3 to both the fdef :args spec and the ::operations override gen.


@alexmiller ah yeah I think I tried :gen with check but I didn't realize that I need to wrap them in thunks


thanks, I will play around with it a bit more later today

Alex Miller (Clojure team)15:01:28

these days I generally preemptively add :gen-max 3 to all collection specs reachable by fdef :args or used in recursion

Alex Miller (Clojure team)15:01:51

I think it would be a good idea to change the default there from 20 to 3


yeah that's good to know as well

Alex Miller (Clojure team)15:01:19

if you’d like to vote :)


it feels that all the spec related testing functionality one needs to write these types of tests is quite spread out, both in terms of namespaces and where the different options for customizing the generators go


nothing that a good utility library won't fix, but I have a hard time keeping in my head where everything is supposed to come from and how it ties together

Alex Miller (Clojure team)15:01:35

well the stuff in spec vs spec.test is intentionally split to emphasize the parts that are designed specifically for testing. and spec.gen is the same - split out the part that dynamically loads and depends on test.check generators.

Alex Miller (Clojure team)15:01:48

those are at this point pretty well factored in my mind

Alex Miller (Clojure team)15:01:22

the gen overrides stuff is a bit messier and not consistent enough between s/exercise, stest/instrument, stest/check etc and we may still make some changes in those


I'm writing code which I can't fully test in use until it hits the production server so I'm trying to cover as many edge cases as possible with spec and generative tests to avoid the long feedback loop of deploy + test, and it's definitely giving me a lot more confidence in that I got rid of most of the silly bugs before trying it in actual use

Alex Miller (Clojure team)16:01:34

cool, that’s good to hear


quick noob question how do I limit the size of a number in spec like: (s/and int? pos?)


@ag: you can pass in arbitrary function


if you also need to generate, you need to write you rown generator

Alex Miller (Clojure team)21:01:32

@ag (s/and int? pos-int? #(< % 100)

Alex Miller (Clojure team)21:01:45

but once you start going there, consider integer ranges

Alex Miller (Clojure team)21:01:17

the range specs come with a better generator by default


ah, right… thanks @alexmiller


uh… so how do I make a spec for a key like this

:options {:on-click `~(fn [r] ,,,,)}
it contains an fn but in quoted form?


I guess I need s/fdef, how do I make a spec for something like {:on-click (fn [e],,,} - function that takes one argument of anything and returns whatever?