pocmatos
2018-6-20 10:50:07

@mflatt I know this is an old one and I just found it by chance. Is it correct to mark here https://github.com/racket/racket/commit/006ffc8ae385407be7fd91b0429becaed43ba677 scribble/srcdoc as deprecated?


pocmatos
2018-6-20 10:51:24

I am curious, are there any example usages of scribble/srcdoc in the wild? Racket seems to encourage the separation of source and documention but I still find it easier to document APIs as I code on the same file.


pocmatos
2018-6-20 10:53:11

@mbutterick Was the printed version of TfL also created in Pollen? Or since it was not web-based, you had to rely on other tools? https://legalsolutions.thomsonreuters.com/law-products/Practice-Materials/Typography-for-Lawyers-2018-ed/p/105523076


greg
2018-6-20 13:43:20

@pocmatos I’ve used scribble/srcdoc in some Frog docs: https://github.com/greghendershott/frog/search?q=srcdoc&unscoped_q=srcdoc (FWIW I found it more convenient to use a define-doc wrapper around proc-doc/names than to use it directly. The macro defines the function, the docs, and some examples/tests.)


greg
2018-6-20 13:48:39

Not sure I’d say Racket encourages separation of source and documentation. It’s more the case that it lacked a good way to combine them, until relatively recently. Much like it lacked a good way to combine source and tests, until submodules and (module+ test ___) was added. Then people started to use combined source/tests. scribble/srcdoc is more recent, and the ergonomics aren’t quite as spiffy, and people write fewer docs than tests <— is why I think there are so few examples in the wild.


greg
2018-6-20 13:49:54

usually feels source, tests, and docs are three sides of the same coin :)


githree
2018-6-20 14:10:46

I was wondering - were there any attempts in Racket to combine scribble + tests -> the tests would then be used as examples in documentation


githree
2018-6-20 14:13:04

I would envisage this could encourage people to write docs alongside the code and I always found docs with examples to be more meaningful


greg
2018-6-20 14:14:29

@mflatt Oh! I didn’t realize that manual action was needed to make it work the first time. Maybe I did this and forgot it, in an older Racket. And IIUC doing this in DrR would cause the pkg/lib package-suggestions-for-module to then work outside DrR (and in racket-mode).


greg
2018-6-20 14:15:55

I’ll try to do the equivalent of this in racket-mode. Probably do what you said: if mismatch then just set db to current catalogs config.


greg
2018-6-20 14:15:57

Thanks!


mflatt
2018-6-20 14:16:24

Sounds right. I just pushed a change to “gui-pkg-manager” to make DrRacket’s “Update” button work.


greg
2018-6-20 14:17:08

@githree Yes. Please see my message just before yours. :slightly_smiling_face:


greg
2018-6-20 14:17:39

greg
2018-6-20 14:19:12

(Caveat: I wrote that for my immediate need in Frog. It’s under private/. I’m not offering it as a role model. or correct in all scenarios.)


githree
2018-6-20 14:22:05

great - the name could be more meaningful though :stuck_out_tongue: Do you have any examples of its use - I couldn’t find single use on frog repository


githree
2018-6-20 14:23:25

oh, sorry, just found it


greg
2018-6-20 14:23:32

greg
2018-6-20 14:23:37

Yes. :slightly_smiling_face:


greg
2018-6-20 14:23:48

No worries


greg
2018-6-20 14:30:41

I mean, I don’t love the result. A define-doc usage has a lot going on. There are pros and cons to shoving everything into one form, vs. simple proximity in the file. It’s kind of like using a separate (: ___) annotation form in TR, vs. putting the types in the define signature. Or like define/contract vs. (provide (contract-out ___)). It’s somewhat a matter of taste.


greg
2018-6-20 14:31:00

The one added wrinkle with this, though, is duplicating the argument names in two places.


greg
2018-6-20 14:31:33

That makes the “proximity” option a lot less appealing, for me.


greg
2018-6-20 14:32:41

So IDK all the possibilities for the ergonomics of this. If I thought my private define-doc macro were awesome sauce, I’d make a package. But I don’t and I didn’t. I’m just answering the “are there examples in the wild?” question. Yes, I have one. It is… an example. :slightly_smiling_face:


githree
2018-6-20 14:33:45

sure, thanks for the answer


githree
2018-6-20 14:38:44

