Fork me on GitHub
#babashka
<
2022-09-07
>
Crispin04:09:29

Does anyone have any ideas on how I could generate documentation pages for a babashka pod... bear with me while I explain...

Crispin04:09:57

I have source on the classpath src/clj. And this builds the actual pod.

Crispin04:09:18

but I also have another source directory src/bb which is not on the classpath

Crispin04:09:00

the source from this directory is embedded into the compiling source with macros, so that it can be injected into the babashka runtime when the the pod is describe d

Crispin04:09:56

if its in the classpath, it cant compile. It fails with java.lang.ClassNotFoundException: babashka.pods (because I use the async invocation method for some functions, calling babashka.pods directly)

Crispin04:09:17

No it somes time to generate some docs, I turn to codox. But codox looks for its source on the classpath. So if src/bb is not on the classpath, it cant find the files. And if it is on the classpath, it wont compile, thus wont generate the docs.

Crispin04:09:59

Has anyone done something like this before? Generated documentation for a library that is outside the clojure compilation space?

Crispin04:09:11

Any other docgen tools?

Crispin04:09:33

I could preprocess the source code, remove the offending vars, and then codox that. thats one solution.

Crispin04:09:14

I'm just checking with the brains trust to see if anyone has done anything like this before

Crispin05:09:15

OK. I got something working by copying the source to a temp directory and quoting the offending vars so they dont get evaluated in compilation. Now codox is making docs! yay!

borkdude06:09:34

Have you tried #quickdoc ?

Crispin06:09:54

no. I'll have a look

Crispin06:09:12

hey cool. just generates markdown 👍

Crispin06:09:28

will have a use for this somewhere.

Crispin06:09:03

Ive got the codox docs looking pretty nice..

borkdude06:09:54

Another idea if you want to use codox: create fake source code or so programmatically? You might be able to use clj-easy stub

Crispin06:09:20

it turned out to be pretty easy, cause there was only one offending place

borkdude17:09:17

@flowthing it's not exposed because I didn't need to expose it yet and nobody asked for it yet

borkdude17:09:15

@flowthing but we could certainly expose it

flowthing17:09:03

I’d love to have it. 🙂

borkdude17:09:52

ok, let me try locally if it works at all, if I bind it into the SCI context

🙏 1
borkdude17:09:19

works and pushed to master

borkdude17:09:50

@flowthing now we're at it, let me also check this source-path thing

flowthing17:09:16

Many thanks once again!

borkdude17:09:35

I'm not so sure how things are affected by source-path

flowthing17:09:47

Yeah, it’s a bit weird.

borkdude17:09:57

should it just be added as a "dummy" thing, so you don't have to write the reader conditional?

borkdude17:09:28

in that case, I think writing the reader conditional might be better than adding it since adding it would maybe create the wrong expectations

flowthing17:09:42

Well, I wouldn’t mind that, at least. But I won’t feel bad about writing the reader conditional, either, now that I now I can use *file* to get the file name in the exception message.

flowthing17:09:04

Yes, I totally agree. It might just be confusing more than anything else.

borkdude17:09:18

OK, then I'll close the issue

flowthing17:09:02

It’s just clojure.main/ex-triage, clojure.main/ex-str, clojure.main/repl-exception, clojure.main/repl-caught, clojure.main/skip-whitespace, and clojure.lang.Compiler/load left for my use case. 🙂 They’re mostly nice-to-have, but do you have any feelings on whether it makes sense to put any effort into them?

borkdude17:09:33

I'm not sure how well they map on the SCI side of things. clojure.lang.Compiler/load won't work since SCI isn't a compiler

flowthing17:09:48

Yeah, I figured that might be a no-go.

flowthing17:09:05

Looking at the clojure.main ones, some of them do have a dependency to clojure.spec.

flowthing17:09:30

That makes things a bit difficult, I think.

borkdude17:09:40

I want to build spec into bb at one point (I have a branch of that). Right now you can run spec with bb but as a completely optional library that is not tied to anything built-in

flowthing17:09:49

Right. :thumbsup:

flowthing17:09:14

I think I can vendor in the bits from clojure.main I need for now and return to them if necessary. Once again, many thanks for this! I’ll start working on polishing Tutkain’s improved Babashka support into a shippable state. 🙂

🎉 1
borkdude17:09:56

Awesome. Happy to retweet something, if you're doing that kind of thing.

flowthing18:09:26

I don't use Twitter, but thanks. 🙂

flowthing19:09:27

Can/should vars have :file meta?

borkdude19:09:26

If they are defined in a file, yes

flowthing19:09:38

Ah, I see. So core vars won’t have it.

borkdude19:09:49

We can maybe continue in #babashka-sci-dev for the more technical details

👍 1
chaos19:09:47

Hi, if I have a top/bb.edn file and a top/subdir/bb.edn, is it possible to invoke a top/subdir/bb.edn task from within a top/bb.edn task? e.g. a solution would be to (babashka.process/shell {:dir "subdir"} "bb subtask")from within the top/bb.edn, but this would invoke a second bb process which is wasteful, thanks

borkdude19:09:32

@U012BL6D9GE this isn't possible, you could use babashka.process/exec if you want to "exec", i.e. replace the current process with a new bb instance. There is a discussion with some workarounds/ideas for this over https://github.com/babashka/babashka/discussions/1044

chaos19:09:24

thanks @U04V15CAJ, it would have certainly been a very feature to have. Do you happen to know if there is a way to get the pat to the currently running bb executable, so I'm sure to invoke the same bb exec with shell rather than the one found in PATH?

chaos19:09:16

*command-line-args* doesn't appear to include the name of the running exec, as it is customary with argv in c like languages

borkdude19:09:55

yes:

$ bb -e '(.get (.command (.info (java.lang.ProcessHandle/current))))'
"/Users/borkdude/dev/babashka/bb"

🙏 1
borkdude19:09:31

It is kind of complicated to implement what you asked for since bb would have to take into account deps and tasks from various places, merge them, etc. I fear that this will be a mess

borkdude19:09:38

there is also the "current working directory" problem

borkdude19:09:49

so I think doing this in user space would be best for now

chaos19:09:47

I think I can see the difficulty managing the same dependency but with different version numbers coming from subprojects

chaos19:09:26

I'm fine with user space as it is at the moment