diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 7a088c76d..5eb3fcd41 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -98,25 +98,43 @@ jobs: git fetch origin gh-pages git reset --hard origin/gh-pages - rm -rf docs - mv ../site docs + # Preserve API reference folders generated by the `build` job + # (for example `master/`, `vX.Y.Z/`), while fully replacing + # the mkdocs website content at the root. + api_doc_dirs=() + for dir in */; do + if [ -f "${dir}libp2p.html" ]; then + api_doc_dirs+=("${dir%/}") + fi + done - # Create a root index.html that redirects to /docs/ so that - # https://vacp2p.github.io/nim-libp2p/ does not return 404 - cat > index.html << 'EOF' - - -
- - - -Redirecting to documentation...
- - - EOF + shopt -s dotglob nullglob + for path in ./*; do + base=${path#./} + if [ "$base" = ".git" ]; then + continue + fi + + keep=false + for dir in "${api_doc_dirs[@]}"; do + if [ "$base" = "$dir" ]; then + keep=true + break + fi + done + + if [ "$keep" = false ]; then + rm -rf "$path" + fi + done + shopt -u dotglob nullglob + + cp -a ../site/. . + + # Maintain backward compatibility for `/docs/...` links. + rm -rf docs + mkdir -p docs + cp -a ../site/. docs/ git add . diff --git a/README.md b/README.md index 3dccf4b1f..205d24900 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ The currently supported Nim versions are v2.2.4 and v2.2.10. nimble install libp2p ``` -You'll find the nim-libp2p documentation [here](https://vacp2p.github.io/nim-libp2p/docs/). See [examples](./examples) for simple usage patterns. +You'll find the nim-libp2p documentation [here](https://vacp2p.github.io/nim-libp2p/). See [examples](./examples) for simple usage patterns. ## Development diff --git a/examples/README.md b/examples/README.md index c2a8b2523..d4a3c3ba9 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,5 +1,5 @@ # nim-libp2p examples -In this folder, you'll find the sources of the [nim-libp2p website](https://vacp2p.github.io/nim-libp2p/docs/) +In this folder, you'll find the sources of the [nim-libp2p website](https://vacp2p.github.io/nim-libp2p/) We recommand to follow the tutorials on the website, but feel free to grok the sources here! diff --git a/libp2p.nim b/libp2p.nim index 97579612c..ad502c00b 100644 --- a/libp2p.nim +++ b/libp2p.nim @@ -4,7 +4,7 @@ when defined(nimdoc): ## Welcome to the nim-libp2p reference! ## - ## If you're new to nim-libp2p, you can find a tutorial `here