ammaraskar / sphinx-action

Github action that builds docs using sphinx and places errors inline
Apache License 2.0
195 stars 117 forks source link

Does not work with python3.10 #43

Open spagh-eddie opened 2 years ago

spagh-eddie commented 2 years ago

This syntax is causing the action to fail. The syntax is for python3.10.

# file.py

with (
    open(...) as f,  # this is line 119
    open(...) as g,
):
    do_cool_stuff()

error message:

[AutoAPI] Reading files... [ 26%] /github/workspace/.../file.py

Extension error (autoapi.extension):
Handler <function run_autoapi at 0x7f0ef2a43af0> for event 'builder-inited' threw an exception (exception: Parsing Python code failed:
invalid syntax (<unknown>, line 119))
make: *** [Makefile:20: html] Error 2
[sphinx-action] Starting sphinx-action build.
Running: 
====================================
Building docs in docs/
====================================
[sphinx-action] Running: ['make', 'html', '-e']
[sphinx-action] Build failed with 0 warnings
Traceback (most recent call last):
  File "/entrypoint.py", line 22, in <module>
    action.build_all_docs(github_env, [os.environ.get("INPUT_DOCS-FOLDER")])
  File "/sphinx_action/action.py", line 167, in build_all_docs
    raise RuntimeError("Build failed")
RuntimeError: Build failed

our action file:

name: Sphinx build

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Build HTML
      uses: ammaraskar/sphinx-action@0.4  # uses the /docs/requirements.txt file
hwayne commented 2 years ago

I think it's because the dockerfile uses the Sphinx 2.4.4 container, which is out of date.

flywire commented 2 years ago

Does that mean there is no Deploying a Sphinx project online?

hwayne commented 2 years ago

@flywire I ended up just building my own project manually:

      - name: directly build sphinx
        run: |
          pip install -r requirements.txt
          sphinx-build -D todo_include_todos=0 docs ./docs/_build/html/

Way easier than figuring out how to config this action overall.

SunC0der commented 1 year ago

Found an alternative solution: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-static-site-generators-with-python

He codes the html generation also manually and deploys the created webpage with his github action

kushalkolar commented 1 month ago

I got this to work if you specify the sphinx version when specifying the action, as shown in the readme: https://github.com/ammaraskar/sphinx-action?tab=readme-ov-file#how-to-use

My yaml, see the : uses: ammaraskar/sphinx-action@8.0.2

name: "Sphinx: Render docs"

on: push

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
    - uses: actions/checkout@v4
    - name: Build HTML
      uses: ammaraskar/sphinx-action@8.0.2
      with:
        pre-build-command: |
          apt-get update -y -qq
          apt-get install --no-install-recommends -y build-essential
          apt-get install --no-install-recommends -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers git-lfs
          # remove pygfx from install_requires, we install using pygfx@main
          sed -i "/pygfx/d" ./setup.py
          pip install git+https://github.com/pygfx/pygfx.git@main
          pip install -e ".[notebook,docs,tests]"
    - name: Upload artifacts
      uses: actions/upload-artifact@v4
      with:
        name: html-docs
        path: docs/build/html/
    - name: Deploy
      uses: peaceiris/actions-gh-pages@v3
      if: github.ref == 'refs/heads/main'
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        publish_dir: docs/build/html