Skip to content

Fix readthedocs build #15437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
env:
TOXENV: docs
TOX_SKIP_MISSING_INTERPRETERS: False
VERIFY_MYPY_ERROR_CODES: 1
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand Down
11 changes: 8 additions & 3 deletions docs/source/html_builder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import json
import os
import textwrap
from pathlib import Path
from typing import Any
Expand All @@ -9,8 +10,6 @@
from sphinx.application import Sphinx
from sphinx.builders.html import StandaloneHTMLBuilder

from mypy.errorcodes import error_codes


class MypyHTMLBuilder(StandaloneHTMLBuilder):
def __init__(self, app: Sphinx) -> None:
Expand All @@ -21,7 +20,9 @@ def write_doc(self, docname: str, doctree: document) -> None:
super().write_doc(docname, doctree)
self._ref_to_doc.update({_id: docname for _id in doctree.ids})

def _write_ref_redirector(self) -> None:
def _verify_error_codes(self) -> None:
from mypy.errorcodes import error_codes

known_missing = {
# TODO: fix these before next release
"annotation-unchecked",
Expand All @@ -39,6 +40,10 @@ def _write_ref_redirector(self) -> None:
raise ValueError(
f"Some error codes are not documented: {', '.join(sorted(missing_error_codes))}"
)

def _write_ref_redirector(self) -> None:
if os.getenv("VERIFY_MYPY_ERROR_CODES"):
self._verify_error_codes()
p = Path(self.outdir) / "_refs.html"
data = f"""
<html>
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ commands =

[testenv:docs]
description = invoke sphinx-build to build the HTML docs
passenv =
VERIFY_MYPY_ERROR_CODES
deps = -rdocs/requirements-docs.txt
commands =
sphinx-build -d "{toxworkdir}/docs_doctree" docs/source "{toxworkdir}/docs_out" --color -W -bhtml {posargs}
Expand Down