Skip to content

Commit

Permalink
Merge pull request #254 from adafruit/readthedocs-patch
Browse files Browse the repository at this point in the history
Added readthedocs file patch
  • Loading branch information
evaherrada authored Nov 9, 2021
2 parents 805b0dd + 77359dd commit 628f852
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 13 deletions.
26 changes: 13 additions & 13 deletions adabot/lib/circuitpython_library_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def get_result(self):
" without reference to import errno. See issue "
"https://github.com/adafruit/circuitpython/issues/1582"
)
ERROR_MISMATCHED_READTHEDOCS = "Mismatched readthedocs.yml"
ERROR_MISMATCHED_READTHEDOCS = "Mismatched readthedocs.yaml"
ERROR_MISSING_DESCRIPTION = "Missing repository description"
ERROR_MISSING_EXAMPLE_FILES = "Missing .py files in examples folder"
ERROR_MISSING_EXAMPLE_FOLDER = "Missing examples folder"
Expand All @@ -110,7 +110,7 @@ def get_result(self):
ERROR_MISSING_LINT = "Missing lint config"
ERROR_MISSING_CODE_OF_CONDUCT = "Missing CODE_OF_CONDUCT.md"
ERROR_MISSING_README_RST = "Missing README.rst"
ERROR_MISSING_READTHEDOCS = "Missing readthedocs.yml"
ERROR_MISSING_READTHEDOCS = "Missing readthedocs.yaml"
ERROR_MISSING_SETUP_PY = "For pypi compatibility, missing setup.py"
ERROR_MISSING_REQUIREMENTS_TXT = "For pypi compatibility, missing requirements.txt"
ERROR_MISSING_BLINKA = (
Expand Down Expand Up @@ -230,25 +230,25 @@ def __init__(

@property
def rtd_yml_base(self):
"""The parsed YAML from `.readthedocs.yml` in the cookiecutter-adafruit-circuitpython repo.
Used to verify that a library's `.readthedocs.yml` matches this version.
"""The parsed YAML from `.readthedocs.yaml` in the cookiecutter-adafruit-circuitpython repo.
Used to verify that a library's `.readthedocs.yaml` matches this version.
"""
if self._rtd_yaml_base is None:
rtd_yml_dl_url = (
"https://raw.githubusercontent.com/adafruit/cookiecutter-adafruit-"
"circuitpython/main/%7B%7B%20cookiecutter%20and%20'tmp_repo'%20%7D"
"%7D/%7B%25%20if%20cookiecutter.sphinx_docs%20in%20%5B'y'%2C%20'yes'"
"%5D%20%25%7D.readthedocs.yml%7B%25%20endif%20%25%7D"
"%5D%20%25%7D.readthedocs.yaml%7B%25%20endif%20%25%7D"
)
rtd_yml = requests.get(rtd_yml_dl_url)
if rtd_yml.ok:
try:
self._rtd_yaml_base = yaml.safe_load(rtd_yml.text)
except yaml.YAMLError:
print("Error parsing cookiecutter .readthedocs.yml.")
print("Error parsing cookiecutter .readthedocs.yaml.")
self._rtd_yaml_base = ""
else:
print("Error retrieving cookiecutter .readthedocs.yml")
print("Error retrieving cookiecutter .readthedocs.yaml")
self._rtd_yaml_base = ""

return self._rtd_yaml_base
Expand Down Expand Up @@ -645,7 +645,7 @@ def validate_contents(self, repo):
files = [x["name"] for x in content_list]

# ignore new/in-work repos, which should have less than 8 files:
# ___.py or folder, CoC, .github/, .readthedocs.yml, docs/,
# ___.py or folder, CoC, .github/, .readthedocs.yaml, docs/,
# examples/, README, LICENSE
if len(files) < 8:
BUNDLE_IGNORE_LIST.append(repo["name"])
Expand Down Expand Up @@ -701,11 +701,11 @@ def validate_contents(self, repo):
else:
errors.append(ERROR_UNABLE_PULL_REPO_CONTENTS)

if "readthedocs.yml" in files or ".readthedocs.yml" in files:
if "readthedocs.yaml" in files or ".readthedocs.yaml" in files:
if self.rtd_yml_base != "":
filename = "readthedocs.yml"
if ".readthedocs.yml" in files:
filename = ".readthedocs.yml"
filename = "readthedocs.yaml"
if ".readthedocs.yaml" in files:
filename = ".readthedocs.yaml"
file_info = content_list[files.index(filename)]
rtd_contents = requests.get(file_info["download_url"])
if rtd_contents.ok:
Expand All @@ -715,7 +715,7 @@ def validate_contents(self, repo):
errors.append(ERROR_MISMATCHED_READTHEDOCS)
except yaml.YAMLError:
self.output_file_data.append(
"Error parsing {} .readthedocs.yml.".format(repo["name"])
"Error parsing {} .readthedocs.yaml.".format(repo["name"])
)
errors.append(ERROR_OUTPUT_HANDLER)
else:
Expand Down
49 changes: 49 additions & 0 deletions patches/0001-Updated-readthedocs-file.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From df685288b18965c4089a8895b0eb3bf80c17423e Mon Sep 17 00:00:00 2001
From: dherrada <[email protected]>
Date: Tue, 9 Nov 2021 13:31:14 -0500
Subject: [PATCH] Updated readthedocs file

---
.readthedocs.yaml | 15 +++++++++++++++
.readthedocs.yml | 7 -------
2 files changed, 15 insertions(+), 7 deletions(-)
create mode 100644 .readthedocs.yaml
delete mode 100644 .readthedocs.yml

diff --git a/.readthedocs.yaml b/.readthedocs.yaml
new file mode 100644
index 0000000..95ec218
--- /dev/null
+++ b/.readthedocs.yaml
@@ -0,0 +1,15 @@
+# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
+#
+# SPDX-License-Identifier: Unlicense
+
+# Read the Docs configuration file
+# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
+
+# Required
+version: 2
+
+python:
+ version: "3.6"
+ install:
+ - requirements: docs/requirements.txt
+ - requirements: requirements.txt
diff --git a/.readthedocs.yml b/.readthedocs.yml
deleted file mode 100644
index 49dcab3..0000000
--- a/.readthedocs.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
-#
-# SPDX-License-Identifier: Unlicense
-
-python:
- version: 3
-requirements_file: docs/requirements.txt
--
2.25.1

0 comments on commit 628f852

Please sign in to comment.