docarchive can't be rendered with local python web server

Apple Recommended

Replies

If you check the video for Host and automate your DocC documentation, the discussion on Apache says that your web server should be able to customize requests including how to route them. Search the transcript for Vue.js web app. Quote from the transcript:

if the request starts with /documentation/ or /tutorials/ then the server should respond with the index.html file that's located in the documentation archive


There is a Node server, called serve that does just that. Using this server, I was able to locally host documentation & tutorials.

# using https://www.npmjs.com/package/serve
serve -h | grep requests
#      -s, --single                        Rewrite all not-found requests to `index.html`

My example usage for SlothCreator:

# Build
# path to Xcode 13 Beta, adjust when its out of Beta
#   having a known output builder folder is helpful when searching for the output
/Applications/Xcode-beta.app/Contents/Developer/usr/bin/xcodebuild \
  docbuild \
  -scheme "SlothCreator" \
  -derivedDataPath tmp/derivedDataPath
# Serve
# Find the Doc Archive, 
#   then serve over port 4001 using https://www.npmjs.com/package/serve
find tmp/derivedDataPath \
  -name "*.doccarchive" \
  -exec serve --listen 4001 --single {} \;

# open in Safari
open http://localhost:4001/documentation/SlothCreator
open http://localhost:4001/tutorials/SlothCreator

Bonus: would be nice to have this served over GitHub Pages