Skip to content

Commit 1f51dfc

Browse files
committed
Add script to generate CFEP index
List of CFEPs added automatically to the cfep-index.rst file
1 parent 1f87f24 commit 1f51dfc

File tree

3 files changed

+68
-14
lines changed

3 files changed

+68
-14
lines changed

.ci_scripts/generate_cfep_index.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import re
2+
import requests
3+
from dataclasses import dataclass
4+
from pathlib import Path
5+
6+
REPO_CONTENTS = "https://api.github.com/repos/conda-forge/cfep/contents/"
7+
TITLE_PATTERN = "<td>\s*Title\s*</td><td>\s*(.*)\s*</td>"
8+
STATUS_PATTERN = "<td>\s*Status\s*</td><td>\s*(.*)\s*</td>"
9+
REPO_DIR = Path(__file__).parents[1].absolute()
10+
CFEP_INDEX_RST = REPO_DIR / "src" / "orga" / "cfep-index.rst"
11+
12+
13+
@dataclass
14+
class Cfep:
15+
filename: str
16+
title: str
17+
status: str
18+
html_url: str
19+
20+
@property
21+
def name(self) -> str:
22+
return self.filename.replace(".md", "")
23+
24+
def rst_link(self) -> str:
25+
clean_title = self.title.replace("`", "")
26+
return f"`{self.name.upper()}: {clean_title} <{self.html_url}>`_ -- *{self.status}*"
27+
28+
def md_link(self) -> str:
29+
return (
30+
f"[{self.name.upper()}: {self.title}]({self.html_url}) -- *{self.status}*"
31+
)
32+
33+
34+
def get_cfeps():
35+
"""Generator that returns all CFEPs from GitHub repo"""
36+
response = requests.get(
37+
REPO_CONTENTS, headers={"Accept": "application/vnd.github.v3+json"}
38+
)
39+
response.raise_for_status()
40+
for content in response.json():
41+
if not content["name"].startswith("cfep"):
42+
continue
43+
if content["name"] == "cfep-00.md":
44+
# Hardcode title and status for CFEP-00
45+
yield Cfep(
46+
content["name"], "CFEP Template", "Proposed", content["html_url"]
47+
)
48+
continue
49+
cfep_response = requests.get(content["download_url"])
50+
cfep_response.raise_for_status()
51+
cfep_text = cfep_response.text
52+
m = re.search(TITLE_PATTERN, cfep_text)
53+
title = m.group(1).strip() if m else ""
54+
m = re.search(STATUS_PATTERN, cfep_text)
55+
status = m.group(1).strip() if m else ""
56+
yield Cfep(content["name"], title, status, content["html_url"])
57+
58+
59+
def write_cfep_index():
60+
with CFEP_INDEX_RST.open("a") as f:
61+
for cfep in get_cfeps():
62+
f.write(f"* {cfep.rst_link()}\n")
63+
64+
65+
if __name__ == "__main__":
66+
write_cfep_index()

.ci_scripts/update_docs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ python .ci_scripts/generate_html.py
2121
mv docs/README docs-README
2222
rm -rf docs/
2323

24+
python .ci_scripts/generate_cfep_index.py
25+
2426
pushd src
2527
make html
2628
mv _build/html ../docs

src/orga/cfep-index.rst

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,3 @@ These CFEPs are similar to `Python's PEP <https://www.python.org/dev/peps/>`_ an
88
CFEPs are stored in the `cfep GitHub repository <https://github.com/conda-forge/cfep>`_.
99
Below is a list of conda-forge enhancement proposals (CFEP):
1010

11-
* `CFEP 00: CFEP Template <https://github.com/conda-forge/cfep/blob/master/cfep-00.md>`_ -- *Proposed*
12-
* `CFEP 01: CFEP Purpose and Guidelines <https://github.com/conda-forge/cfep/blob/master/cfep-01.md>`_ -- *Proposed*
13-
* `CFEP 02: Upgrade default macOS Travis image to xcode6.4 <https://github.com/conda-forge/cfep/blob/master/cfep-02.md>`_ -- *Accepted*
14-
* `CFEP 03: Providing manually uploaded builds on the conda-forge anaconda channel <https://github.com/conda-forge/cfep/blob/master/cfep-03.md>`_ -- *Proposed*
15-
* `CFEP 05: Providing pre-release builds on the conda-forge anaconda channel <https://github.com/conda-forge/cfep/blob/master/cfep-05.md>`_ -- *Accepted*
16-
* `CFEP 07: Migration strategy to Anaconda compilers <https://github.com/conda-forge/cfep/blob/master/cfep-07.md>`_ -- *Proposed*
17-
* `CFEP 08: Packages which are "Too Big to Fail" <https://github.com/conda-forge/cfep/blob/master/cfep-08.md>`_ -- *Deferred*
18-
* `CFEP 09: Pinning Proposal <https://github.com/conda-forge/cfep/blob/master/cfep-09.md>`_ -- *Proposed*
19-
* `CFEP 11: Automated Closing of Excessively Old PRs on Staged Recipes <https://github.com/conda-forge/cfep/blob/master/cfep-11.md>`_ -- *Accepted*
20-
* `CFEP 13: Securing conda-forge Uploads to anaconda.org <https://github.com/conda-forge/cfep/blob/master/cfep-13.md>`_ -- *Accepted*
21-
* `CFEP 14: Security and Systems Subteam <https://github.com/conda-forge/cfep/blob/master/cfep-14.md>`_ -- *Draft*
22-
* `CFEP 15: Deprecate Python 2.7 and vs2008 <https://github.com/conda-forge/cfep/blob/master/cfep-15.md>`_ -- *Accepted*
23-
* `CFEP 16: Setting license and license_family field <https://github.com/conda-forge/cfep/blob/master/cfep-16.md>`_ -- *Proposed*
24-
* `CFEP 18: Packaging static libraries <https://github.com/conda-forge/cfep/blob/master/cfep-18.md>`_ -- *Accepted*

0 commit comments

Comments
 (0)