what I am thinking about is more about moving definition of contracts + test to scribble file directly so, e.g. contract definition could be used to also generate scribble defproc + tests would then generate scribble examples. I am not sure it would even work - just an idea


githree
2018-6-20 14:40:51

defproc/contract and test-case/example


githree
2018-6-20 14:46:30

this would make writing contracts equivalent to writing documentation and writing tests equivalent to writing examples in this documentation so the gravity centre would move in the direction of scribble files.


githree
2018-6-20 14:54:37

@greg my suggestion wouldn’t shove everything into one form, instead contracts and tests would sit nicely under specific procedure section in the documentation… if it is at all feasible :grin:


greg
2018-6-20 15:03:26

I’m a bit distracted because I need to work on something else now, but. I think that seems like another good way people might want to do it. Feasible? I’m not sure how contracts defined in some.scrbl are effected for definitions in some.rkt. It seems like some.rkt must be the thing that provides the definitions with contract wrappers (e.g. via define/contract, contract-out, or friends). Maybe some.scrbl must provide contracts and some.rkt must require and use those…? I don’t immediately see how the pieces fit together the resulting ergonomics. But I’m not saying it would be impossible or bad. idk.


githree
2018-6-20 15:05:26

the crossreference is the main reason why I am not sure about feasibility


greg
2018-6-20 15:05:56

Yep. Oh also to run the tests in some.scrbl you need the definitions from some.rkt so um… ¯_(ツ)_/¯


greg
2018-6-20 15:06:38

You could just define the function some.scrbl and have no some.rkt at all. Instead of srcdoc you have docsrc. :slightly_smiling_face:


githree
2018-6-20 15:07:42

that would be full blown literate programming - I was thinking more about literate testing/contracting


githree
2018-6-20 15:07:57

scribble doc -> API to the src


greg
2018-6-20 16:48:26

Off the top of their head does anyone know of two packages supplying a module of the same name? e.g. pkg-a and pkg-b both supply a module foo? [Why: I want to exercise a package-suggestions feature for the case (require foo). I know I can write some Racket code to trawl all the supplied modules in catalogs to try to find an example, and this would be a fun exercise if I had more time, but first I’m trying “Dear Lazy Slack”.]


mflatt
2018-6-20 16:53:14

The pkg-build conflicts list has all of those: http://pkg-build.racket-lang.org/conflicts.txt


greg
2018-6-20 17:33:16

Thanks! (require no-debug/syntax) is a good test case; package suggestions are mischief and mischief-dev.


ben
2018-6-20 18:41:45

add prints to find out where its slow, and maybe cache slow things :/


leif
2018-6-20 20:30:06

@mflatt (Or whoever maintains the racket/serialize collection these days), is there a way I can intercept the deserializers dynamic-require and replace it with another module.


leif
2018-6-20 20:30:39

Or rather, is there any way I can give it a fallback if it fails to require the module.


leif
2018-6-20 20:31:10

deserialize-module-guard looks like it almost does what I want, but only gets run for its effects. (Which seem to be throwing errors.)


leif
2018-6-20 20:41:25

And if it doesn’t exist, would it be a bad idea to add a ‘fallback’ hook to the library?


leif
2018-6-20 21:07:29

mflatt
2018-6-20 21:21:59

@leif That idea looks ok to me.


leif
2018-6-20 21:38:27

Okay cool. I’ll add docs and tests. Thanks. :slightly_smiling_face:


notjack
2018-6-21 02:48:23

sad :(


greg
2018-6-21 04:26:41

At some point I learned that, when requiring modules within a collection, it’s best to use relative paths. I recall someone (Eli?) explaining why at the time. But… I no longer remember the why. I just keep doing it — even though sometimes it’s a bit ugly. e.g. in collection/private/sub/foo.rkt, something like (require "../../bar.rkt") instead of (require collection/bar.rkt). But recently I’m noticing code that doesn’t use relative paths. Maybe it used to matter, but doesn’t anymore? Or if it does still matter, why?


greg
2018-6-21 04:28:34

Is it better only because relative paths will still work even if you haven’t raco linked the collection, or raco pkg installed the collection as a package?


notjack
2018-6-21 04:46:03

@greg I think the rule is that across your codebase you shouldn’t require the same module twice as both a file path and as a collection, but I’m not sure about that


notjack
2018-6-21 04:50:12

Lately I’ve switched to exclusively using collection paths and it’s been a pleasant experience