Fork me on GitHub
#clojurescript
<
2021-03-11
>
Karol Wójcik08:03:23

Does anyone know any tools for generating api documentation out of source code for #clojurescript which are not either codeina or codox. The tool should would work well with cljc & shadow-cljs style of requires.

simongray10:03:37

There's Dynadoc by Zach Oakes.

simongray10:03:55

Not sure if that fits the bill.

Karol Wójcik13:03:50

Thanks @U4P4NREBY! Actually not really. The best option for me would be to run clj-doc so that it would generate html files.

fsd15:03:24

Hello there, I am JS dev, new to Clojure world. I have this function in JavaScript for mapbox and need help converting it to clojurescript. import data from './data.json'

const featuresLst = data.map(
    park => ({
        "type": 'Feature',
        "geometry":
        {
            "type": 'Point',
            "coordinates": [park.Longitude, park.Latitude]
        },
        "properties": {
            "marker-symbol": getImage(park),
            "title": [park.Name]
        }
    }));

p-himik15:03:24

You can't import data like that, but there are other means to achieve the same: https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745 Even if you're not using shadow-cljs, you can still use the same approach via macros. The rest you can do via JS interop. There's a section for that in this cheatsheet: https://cljs.info/cheatsheet/

p-himik15:03:18

This FAQ for JS devs might also be useful: https://clojurescript.org/guides/faq-js

fsd15:03:22

Ah I see @U2FRKM4TW thanks for the helpful info.

👍 3
fsd15:03:59

I tried this website https://roman01la.github.io/javascript-to-clojurescript/ for converting this piece of code but some reason it just does not process this.

const featuresLst = data.map(
    park => ({
        "type": 'Feature',
        "geometry":
        {
            "type": 'Point',
            "coordinates": [park.Longitude, park.Latitude]
        },
        "properties": {
            "marker-symbol": getImage(park),
            "title": [park.Name]
        }
    }));

p-himik15:03:13

Wrap the body of the arrow function in {return ...;}.

p-himik15:03:50

Huh, doesn't work with a "full" object but works with just {}. Eh, don't rely on this thing. Just go through the guides and convert it by hand.

👍 3
p-himik15:03:10

Or use the tool, but only for some small chunks of code - not for the whole thing.

👍 3
fsd16:03:23

Thanks for taking your time out 🙂

DoubleU22:03:07

I posted this in the beginners room, but I think it might be better to have it here: Hi All, bit of a newbie question here, but I have a form component in my clojurescript, and that component contains a form-input as a child (code below).  I’m trying to figure out how to dispatch an event back out to my component when the `on-blur` event is fired but not exactly sure how. With something like Angular, from within the component I could use the .emit(), in React, I could do something like onClick={someMethod} which would then call a method in my parent, but not sure how to do this in clojurescript (or if this is even possible).  Can someone provide some direction?

[form-input
          (utils/merge-fn-props {:on-input #(reset! value (-> % .-target .-value))
                                 :on-focus #(reset! focus? true)
                                 :on-blur #(reset! focus? false)}...

p-himik22:03:03

Saying "do it in ClojureScript" is like saying "do it in JavaScript". But you mention Angular and React, and the most probable corresponding thing in the ClojureScript world is Reagent. Almost always, you can do the exact same thing in Reagent that you can do in React. If you still can't figure it out, post the code that includes the parent component.

Joe Littlejohn23:03:01

I’m trying to override toString for a value so that I can get a custom string when I use the str function on it. I can see that people in the past have recommended just creating a type and overriding toString like you would in Clojure: https://groups.google.com/g/clojure/c/ARqsbic3F_8 https://stackoverflow.com/questions/48703654/convert-custom-type-into-string This seems to work great if I do (str x) , but if I do (str [x]) then the overridden toString is not used (and I see #object[something.core.MyType] instead. Is there something special about str for collections in ClojureScript that means it does not just perform str on each item inside?