Docc on Windows?

Hello,

I'm learning Swift but (unfortunately) I have to use Windows because if I will end up using Swift, it will be for Windows.

After installing Swift 5.9, I can't find any docc executable, to build documentation. So I tried to compile it from it's source code, but it failed.

Is Docc supposed to work at all on Windows?
If not, are there alternatives?

DocC is not yet supported on Windows, but people are working on it, cf. this roadmap for progress for some Windows related issues.

2 Likes

Thank you Stefan

There are a couple of patches required to support this, but they should be available on GitHub. SwiftDocC: use "portable" paths for file names by compnerd · Pull Request #668 · apple/swift-docc · GitHub might be the important one. There is some work that is needed in the render Vue application to get the adjusted behaviour for portable file names that needs to be worked out, but most of the other issues should've been worked out.

The Preview Server is not avalable on Windows due to NIO being a dependency, but you can use python as a stand in (IIRC, python -m http.server -d . in the generated docc bundle).

Verified that the one mentioned patch is just the remaining piece for enabling DocC.

Generating the documentation should be:

swift package generate-documentation --output-path docs --transform-for-static-hosting --target ...

You can use python's builtin web server in place of the preview server:

python -m http.server -d docs
7 Likes

Thank you Saleem.

I don't know where you find the time and energy to drive the porting to Windows. Impressive work.

I will try to get and compile your Docc fork.

Unfortunately, each time I try to compile Docc on windows 10, Swift 5.9, I get this error:

error: command Compiling Swift Module 'SwiftDocC' (424 sources) failed: unable to spawn process 'C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe' (The filename or extension is too long.
)

I have tried the official repository (main) and also Saleem's fork on different branches (main, portable, windows) but not luck with the above error

The question is: Given the situation that all issues for a Windows version of DocC are fixed, I guess an according DocC will be part if the “next” toolchain version for Windows, so why not wait a little bit?

(Of course, your question is a very valid one.)

Waiting is fine, I didn't mean to imply that this was urgent.
I was just curios.

This is due to the toolchain version. There were fixes to SPM in 5.10 that are required. As those bills have not been setup yet, you would need to use the latest main snapshot.

This is not guaranteed to be immediate. There’s still two issues left to be resolved:

  1. The use of portable paths (see the patch)
  2. The changes required in the render application (more complicated

Additionally, given the number of branches, it does require some assistance to ensure that changes make it into the right release.