pdoc icon indicating copy to clipboard operation
pdoc copied to clipboard

Offline html output

Open yiyuezhuo opened this issue 5 years ago • 1 comments

Expected Behavior

To generate an offline document, using pdoc, I found that I can generate pdf document but the pdf doc seems a little confusing. The html output is pretty but link to some online assets such as https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css, so this option is not available for a offline project. A extra option to scratch those static assets and "freeze" them in a local directory maybe very useful.

Additional info

  • pdoc version: 0.7.2

yiyuezhuo avatar Dec 13 '19 07:12 yiyuezhuo

I've been after the same offline use issue and found this issue, plus the mentioned #337. The latter is a good start, but I had to elaborate a bit more to actually get it working without CORS problems, since the browser sees the files with a file:// protocol. My postprocessing looks like this:

for htmlfile in $(find . -name '*.html'); do
    pushd $(dirname ${htmlfile})
    bn=$(basename ${htmlfile})
    grep -oPh 'https://cdnjs[^"]*' ${bn} | sort | uniq | wget -nc -i -
    sed -i -E 's,https://cdnjs([^"]*?/)+,,g' ${bn}
    sed -i -E 's, integrity=".*?",,g' ${bn}
    sed -i -E 's, crossorigin>,>,g' ${bn}
    popd
done

It is not very clean, as the same resources are downloaded to each and every subdirectory, but at least it works.

phlibi avatar Jan 12 '22 15:01 phlibi