Repository: qtile/qtile

Issue:
Can't build HTML documentation
### The issue:

Qtile version is 0.22.1. I make a python virtual environment and install the requirements for building the docs, but when running `make html` I get an error about screenshots not being found.

Here's the full stack trace:
```
# Sphinx version: 5.3.0
# Python version: 3.9.10 (CPython)
# Docutils version: 0.17.1 release
# Jinja2 version: 3.1.2
# Last messages:
#   reading sources... [ 51%] manual/install/nixos
#   reading sources... [ 53%] manual/install/slackware
#   reading sources... [ 54%] manual/install/ubuntu
#   reading sources... [ 56%] manual/install/without-dm
#   reading sources... [ 57%] manual/license
#   reading sources... [ 59%] manual/ref/commands
#   reading sources... [ 60%] manual/ref/extensions
#   reading sources... [ 62%] manual/ref/hooks
#   reading sources... [ 64%] manual/ref/layouts
#   reading sources... [ 65%] manual/ref/widgets
# Loaded extensions:
#   sphinx.ext.mathjax (5.3.0) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.2) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (2.0.0) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.5) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.3) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.12) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/alabaster/__init__.py
#   sphinx.ext.autodoc.preserve_defaults (5.3.0) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/ext/autodoc/preserve_defaults.py
#   sphinx.ext.autodoc.type_comment (5.3.0) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/ext/autodoc/type_comment.py
#   sphinx.ext.autodoc.typehints (5.3.0) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/ext/autodoc/typehints.py
#   sphinx.ext.autodoc (5.3.0) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/ext/autodoc/__init__.py
#   sphinx.ext.autosummary (5.3.0) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/ext/autosummary/__init__.py
#   sphinx.ext.coverage (5.3.0) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/ext/coverage.py
#   sphinx.ext.graphviz (5.3.0) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/ext/graphviz.py
#   sphinx.ext.todo (5.3.0) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/ext/todo.py
#   sphinx.ext.viewcode (5.3.0) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/ext/viewcode.py
#   sphinxcontrib.seqdiag (3.0.0) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinxcontrib/seqdiag.py
#   sphinx_qtile (unknown version) from /home/daniel/proj/qtile/docs/sphinx_qtile.py
#   numpydoc (1.5.0) from /home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/numpydoc/__init__.py
Traceback (most recent call last):
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/cmd/build.py", line 281, in build_main
    app.build(args.force_all, args.filenames)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/application.py", line 347, in build
    self.builder.build_update()
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/builders/__init__.py", line 310, in build_update
    self.build(to_build,
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/builders/__init__.py", line 326, in build
    updated_docnames = set(self.read())
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/builders/__init__.py", line 433, in read
    self._read_serial(docnames)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/builders/__init__.py", line 454, in _read_serial
    self.read_doc(docname)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/builders/__init__.py", line 510, in read_doc
    publisher.publish()
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/core.py", line 217, in publish
    self.document = self.reader.read(self.source, self.parser,
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/io.py", line 104, in read
    self.parse()
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/parsers.py", line 78, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 170, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/statemachine.py", line 239, in run
    context, next_state, result = self.check_line(
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
    return method(match, context, next_state)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 3008, in text
    self.section(title.lstrip(), source, style, lineno + 1, messages)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 393, in new_subsection
    newabsoffset = self.nested_parse(
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/statemachine.py", line 239, in run
    context, next_state, result = self.check_line(
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
    return method(match, context, next_state)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 2342, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construct
    return method(self, expmatch)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 2096, in directive
    return self.run_directive(
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 2146, in run_directive
    result = directive_instance.run()
  File "/home/daniel/proj/qtile/docs/sphinx_qtile.py", line 121, in run
    nested_parse_with_titles(self.state, result, node)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/sphinx/util/nodes.py", line 340, in nested_parse_with_titles
    return state.nested_parse(content, 0, node, match_titles=1)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/statemachine.py", line 239, in run
    context, next_state, result = self.check_line(
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
    return method(match, context, next_state)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 2342, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construct
    return method(self, expmatch)
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 2096, in directive
    return self.run_directive(
  File "/home/daniel/proj/qtile/docs/venv/lib64/python3.9/site-packages/docutils/parsers/rst/states.py", line 2146, in run_directive
    result = directive_instance.run()
  File "/home/daniel/proj/qtile/docs/sphinx_qtile.py", line 119, in run
    for line in self.make_rst():
  File "/home/daniel/proj/qtile/docs/sphinx_qtile.py", line 164, in make_rst
    with open(index, "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/daniel/proj/qtile/docs/_static/screenshots/widgets/shots.json'
```

I also get the message `WARNING: html_extra_path entry '_static/screenshots' does not exist`.

### Required:

- [X] I have searched past issues to see if this bug has already been reported.


Discussion:
We disabled screenshot building by default to speed up build times when testing locally. There's obviously still a bug there though (which isn't on my system as that file exists but is ignored by git).

While I'm fixing it, you could enable the screenshot build by setting the `QTILE_BUILD_SCREENSHOTS` environment variable.

Resolving patch:
diff --git a/docs/sphinx_qtile.py b/docs/sphinx_qtile.py
--- a/docs/sphinx_qtile.py
+++ b/docs/sphinx_qtile.py
@@ -163,7 +163,7 @@ def make_rst(self):
             try:
                 with open(index, "r") as f:
                     shots = json.load(f)
-            except json.JSONDecodeError:
+            except (json.JSONDecodeError, FileNotFoundError):
                 shots = {}
 
             widget_shots = shots.get(class_name.lower(), dict())


Test patch: