Search code examples
graphvizread-the-docs

How to make ReadTheDocs build graphs using graphviz


I have configured automated documentation building on https://readthedocs.org/ portal. I am using sphinx.ext.autodoc extension which builds graphs using graphviz.

I am not sure how to configure .readthedocs.yaml file to have graphviz installed before the build. So I do have graphs properly built with no warning:

generating indices... WARNING: dot command 'dot' cannot be run (needed for graphviz output), check the graphviz_dot setting

I tried:

  • this:
build:
  os: ubuntu-22.04
  tools:
    python: "3.11"
  jobs:
    pre_install:
      - sudo apg-get update
      - sudo apg-get install graphviz

then I see error: /bin/sh: 1: sudo: not found

  • and this:
build:
  os: ubuntu-22.04
  tools:
    python: "3.11"
  jobs:
    pre_install:
      - apg-get update
      - apg-get install graphviz

then I see an error:

E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/

Solution

  • I just got an answer from ReadTheDocs support, so there are changes to .readthedocs.yaml file structure and apps can be installed by specifying in build.apt_packages section. Documentation: https://docs.readthedocs.io/en/stable/config-file/v2.html#build-apt-packages

    So the proper config would look like this:

    build:
      os: ubuntu-22.04
      tools:
        python: "3.11"
      apt_packages:
        - graphviz