Skip to content

Commit

Permalink
Convert documentation to the new front (#271)
Browse files Browse the repository at this point in the history
* Main conversion

* Doc styling

* Style

* New front deploy

* Fixes

* Fixes

* Fix new docstrings

* Style
  • Loading branch information
sgugger authored Mar 10, 2022
1 parent 6ffab17 commit fb5ed62
Show file tree
Hide file tree
Showing 44 changed files with 1,898 additions and 2,501 deletions.
42 changes: 0 additions & 42 deletions .github/deploy_doc.sh

This file was deleted.

108 changes: 108 additions & 0 deletions .github/workflows/build_dev_documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Build dev documentation

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build_and_package:
runs-on: ubuntu-latest
container:
image: huggingface/transformers-doc-builder
env:
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.number }}
EVENT_CONTEXT: ${{ toJSON(github.event) }}

steps:
- uses: actions/checkout@v2
with:
repository: 'huggingface/doc-builder'
path: doc-builder

- uses: actions/checkout@v2
with:
repository: 'huggingface/accelerate'
path: accelerate

- uses: actions/setup-node@v2
with:
node-version: '16'

- name: Set env
run: |
echo "WRITE=$(echo 'ghp_'$(wget -qO- lysand.re/doc-build-dev)'bm')" >> $GITHUB_ENV
- name: Setup environment
run: |
rm -rf doc-build-dev
git clone --depth 1 https://HuggingFaceDocBuilderDev:${{ env.WRITE }}@github.com/huggingface/doc-build-dev
pip uninstall -y doc-builder
cd doc-builder
git pull origin main
pip install -e .
cd ..
cd accelerate
pip install .[dev]
cd ..
- name: Setup git
run: |
git config --global user.name "Hugging Face Doc Builder"
git config --global user.email docs@huggingface.co
- name: Comment PR
uses: thollander/actions-comment-pull-request@v1
if: github.event.action == 'opened'

with:
message: 'The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/accelerate/pr_${{ env.PR_NUMBER }}). All of your documentation changes will be reflected on that endpoint.'
GITHUB_TOKEN: ${{ env.WRITE }}

- name: Find Comment
if: github.event.action == 'reopened'
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ env.PR_NUMBER }}
comment-author: HuggingFaceDocBuilderDev

- name: Update comment
if: github.event.action == 'reopened'
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
token: ${{ env.WRITE }}
edit-mode: replace
body: |
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_${{ env.PR_NUMBER }}). All of your documentation changes will be reflected on that endpoint.
- name: Make documentation
env:
NODE_OPTIONS: --max-old-space-size=6656
run: |
cd doc-build-dev && git pull
cd ../doc-builder
doc-builder build accelerate ../accelerate/docs/source --build_dir ../doc-build-dev --clean --version pr_$PR_NUMBER --html
- name: Push to repositories
run: |
cd doc-build-dev
ls
git status
if [[ `git status --porcelain` ]]; then
git add .
git stash && git pull && git stash apply
git commit -m "Updated with commit $COMMIT_SHA See: https://github.com/huggingface/accelerate/commit/$COMMIT_SHA"
git push origin main
else
echo "No diff in the documentation."
fi
shell: bash
83 changes: 83 additions & 0 deletions .github/workflows/build_documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build documentation

on:
push:
branches:
- master
- doc-builder*
- v*-release

jobs:
build_and_package:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/setup-node@v2
with:
node-version: '16'

- uses: actions/checkout@v2
with:
repository: 'huggingface/doc-builder'
path: doc-builder

- uses: actions/checkout@v2
with:
repository: 'huggingface/doc-build'
path: doc-build
token: ${{ secrets.HUGGINGFACE_PUSH }}

- uses: actions/checkout@v2
with:
repository: 'huggingface/accelerate'
path: accelerate

- name: Loading cache.
uses: actions/cache@v2
id: cache
with:
path: ~/.cache/pip
key: v1-test_build_doc
restore-keys: |
v1-test_build_doc-${{ hashFiles('setup.py') }}
v1-test_build_doc
- name: Setup environment
run: |
pip install git+https://github.com/huggingface/doc-builder
cd accelerate
pip install .[dev]
cd ..
- name: Setup git
run: |
git config --global user.name "Hugging Face Doc Builder"
git config --global user.email docs@huggingface.co
cd doc-build
git pull origin main
cd ..
- name: Make documentation
run: |
cd doc-builder &&
doc-builder build accelerate ../accelerate/docs/source --build_dir ../doc-build --clean --html &&
cd ..
env:
NODE_OPTIONS: --max-old-space-size=6656

- name: Push to repositories
run: |
cd doc-build &&
if [[ `git status --porcelain` ]]; then
git add . &&
git stash && git pull && git stash apply &&
git commit -m "Updated with commit ${{ github.sha }} \n\nSee: https://github.com/huggingface/accelerate/commit/${{ github.sha }}" &&
git push origin main
else
echo "No diff in the documentation."
fi &&
cd .. &&
63 changes: 63 additions & 0 deletions .github/workflows/delete_dev_documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Delete dev documentation

on:
pull_request:
types: [ closed ]


jobs:
build_and_package:
runs-on: ubuntu-latest
container:
image: huggingface/transformers-doc-builder

env:
PR_NUMBER: ${{ github.event.number }}

steps:
- name: Set env
run: |
echo "WRITE=$(echo 'ghp_'$(wget -qO- lysand.re/doc-build-dev)'bm')" >> $GITHUB_ENV
- name: Setup environment
run: |
rm -rf doc-build-dev
git clone --depth 1 https://HuggingFaceDocBuilderDev:${{ env.WRITE }}@github.com/huggingface/doc-build-dev
- name: Setup git
run: |
git config --global user.name "Hugging Face Doc Builder"
git config --global user.email docs@huggingface.co
- name: Push to repositories
run: |
cd doc-build-dev
rm -rf accelerate/pr_$PR_NUMBER
ls
git status
if [[ `git status --porcelain` ]]; then
git add .
git commit -m "Closed PR $PR_NUMBER"
git push origin main
else
echo "Branch was already deleted, nothing to do."
fi
shell: bash

- name: Find Comment
if: ${{ always() }}
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ env.PR_NUMBER }}
comment-author: HuggingFaceDocBuilderDev

- name: Update comment
if: ${{ always() }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
token: ${{ env.WRITE }}
edit-mode: replace
body: |
_The documentation is not available anymore as the PR was closed or merged._
37 changes: 0 additions & 37 deletions .github/workflows/docs-deploy.yml

This file was deleted.

4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,3 @@ style:
# Run tests for the library
test:
python -m pytest -n auto --dist=loadfile -s -v ./tests/

# Check that docs can build
docs:
cd docs && make html SPHINXOPTS="-W"
Binary file removed docs/source/_static/css/Calibre-Light.ttf
Binary file not shown.
Binary file removed docs/source/_static/css/Calibre-Medium.otf
Binary file not shown.
Binary file removed docs/source/_static/css/Calibre-Regular.otf
Binary file not shown.
Binary file removed docs/source/_static/css/Calibre-Thin.otf
Binary file not shown.
16 changes: 0 additions & 16 deletions docs/source/_static/css/code-snippets.css

This file was deleted.

Loading

0 comments on commit fb5ed62

Please sign in to comment.