wjb
2022-1-17 15:16:52

Hm. This doesn’t always work. On another machine, (collection-search '(lib "lib/lib.scrbl")) finds “lib/lib.scrbl” in a package in the same collection, except that file doesn’t exist in that package at all.


wjb
2022-1-17 15:30:01

Using this first command instead seems to work better scribble --dest ./build --dest-name lib --htmls --info-out build/lib.sxref +m --redirect-main "<https://docs.racket-lang.com>" `racket -e "(display (path-&gt;string (collection-file-path \"lib.scrbl\" \"lib\")))"`


wjb
2022-1-17 15:47:43

Is it expected that collection-search can return a path that doesn’t exist?


samth
2022-1-17 17:02:11

Probably you should avoid using display programmatically


samth
2022-1-17 17:02:26

I might use write-string there


wjb
2022-1-17 17:24:51

That wouldn’t work; the length of the string would end up as part of the path. Why not use display?


samth
2022-1-17 17:39:03

Display is intended for human readability, so it may make wrong choices for programmatic consumption


samth
2022-1-17 17:39:12

Eg, handling of newlines


wjb
2022-1-17 17:39:49

Noted. If there are newlines in the path I’ll deal with it then :stuck_out_tongue:


wjb
2022-1-17 18:07:24

Ahh (void (write-string …)) works


samth
2022-1-17 18:10:41

I think it doesn’t even look at the content of the paths that it produces


samth
2022-1-17 18:11:17

Is there a reason not to use collection-file-path?


wjb
2022-1-17 18:21:38

not as far as I know; i just discovered collection-search first


wjb
2022-1-17 18:23:38

I’m using collection-file-path now; it just seemed odd that collection-search could generate a bogus path.


blerner
2022-1-17 23:27:42

perhaps a naive question: I’m building scribble docs on WSL, using my Windows installation of Racket. Is there a way to force Scribble to use Unix (i.e. case-sensitive) paths? Or, is there a way to have a path-&gt;string/convention sort of function, that I could ensure produces Unix-convention paths?


blerner
2022-1-17 23:28:15

I’ve checked the Manipulating Paths section of the docs as thoroughly as I can, and don’t see any way to get this behavior


blerner
2022-1-17 23:29:23

the paths I need are simple, relative dir/dir/dir/file.foo sorts of things, so I suppose I could just string-substitute \ with / and call it done…but that seems brittle/incorrect


mflatt
2022-1-17 23:41:53

Are the relevant paths in generated HTML or somewhere else?


spdegabrielle
2022-1-18 00:12:38

Does (system-path-convention-type) return 'unix or 'windows under WSL?


spdegabrielle
2022-1-18 00:15:08

Maybe (system-type)?


mflatt
2022-1-18 00:15:14

From WSL, you can run either a Windows build or a Linux build (so, 'windows or 'unix, respectively). My guess is that @blerner wants a Windows build for DrRacket, at least.


blerner
2022-1-18 00:19:29

I have a Windows DrRacket installed, and if I can avoid installing a second racket within WSL, so much the better


blerner
2022-1-18 00:21:48

the relevant paths are generated by install-file, part of the html-renderer of scribble — though I have a bit of a wrapper around that method, since its handling of dest-prefix isn’t quite what I want (and that behavior apparently changed between v8.2 and v8.3, so I needed to go fix up my wrapper…) because it’s a Windows build of DrR, the paths have \ separators in them, which then make it into the generated HTML. but since the generated HTML is going to live on a Linux machine eventually, I (a) needed to re-process the generated paths to be case-sensitive, and (b) wanted to fix up those path separators


blerner
2022-1-18 00:22:43

(the case-*in*sensitivity happens automatically within the base-renderer, which simplifies paths. I happen to know that my directories are lowercase but my filenames might not be, so I can just redo the filenames as needed)


blerner
2022-1-18 00:23:05

(system-path-convention-type) returns ’windows


mflatt
2022-1-18 00:26:50

Are the generated paths in HTML absolute or relative? I’d expect only absolute paths to use \.


blerner
2022-1-18 00:27:44

relative


mflatt
2022-1-18 00:30:08

That sounds like a bug. I can imagine how install-file might go wrong that way, if that’s it. So, Scribble is trying to generate a reference to a file (that you asked it to add?), and it’s generating a relative URL with \?


blerner
2022-1-18 00:31:42

My overall scenario is, I have a project src-root directory and a dest-root directory, and I want the build to install-files such that their paths relative to dest-root match their paths relative to src-root. So I added a wrapper around the install-files method that manipulates the dest-prefix state within the render a bit, and then calls the superclass’s install-files. (This was something that versions < 8.2 couldn’t do at all, AFAICT, and the dest-prefix stuff in v8.3 doesn’t quite do what I think it does; if I’m misunderstanding it, that’s entirely possible…) But the result of the super-call gives a relative path with \ separators in it


mflatt
2022-1-18 00:41:10

If I run scribble --dest-base nested/ ..., on Windows, then the paths in HTML to support files end up with nested\ instead of nested/ (which is broken). That’s the problem you’re seeing, right?


blerner
2022-1-18 00:43:49

I suspect so, yes. I’m not currently using --dest-base at the command line, directly, but I think that’s what I’m seeing


mflatt
2022-1-18 01:17:22

It does seem like you can work around the bug by overriding install-file. When you get a string back, use split-path to break it into a list of components, use path-element-&gt;string to turn each element into a string, and hthen join the strings with a / separator. You may have to deal with 'up and 'same path components, but probably not.


mflatt
2022-1-18 01:17:27

Meanwhile, I’ll fix the bug.


blerner
2022-1-18 01:19:26

right, that’s ultimately what I’ll probably do. I was wondering if there were a more robust way of “format this #path as a Unix path string” besides “I’ll just manually insert all the /s”


mflatt
2022-1-18 01:19:46

There may be a relative-path-to-relative-url function somewhere. Seems like there should be, but I don’t remember.


blerner
2022-1-18 01:20:46

oho, yes — relative-path-&gt;relative-url-string is such a thing


mflatt
2022-1-18 01:20:54

Yes, I just found that, too :slightly_smiling_face:


blerner
2022-1-18 01:21:22

that’s intriguing…


blerner
2022-1-18 01:24:15

that does seem to work for my case. thanks!


blerner
2022-1-18 01:25:48

(hehe, looking at the implementation of that function…it just explode-paths the path and chunks it together with / — nothing super fancy :slightly_smiling_face: )