@@ -55,19 +55,12 @@ def manipulate_config(app, config):
5555
5656 # We are using APIv2 to pull active versions, downloads and subprojects
5757 # because APIv3 requires a token.
58- try :
59- response_project = requests .get (
60- f"{ scheme } ://{ production_domain } /api/v3/projects/{ project_slug } /" ,
61- timeout = 2 ,
62- ).json ()
63- language = response_project ["language" ]["code" ]
64- except Exception :
65- logger .warning (
66- "An error ocurred when hitting API to fetch project language. Defaulting to 'en'." ,
67- exc_info = True ,
68- )
69- language = "en"
7058
59+ # Project language.
60+ # Do not inquire the RTD API for the project language. We can safely just use English.
61+ language = "en"
62+
63+ # Project versions. Acquire them from RTD's API.
7164 try :
7265 response_versions = requests .get (
7366 f"{ scheme } ://{ production_domain } /api/v3/projects/{ project_slug } /versions/?active=true" ,
@@ -84,51 +77,11 @@ def manipulate_config(app, config):
8477 )
8578 versions = []
8679
87- try :
88- downloads = []
89- for version in response_versions ["results" ]:
90- if version ["slug" ] != version_slug :
91- continue
92-
93- for key , value in version ["downloads" ]:
94- downloads .append (
95- (
96- key ,
97- value ,
98- ),
99- )
100- except Exception :
101- logger .warning (
102- "An error ocurred when generating the list of downloads. Defaulting to an empty list." ,
103- exc_info = True ,
104- )
105- downloads = []
106-
107- try :
108- subprojects = []
109- response_project = requests .get (
110- f"{ scheme } ://{ production_domain } /api/v2/project/?slug={ project_slug } " ,
111- timeout = 2 ,
112- ).json ()
113- project_id = response_project ["results" ][0 ]["id" ]
80+ # Project downloads. What are they?
81+ downloads = []
11482
115- response_subprojects = requests .get (
116- f"{ scheme } ://readthedocs.org/api/v2/project/{ project_id } /subprojects/" ,
117- timeout = 2 ,
118- ).json ()
119- for subproject in response_subprojects ["subprojects" ]:
120- subprojects .append (
121- (
122- subproject ["slug" ],
123- subproject ["canonical_url" ],
124- ),
125- )
126- except Exception :
127- logger .warning (
128- "An error ocurred when hitting API to fetch project/subprojects. Defaulting to an empty list." ,
129- exc_info = True ,
130- )
131- subprojects = []
83+ # Subprojects. We don't use them.
84+ subprojects = []
13285
13386 # Add project information to the template context.
13487 context = {
0 commit comments